/**
  * stage 
  * 
  * @access public
  * @return void
  */
 public function stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('command_error');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $viewData->commands = RevDeploy::getCommonMergedDeploymentCommands($deployment, $modrevision, false);
     $viewData->deployment = $deployment;
     $this->sendResponse('command_stage', $viewData);
 }
 public function copy_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('svc_error');
     $this->checkGroupAuth($deployment);
     $this->checkDeploymentRevStatus($deployment);
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $svcName = $this->getParam('svcName');
     $svcInfo = $this->fetchSvcInfo($deployment, 'copy_write', $modrevision);
     if (RevDeploy::existsDeploymentSvc($deployment, $svcName, $modrevision) === true) {
         $viewData->error = 'Service template information exists for ' . $svcName . ' into ' . $deployment . ' Deployment';
         $viewData->action = 'copy_write';
         $viewData->deployment = $deployment;
         $viewData->svctemplates = RevDeploy::getCommonMergedDeploymentSvcTemplates($deployment, $modrevision);
         $viewData->svcgroups = RevDeploy::getCommonMergedDeploymentSvcGroups($deployment, $modrevision);
         $viewData->svcchkcmds = RevDeploy::getCommonMergedDeploymentCommands($deployment, $modrevision);
         $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
         $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
         $viewData->contactgroups = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $modrevision);
         $viewData->svcInfo = $svcInfo;
         $this->sendResponse('svc_action_stage', $viewData);
     }
     if (RevDeploy::createDeploymentSvc($deployment, $svcName, $svcInfo, $modrevision) === false) {
         $viewData->header = $this->getErrorHeader('svc_error');
         $viewData->error = 'Unable to write service tempalte information for ' . $svcName . ' into ' . $deployment . ' Deployment';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->deployment = $deployment;
     $viewData->svc = $svcName;
     $this->sendResponse('svc_write', $viewData);
 }
