/** * _getSupNRPECfg - get supplemental nrpe config file * * @param mixed $deployment * @param mixed $revision * * @static * @access private * @return void */ private static function _getSupNRPECfg($deployment, $revision) { $results = ""; if (RevDeploy::existsDeploymentSupNRPECfg($deployment, $revision) !== false) { $supnrpecfgInfo = RevDeploy::getDeploymentSupNRPECfg($deployment, $revision); $results = NRPECreate::buildSupNRPEFile($deployment, $revision, $supnrpecfgInfo); return $results; } return $results; }
if ($contentType == 'application/json') { $supNRPECfgInfo = $request->getBody(); $supNRPECfgInfo = json_decode($supNRPECfgInfo, true); } elseif (preg_match("/form-(data|urlencoded)/", $contentType)) { $supNRPECfgInfo['location'] = $request->post('location'); $supNRPECfgInfo['cmds'] = $request->post('cmds'); } // A bit of param validation if (!isset($supNRPECfgInfo['location']) || empty($supNRPECfgInfo['location'])) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect location parameter (unix path including filename)"); $app->halt(404, $apiResponse->returnJson()); } // Param manipulation depending on what is detected if (is_array($supNRPECfgInfo['cmds'])) { $supNRPECfgInfo['cmds'] = implode(',', $supNRPECfgInfo['cmds']); } check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (RevDeploy::existsDeploymentSupNRPECfg($deployment, $deployRev) === true) { RevDeploy::modifyDeploymentSupNRPECfg($deployment, $supNRPECfgInfo, $deployRev); $msg = "Successfully Modified NRPE Config"; } else { RevDeploy::createDeploymentSupNRPECfg($deployment, $supNRPECfgInfo, $deployRev); $msg = "Successfully Created NRPE Config"; } $supNRPECfgInfo = RevDeploy::getDeploymentNRPECfg($deployment, $deployRev); $fileContents = NRPECreate::buildSupNRPEFile($deployment, $deployRev, $supNRPECfgInfo); $apiResponse = new APIViewData(0, $deployment, $msg); $apiResponse->setExtraResponseData('md5', md5($fileContents)); $apiResponse->printJson(); })->name('saigon-api-create-sup-nrpe-cfg');
public function sup_import_stage() { $viewData = new ViewData(); $deployment = $this->getDeployment('sup_nrpe_cfg_error'); $modrevision = RevDeploy::getDeploymentNextRev($deployment); if (RevDeploy::existsDeploymentSupNRPECfg($deployment, $modrevision) !== false) { $viewData->error = "Supplemental NRPE Configuration file exists for Deployment: {$deployment}"; } $viewData->deployment = $deployment; $this->sendResponse('sup_nrpe_cfg_import_stage', $viewData); }