public function copy_to_write_sup() { $viewData = new ViewData(); $deployment = $this->getDeployment('sup_nrpe_plugin_error'); $plugin = $this->getPlugin('sup_nrpe_plugin_error'); $todeployment = $this->getParam('todeployment'); if ($todeployment === false) { $viewData->header = $this->getErrorHeader('sup_nrpe_plugin_error'); $viewData->error = 'Unable to detect deployment to copy plugin to'; $this->sendResponse('generic_error', $viewData); } $this->checkGroupAuth($todeployment); $this->checkDeploymentRevStatus($todeployment); $tdRev = RevDeploy::getDeploymentNextRev($todeployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); $pluginInfo = RevDeploy::getDeploymentSupNRPEPlugin($deployment, $plugin, $deployRev); if (RevDeploy::existsDeploymentSupNRPEPlugin($todeployment, $plugin, $tdRev) === true) { RevDeploy::modifyDeploymentSupNRPEPlugin($todeployment, $plugin, $pluginInfo, $tdRev); } else { RevDeploy::createDeploymentSupNRPEPlugin($todeployment, $plugin, $pluginInfo, $tdRev); } $viewData->todeployment = $todeployment; $ccs = $this->getParam('ccs'); if ($ccs == 1) { $viewData->deployment = $todeployment; } else { $viewData->deployment = $deployment; } $viewData->plugin = $plugin; $this->sendResponse('sup_nrpe_plugin_write', $viewData); }
private static function copySupNRPEPlugins($deployment, $revision, $supnrpePlugins) { if (self::$init === false) { self::init(); } foreach ($supnrpePlugins as $plugin => $pArray) { RevDeploy::createDeploymentSupNRPEPlugin($deployment, $plugin, $pArray, $revision); } }
$pluginInfo['md5'] = md5($pluginInfo['file']); $pluginInfo['file'] = base64_encode($pluginInfo['file']); } else { $pluginInfo['md5'] = md5($data); } } if (isset($pluginInfo['location']) && !empty($pluginInfo['location'])) { $pluginInfo['location'] = base64_encode($pluginInfo['location']); } check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (RevDeploy::existsDeploymentSupNRPEPlugin($deployment, $pluginInfo['name'], $deployRev) === true) { RevDeploy::modifyDeploymentSupNRPEPlugin($deployment, $pluginInfo['name'], $pluginInfo, $deployRev); $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Supplemental NRPE Plugin: " . $pluginInfo['name']); } else { RevDeploy::createDeploymentSupNRPEPlugin($deployment, $pluginInfo['name'], $pluginInfo, $deployRev); $apiResponse = new APIViewData(0, $deployment, "Successfully Created Supplemental NRPE Plugin: " . $pluginInfo['name']); } $apiResponse->setExtraResponseData('md5', $pluginInfo['md5']); $apiResponse->printJson(); })->name('saigon-api-create-supplemental-nrpe-plugin'); $app->get('/sapi/supnrpeplugin/:deployment/:supnrpeplugin(/:staged)', function ($deployment, $supNRPEPlugin, $staged = false) use($app) { check_deployment_exists($app, $deployment); // Load up Current Plugins or Staged Plugins 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'];