foreach ($plugins as $plugin) { $pluginData = RevDeploy::getDeploymentNRPEPlugin($deployment, $plugin, $deployRev); if ($pluginData !== false) { $results[$plugin] = $pluginData; } } if (!empty($results)) { $apiResponse = new APIViewData(0, $deployment, false); $apiResponse->setExtraResponseData('plugins', $results); $apiResponse->printJson(); } else { $apiResponse = new APIViewData(1, $deployment, "Unable to detect nrpe plugin(s) specified: {$nrpePlugin}"); $app->halt(404, $apiResponse->returnJson()); } } else { $pluginData = RevDeploy::getDeploymentNRPEPlugin($deployment, $nrpePlugin, $deployRev); if ($pluginData !== false) { $apiResponse = new APIViewData(0, $deployment, false); $apiResponse->setExtraResponseData('plugin', $pluginData); $apiResponse->printJson(); } else { $apiResponse = new APIViewData(1, $deployment, "Unable to detect nrpe plugin specified: {$nrpePlugin}"); $app->halt(404, $apiResponse->returnJson()); } } })->name('saigon-api-get-nrpe-plugin'); $app->delete('/sapi/nrpeplugin/:deployment/:nrpeplugin', function ($deployment, $nrpePlugin) use($app) { check_deployment_exists($app, $deployment); check_auth($app, $deployment); check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment);
public function copy_to_write() { $viewData = new ViewData(); $deployment = $this->getDeployment('nrpe_plugin_error'); $plugin = $this->getPlugin('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::getDeploymentNRPEPlugin($deployment, $plugin, $deployRev); if (RevDeploy::existsDeploymentNRPEPlugin($todeployment, $plugin, $tdRev) === true) { RevDeploy::modifyDeploymentNRPEPlugin($todeployment, $plugin, $pluginInfo, $tdRev); } else { RevDeploy::createDeploymentNRPEPlugin($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('nrpe_plugin_write', $viewData); }