Beispiel #1
0
function check_revision_status($deployment)
{
    $currRev = RevDeploy::getDeploymentRev($deployment);
    $nextRev = RevDeploy::getDeploymentNextRev($deployment);
    if ($currRev == $nextRev) {
        $incrRev = RevDeploy::incrDeploymentNextRev($deployment);
        CopyDeploy::copyDeploymentRevision($deployment, $currRev, $incrRev);
    }
    return true;
}
Beispiel #2
0
    } else {
        $apiResponse->setExtraResponseData('contacts', RevDeploy::getDeploymentContactswInfo($deployment, $deployRev));
    }
    $apiResponse->printJson();
})->name('saigon-api-get-contacts');
$app->get('/sapi/contact/:deployment/:contact(/:staged)', function ($deployment, $contact, $staged = false) use($app) {
    check_deployment_exists($app, $deployment);
    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);
    }
    if (preg_match('/,/', $contact)) {
        $contacts = preg_split('/\\s?,\\s?/', $contact);
        $results = array();
        foreach ($contacts as $ctemp) {
            if (RevDeploy::existsDeploymentContact($deployment, $ctemp, $deployRev) === true) {
                $results[$ctemp] = RevDeploy::getDeploymentContact($deployment, $ctemp, $deployRev);
            }
        }
        if (empty($results)) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect contact s specified: {$contact}");
            $app->halt(404, $apiResponse->returnJson());
        } else {
            $apiResponse = new APIViewData(0, $deployment, false);
            $apiResponse->setExtraResponseData('contacts', $results);
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('host_template_error');
     $hostTemplate = $this->getParam('hosttemp');
     if ($hostTemplate === false) {
         $viewData->header = $this->getErrorHeader('host_template_error');
         $viewData->error = 'Unable to detect host template specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->hosttemplates = RevDeploy::getCommonMergedDeploymentHostTemplates($deployment, $modrevision);
     $viewData->hostchkcmds = RevDeploy::getCommonMergedDeploymentHostCheckCommands($deployment, $modrevision);
     $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
     $viewData->hostInfo = RevDeploy::getDeploymentHostTemplate($commonRepo, $hostTemplate, $commonrevision);
     $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
     $viewData->contactgroups = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->hosttemplate = $hostTemplate;
     $viewData->action = 'copy_write';
     $this->sendResponse('host_template_action_stage', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('svc_error');
     $svc = $this->getParam('svc');
     if ($svc === false) {
         $viewData->header = $this->getErrorHeader('svc_error');
         $viewData->error = 'Unable to detect service template specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $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->svcInfo = RevDeploy::getDeploymentSvc($commonRepo, $svc, $commonrevision);
     $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
     $viewData->contactgroups = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->action = 'copy_write';
     $this->sendResponse('svc_action_stage', $viewData);
 }
 public function manage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('ngnt_error');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $viewData->nodeInfo = RevDeploy::getDeploymentNodeTemplateswInfo($deployment, $modrevision);
     if ($deployment != 'common') {
         $crepo = RevDeploy::getDeploymentCommonRepo($deployment);
         $crev = RevDeploy::getDeploymentRev($crepo);
         $viewData->cstdTemplates = RevDeploy::getDeploymentNodeTemplateswInfo($crepo, $crev);
         $viewData->cdeployment = RevDeploy::getDeploymentCommonRepo($deployment);
     }
     $viewData->deployment = $deployment;
     $this->sendResponse('ngnt_manage', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('timeperiod_error');
     $timeName = $this->getParam('timeperiod');
     if ($timeName === false) {
         $viewData->header = $this->getErrorHeader('timeperiod_error');
         $viewData->error = 'Unable to detect timeperiod specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $timeInfo = RevDeploy::getDeploymentTimeperiodInfo($commonRepo, $timeName, $commonrevision);
     if (empty($timeInfo)) {
         $viewData->header = $this->getErrorHeader('timeperiod_error');
         $viewData->error = 'Unable to fetch timeperiod information for ' . $timeName . ' from data store';
         $this->sendError('generic_error', $viewData);
     }
     $timeData = RevDeploy::getDeploymentTimeperiodData($commonRepo, $timeName, $commonrevision);
     if (empty($timeData)) {
         $viewData->header = $this->getErrorHeader('timeperiod_error');
         $viewData->error = 'Unable to fetch timeperiod data for ' . $timeName . ' from data store';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->timeInfo = $timeInfo;
     unset($_SESSION[$deployment]['timeperiods']);
     $_SESSION[$deployment]['timeperiods'] = array();
     foreach ($timeData as $md5Key => $tpArray) {
         $_SESSION[$deployment]['timeperiods'][$md5Key] = $tpArray;
     }
     $viewData->action = 'copy_write';
     $this->sendResponse('timeperiod_action_stage', $viewData);
 }
 public function copy_common_stage_sup()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('sup_nrpe_plugin_error');
     $deployments = array();
     $viewData->deployment = $deployment;
     array_push($deployments, $deployment);
     $plugin = $this->getPlugin('sup_nrpe_plugin_error');
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $modrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->plugin = RevDeploy::getDeploymentSupNRPEPlugin($commonRepo, $plugin, $modrevision);
     $viewData->availdeployments = $deployments;
     $viewData->ccs = true;
     $viewData->action = 'copy_to_write_sup';
     $this->sendResponse('sup_nrpe_plugin_view_stage', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('nrpe_cmd_error');
     $viewData->deployment = $deployment;
     $nrpecmd = $this->getParam('cmdname');
     if ($nrpecmd === false) {
         $viewData->header = $this->getErrorHeader('nrpe_cmd_error');
         $viewData->error = 'Unable to detect command specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->command = $nrpecmd;
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $nrpecmdInfo = RevDeploy::getDeploymentNRPECmd($commonRepo, $nrpecmd, $commonrevision);
     if (empty($nrpecmdInfo)) {
         $viewData->header = $this->getErrorHeader('nrpe_cmd_error');
         $viewData->error = 'Unable to fetch command information for ' . $nrpecmd . ' from data store';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->nrpecmdInfo = $nrpecmdInfo;
     $viewData->action = 'copy_write';
     $this->sendResponse('nrpe_cmd_action_stage', $viewData);
 }
 /**
  * getCmdline 
  * 
  * @access public
  * @return void
  */
 public function getCmdline()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('command_error');
     $cmd = $this->getParam('cmdName');
     if ($cmd === false) {
         die;
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     if (RevDeploy::existsDeploymentCommand($deployment, $cmd, $modrevision) === true) {
         $viewData->cmdline = RevDeploy::getDeploymentCommandExec($deployment, $cmd, $modrevision);
     } else {
         $crepo = RevDeploy::getDeploymentCommonRepo($deployment);
         $crev = RevDeploy::getDeploymentRev($crepo);
         $viewData->cmdline = RevDeploy::getDeploymentCommandExec($crepo, $cmd, $crev);
     }
     $this->sendResponse('command_show_cmdline', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('host_group_error');
     $hostGrpName = $this->getParam('hostName');
     if ($hostGrpName === false) {
         $viewData->header = $this->getErrorHeader('host_group_error');
         $viewData->error = 'Unable to detect host specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->hostGrpInfo = RevDeploy::getDeploymentHostGroup($commonRepo, $hostGrpName, $commonrevision);
     $viewData->deployment = $deployment;
     $viewData->action = 'copy_write';
     $this->sendResponse('host_group_action_stage', $viewData);
 }
Beispiel #11
0
 /**
  * checkDeploymentRevStatus 
  * 
  * @param mixed $deployment deployment we are processing 
  *
  * @access public
  * @return void
  */
 public function checkDeploymentRevStatus($deployment)
 {
     $currRev = RevDeploy::getDeploymentRev($deployment);
     $nextRev = RevDeploy::getDeploymentNextRev($deployment);
     if ($currRev === false && $nextRev === false) {
         return;
     }
     if ($currRev == $nextRev) {
         $incrRev = RevDeploy::incrDeploymentNextRev($deployment);
         CopyDeploy::copyDeploymentRevision($deployment, $currRev, $incrRev);
     }
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_error');
     $contactName = $this->getParam('contactName');
     if ($contactName === false) {
         $viewData->header = $this->getErrorHeader('contact_error');
         $viewData->error = 'Unable to detect contact specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $contactInfo = RevDeploy::getDeploymentContact($commonRepo, $contactName, $commonrevision);
     $viewData->contactInfo = $contactInfo;
     $viewData->contacttemplates = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $modrevision);
     $viewData->notifycmds = RevDeploy::getCommonMergedDeploymentNotifyCommands($deployment, $modrevision);
     $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->action = 'copy_write';
     $this->sendResponse('contact_action_stage', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('svc_dep_error');
     $svcDepName = $this->getParam('svcDep');
     if ($svcDepName === false) {
         $viewData->header = $this->getErrorHeader('svc_dep_error');
         $viewData->error = 'Unable to detect service specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->svcDepInfo = RevDeploy::getDeploymentSvcDependency($commonRepo, $svcDepName, $commonrevision);
     $viewData->svcs = RevDeploy::getCommonMergedDeploymentSvcs($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->action = 'copy_write';
     $this->sendResponse('svc_dep_action_stage', $viewData);
 }
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_group_error');
     $cgName = $this->getParam('cgName');
     if ($cgName === false) {
         $viewData->header = $this->getErrorHeader('contact_group_error');
         $viewData->error = 'Unable to detect contact specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->contactInfo = RevDeploy::getDeploymentContactGroup($commonRepo, $cgName, $commonrevision);
     $viewData->contactgroups = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $modrevision);
     $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $viewData->action = 'copy_write';
     $this->sendResponse('contact_group_action_stage', $viewData);
 }
 /**
  * reset_ftr_rev - reset future revision to match current revision information 
  * 
  * @access public
  * @return void
  */
 public function reset_ftr_rev()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('deployment_error');
     $this->checkGroupAuth($deployment);
     $currrev = RevDeploy::getDeploymentRev($deployment);
     $nextrev = RevDeploy::getDeploymentNextRev($deployment);
     if ($currrev == $nextrev) {
         $viewData->header = $this->getErrorHeader('deployment_error');
         $viewData->error = 'Unable to process request, no new revision exists to reset';
         $this->sendError('generic_error', $viewData);
     }
     CopyDeploy::resetDeploymentRevision($deployment, $currrev, $nextrev);
     $viewData->deployment = $deployment;
     $viewData->currrev = $currrev;
     $viewData->nextrev = $nextrev;
     $this->sendResponse('deployment_rfr', $viewData);
 }