Exemplo n.º 1
0
 public static function createDeployment($deployment, array $deployInfo, array $deployHostSearch, array $deployStaticHosts)
 {
     if (self::$init === false) {
         self::init();
     }
     if (($return = NagRedis::sAdd(md5('deployments'), $deployment)) !== false) {
         $deployInfo['type'] = 'rev';
         if (($return = NagRedis::hMSet(md5('deployment:' . $deployment), $deployInfo)) !== false) {
             NagRedis::hIncrBy(md5('deployment:' . $deployment), 'revision');
             NagRedis::hIncrBy(md5('deployment:' . $deployment), 'nextrevision', 2);
             if (!empty($deployHostSearch)) {
                 foreach ($deployHostSearch as $md5Key => $tmpArray) {
                     NagRedis::sAdd(md5('deployment:' . $deployment) . ':hostsearches', $md5Key);
                     NagRedis::hMset(md5('deployment:' . $deployment) . ':hostsearch:' . $md5Key, $tmpArray);
                 }
             }
             if (!empty($deployStaticHosts)) {
                 NagRedis::set(md5('deployment:' . $deployment) . ':statichosts', json_encode($deployStaticHosts));
             }
             if ($deployment != 'common' && $deployInfo['deploystyle'] == 'commonrepo') {
                 self::addCommonRepo($deployment);
             }
             $deployData = new DeploymentData($deployment, $deployInfo, $deployHostSearch, $deployStaticHosts, 'create');
             self::$log->addToLog($deployData);
             return true;
         }
     }
     return false;
 }