Exemplo n.º 1
0
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect file parameter (expecting base64 encoded file contents if Content-Type is application/json)");
        $app->halt(404, $apiResponse->returnJson());
    } elseif (!isset($pluginInfo['desc']) || empty($pluginInfo['desc'])) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect desc parameter (plugin description)");
        $app->halt(404, $apiResponse->returnJson());
    } elseif (!isset($pluginInfo['location']) || empty($pluginInfo['location'])) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect location parameter (plugin location expecting unix path)");
        $app->halt(404, $apiResponse->returnJson());
    }
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentNagiosPlugin($deployment, $pluginInfo['name'], $deployRev) === true) {
        RevDeploy::modifyDeploymentNagiosPlugin($deployment, $pluginInfo['name'], $pluginInfo, $deployRev);
        $msg = "Successfully Modified Nagios Plugin: " . $pluginInfo['name'];
    } else {
        RevDeploy::createDeploymentNagiosPlugin($deployment, $pluginInfo['name'], $pluginInfo, $deployRev);
        $msg = "Successfully Created Nagios Plugin: " . $pluginInfo['name'];
    }
    $apiResponse = new APIViewData(0, $deployment, $msg);
    $apiResponse->setExtraResponseData('md5', $pluginInfo['md5']);
    $apiResponse->printJson();
})->name('saigon-api-create-nagios-plugin');
$app->get('/sapi/nagiosplugin/:deployment/:nagiosplugin(/:staged)', function ($deployment, $nagiosPlugin, $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());
        }
Exemplo n.º 2
0
 private static function copyNagiosPlugins($deployment, $revision, array $nagiosPlugins)
 {
     if (self::$init === false) {
         self::init();
     }
     foreach ($nagiosPlugins as $plugin => $pArray) {
         RevDeploy::createDeploymentNagiosPlugin($deployment, $plugin, $pArray, $revision);
     }
 }
 public function copy_to_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('nagios_plugin_error');
     $plugin = $this->getPlugin('nagios_plugin_error');
     $todeployment = $this->getParam('todeployment');
     if ($todeployment === false) {
         $viewData->header = $this->getErrorHeader('nagios_plugin_error');
         $viewData->error = 'Unable to detect deployment to copy command to';
         $this->sendResponse('generic_error', $viewData);
     }
     $this->checkGroupAuth($todeployment);
     $this->checkDeploymentRevStatus($todeployment);
     $tdRev = RevDeploy::getDeploymentNextRev($todeployment);
     $deployRev = RevDeploy::getDeploymentNextRev($deployment);
     $pluginInfo = RevDeploy::getDeploymentNagiosPlugin($deployment, $plugin, $deployRev);
     if (RevDeploy::existsDeploymentNagiosPlugin($todeployment, $plugin, $tdRev) === true) {
         RevDeploy::modifyDeploymentNagiosPlugin($todeployment, $plugin, $pluginInfo, $tdRev);
     } else {
         RevDeploy::createDeploymentNagiosPlugin($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('nagios_plugin_write', $viewData);
 }