예제 #1
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;
         }
     }
 }
 public function copy_to_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_error');
     $contactName = $this->getParam('contactName');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $contactInfo = $this->fetchContactInfo($deployment, 'copy_to_write', $modrevision);
     $todeployment = $this->getParam('todeployment');
     if ($todeployment === false) {
         $viewData->error = 'Unable to detect contact to copy contact to';
         $viewData->availdeployments = $this->getDeploymentsAvailToUser();
         $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_to_write';
         $this->sendResponse('contact_action_stage', $viewData);
     }
     $this->checkGroupAuth($todeployment);
     $this->checkDeploymentRevStatus($todeployment);
     $tdRev = RevDeploy::getDeploymentNextRev($todeployment);
     if (RevDeploy::existsDeploymentContact($todeployment, $contactName, $tdRev) === true) {
         RevDeploy::modifyDeploymentContact($todeployment, $contactName, $contactInfo, $tdRev);
     } else {
         RevDeploy::createDeploymentContact($todeployment, $contactName, $contactInfo, $tdRev);
     }
     $viewData->deployment = $deployment;
     $viewData->todeployment = $todeployment;
     $viewData->contact = $contactName;
     $this->sendResponse('contact_write', $viewData);
 }
예제 #3
0
    check_deployment_exists($app, $deployment);
    $request = $app->request();
    $commonMerge = $request->get('common');
    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('contact_templates', RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $deployRev));
    } else {
        $apiResponse->setExtraResponseData('contact_templates', RevDeploy::getDeploymentContactTemplateswInfo($deployment, $deployRev));
    }
    $apiResponse->printJson();
})->name('saigon-api-get-contact-templates');
$app->get('/sapi/contacttemplate/:deployment/:contacttemplate(/:staged)', function ($deployment, $contacttemplate, $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 {
 public function copy_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_template_error');
     $this->checkGroupAuth($deployment);
     $this->checkDeploymentRevStatus($deployment);
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $contactName = $this->getParam('contactName');
     $contactInfo = $this->fetchContactTemplateInfo($deployment, 'copy_write', $modrevision);
     if (RevDeploy::existsDeploymentContactTemplate($deployment, $contactName, $modrevision) === true) {
         $viewData->error = 'Contact template information exists for ' . $contactName . ' into ' . $deployment . ' Deployment';
         $viewData->action = 'copy_write';
         $viewData->contacttemplate = $contactName;
         $viewData->deployment = $deployment;
         $viewData->contacttemplates = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $modrevision);
         $viewData->notifycmds = RevDeploy::getCommonMergedDeploymentNotifyCommands($deployment, $modrevision);
         $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
         $viewData->contactInfo = $contactInfo;
         $this->sendResponse('contact_template_action_stage', $viewData);
     }
     if (RevDeploy::createDeploymentContactTemplate($deployment, $contactName, $contactInfo, $modrevision) === false) {
         $viewData->header = $this->getErrorHeader('contact_template_error');
         $viewData->error = 'Unable to write contact tempalte information for ' . $contactName . ' into ' . $deployment . ' Deployment';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->deployment = $deployment;
     $viewData->contact = $contactName;
     $this->sendResponse('contact_template_write', $viewData);
 }