public function import_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('nrpe_cfg_error');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     if (RevDeploy::existsDeploymentNRPECfg($deployment, $modrevision) !== false) {
         $viewData->error = "NRPE Configuration file exists for Deployment: {$deployment}";
     }
     $viewData->deployment = $deployment;
     $this->sendResponse('nrpe_cfg_import_stage', $viewData);
 }
Exemplo n.º 2
0
 /**
  * _getNRPECfg - get core nrpe config file 
  * 
  * @param mixed $deployment deployment we are referencing
  * @param mixed $revision   revision we are referencing
  *
  * @static
  * @access private
  * @return void
  */
 private static function _getNRPECfg($deployment, $revision)
 {
     $results = "";
     if (RevDeploy::existsDeploymentNRPECfg($deployment, $revision) !== false) {
         $nrpecfgInfo = RevDeploy::getDeploymentNRPECfg($deployment, $revision);
         $results = NRPECreate::buildNRPEFile($deployment, $revision, $nrpecfgInfo);
         return $results;
     }
     return $results;
 }
Exemplo n.º 3
0
        $app->halt(404, $apiResponse->returnJson());
    } elseif (!isset($nrpeCfgInfo['allowed_hosts']) || empty($nrpeCfgInfo['allowed_hosts'])) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect allowed_hosts parameter (hosts allowed to connect to service)");
        $app->halt(404, $apiResponse->returnJson());
    } elseif (!isset($nrpeCfgInfo['cmds']) || empty($nrpeCfgInfo['cmds'])) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect cmds parameter (commands to activate in nrpe config)");
        $app->halt(404, $apiResponse->returnJson());
    }
    // Param manipulation depending on what is detected
    if (is_array($nrpeCfgInfo['cmds'])) {
        $nrpeCfgInfo['cmds'] = implode(',', $nrpeCfgInfo['cmds']);
    }
    if (!isset($nrpeCfgInfo['include_dir']) || empty($nrpeCfgInfo['include_dir'])) {
        unset($nrpeCfgInfo['include_dir']);
    }
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentNRPECfg($deployment, $deployRev) === true) {
        RevDeploy::modifyDeploymentNRPECfg($deployment, $nrpeCfgInfo, $deployRev);
        $msg = "Successfully Modified NRPE Config";
    } else {
        RevDeploy::createDeploymentNRPECfg($deployment, $nrpeCfgInfo, $deployRev);
        $msg = "Successfully Created NRPE Config";
    }
    unset($nrpeCfgInfo);
    $nrpeCfgInfo = RevDeploy::getDeploymentNRPECfg($deployment, $deployRev);
    $fileContents = NRPECreate::buildNRPEFile($deployment, $deployRev, $nrpeCfgInfo);
    $apiResponse = new APIViewData(0, $deployment, $msg);
    $apiResponse->setExtraResponseData('md5', md5($fileContents));
    $apiResponse->printJson();
})->name('saigon-api-create-nrpe-cfg');