示例#3
0
 public static function copyDeploymentRevision($deployment, $fromrev, $torev)
 {
     if (self::$init === false) {
         self::init();
     }
     self::$m_commonrepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $results = array();
     $results['timeperiods'] = RevDeploy::getCommonMergedDeploymentTimeperiodswData($deployment, $fromrev);
     $results['commands'] = RevDeploy::getCommonMergedDeploymentCommands($deployment, $fromrev, false);
     $results['contacttemplates'] = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $fromrev);
     $results['contactgroups'] = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $fromrev);
     $results['contacts'] = RevDeploy::getCommonMergedDeploymentContacts($deployment, $fromrev);
     $results['hosttemplates'] = RevDeploy::getCommonMergedDeploymentHostTemplates($deployment, $fromrev);
     $results['hostgroups'] = RevDeploy::getCommonMergedDeploymentHostGroups($deployment, $fromrev);
     $results['servicetemplates'] = RevDeploy::getCommonMergedDeploymentSvcTemplates($deployment, $fromrev);
     $results['servicegroups'] = RevDeploy::getCommonMergedDeploymentSvcGroups($deployment, $fromrev);
     $results['servicedependencies'] = RevDeploy::getCommonMergedDeploymentSvcDependencies($deployment, $fromrev);
     $results['serviceescalations'] = RevDeploy::getDeploymentSvcEscalationswInfo($deployment, $fromrev);
     $results['services'] = RevDeploy::getCommonMergedDeploymentSvcs($deployment, $fromrev);
     $results['nodetemplates'] = RevDeploy::getDeploymentNodeTemplateswInfo($deployment, $fromrev);
     $results['resourcecfg'] = RevDeploy::getDeploymentResourceCfg($deployment, $fromrev);
     $results['cgicfg'] = RevDeploy::getDeploymentCgiCfg($deployment, $fromrev);
     $results['modgearmancfg'] = RevDeploy::getDeploymentModgearmanCfg($deployment, $fromrev);
     $results['nagioscfg'] = RevDeploy::getDeploymentNagiosCfg($deployment, $fromrev);
     $results['nrpecmds'] = RevDeploy::getDeploymentNRPECmdswInfo($deployment, $fromrev);
     $results['nrpecfg'] = RevDeploy::getDeploymentNRPECfg($deployment, $fromrev);
     $results['nrpeplugins'] = RevDeploy::getDeploymentNRPEPluginswData($deployment, $fromrev);
     $results['supnrpecfg'] = RevDeploy::getDeploymentSupNRPECfg($deployment, $fromrev);
     $results['supnrpeplugins'] = RevDeploy::getDeploymentSupNRPEPluginswData($deployment, $fromrev);
     $results['nagiosplugins'] = RevDeploy::getDeploymentNagiosPluginswData($deployment, $fromrev);
     foreach ($results as $key => $value) {
         if (empty($value)) {
             continue;
         }
         switch ($key) {
             case 'timeperiods':
                 self::copyTimeperiods($deployment, $torev, $results['timeperiods']);
                 break;
             case 'commands':
                 self::copyCommands($deployment, $torev, $results['commands']);
                 break;
             case 'contacttemplates':
                 self::copyContactTemplates($deployment, $torev, $results['contacttemplates']);
                 break;
             case 'contactgroups':
                 self::copyContactGroups($deployment, $torev, $results['contactgroups']);
                 break;
             case 'contacts':
                 self::copyContacts($deployment, $torev, $results['contacts']);
                 break;
             case 'hosttemplates':
                 self::copyHostTemplates($deployment, $torev, $results['hosttemplates']);
                 break;
             case 'hostgroups':
                 self::copyHostGroups($deployment, $torev, $results['hostgroups']);
                 break;
             case 'servicetemplates':
                 self::copyServiceTemplates($deployment, $torev, $results['servicetemplates']);
                 break;
             case 'servicegroups':
                 self::copyServiceGroups($deployment, $torev, $results['servicegroups']);
                 break;
             case 'servicedependencies':
                 self::copyServiceDependencies($deployment, $torev, $results['servicedependencies']);
                 break;
             case 'serviceescalations':
                 self::copyServiceEscalations($deployment, $torev, $results['serviceescalations']);
                 break;
             case 'services':
                 self::copyServices($deployment, $torev, $results['services']);
                 break;
             case 'nodetemplates':
                 self::copyNodeTemplates($deployment, $torev, $results['nodetemplates']);
                 break;
             case 'resourcecfg':
                 self::copyResourceCfg($deployment, $torev, $results['resourcecfg']);
                 break;
             case 'cgicfg':
                 self::copyCGICfg($deployment, $torev, $results['cgicfg']);
                 break;
             case 'modgearmancfg':
                 self::copyModgearmanCfg($deployment, $torev, $results['modgearmancfg']);
                 break;
             case 'nagioscfg':
                 self::copyNagiosCfg($deployment, $torev, $results['nagioscfg']);
                 break;
             case 'nrpecmds':
                 self::copyNRPECmds($deployment, $torev, $results['nrpecmds']);
                 break;
             case 'nrpecfg':
                 self::copyNRPECfg($deployment, $torev, $results['nrpecfg']);
                 break;
             case 'nrpeplugins':
                 self::copyNRPEPlugins($deployment, $torev, $results['nrpeplugins']);
                 break;
             case 'supnrpecfg':
                 self::copySupNRPECfg($deployment, $torev, $results['supnrpecfg']);
                 break;
             case 'supnrpeplugins':
                 self::copySupNRPEPlugins($deployment, $torev, $results['supnrpeplugins']);
                 break;
             case 'nagiosplugins':
                 self::copyNagiosPlugins($deployment, $torev, $results['nagiosplugins']);
                 break;
             default:
                 break;
         }
     }
 }
示例#4
0
    $request = $app->request();
    $commonMerge = $request->get('common');
    // Load up Current Commands or Staged Commands
    if ($staged == 1) {
        $revs = RevDeploy::getDeploymentRevs($deployment);
        if ($revs['currrev'] == $revs['nextrev']) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect staged revision to reference");
            $app->halt(404, $apiResponse->returnJson());
        }
        $deployRev = $revs['nextrev'];
    } else {
        $deployRev = RevDeploy::getDeploymentRev($deployment);
    }
    $apiResponse = new APIViewData(0, $deployment, false);
    if ($commonMerge == 1) {
        $apiResponse->setExtraResponseData('commands', RevDeploy::getCommonMergedDeploymentCommands($deployment, $deployRev, false));
    } else {
        $apiResponse->setExtraResponseData('commands', RevDeploy::getDeploymentCommandswInfo($deployment, $deployRev));
    }
    $apiResponse->printJson();
})->name('saigon-api-get-commands');
$app->post('/sapi/command/:deployment', function ($deployment) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    $request = $app->request();
    $contentType = $request->headers('Content-Type');
    if ($contentType == 'application/json') {
        $commandInfo = $request->getBody();
        $commandInfo = json_decode($commandInfo, true);
        if (isset($commandInfo['command_line']) && !empty($commandInfo['command_line'])) {
            if (($b64dec = base64_decode($commandInfo['command_line'], true)) === false) {