} unset($plugindata['deployment']); unset($plugindata['desc']); $results[$plugins] = $plugindata; echo json_encode($results); return; } })->via('GET', 'POST'); $app->map('/api/getRouterVM/:zone', function ($zone) use($app) { $zone = strtoupper($zone); if (CDC_DS::isRouterZone($zone) === false) { $apiResponse = new APIViewData(1, false, "Unable to detect router vm zone specified: {$zone}"); $apiResponse->setExtraResponseData('zone', $zone); $app->halt(403, $apiResponse->returnJson()); } $results = CDC_DS::getRouterInfo($zone); echo $results; return; })->via('GET', 'POST'); $app->map('/api/getNagiosPlugin/:deployment/:plugins', function ($deployment, $plugins) use($app) { check_deployment_exists($app, $deployment); $deployrev = RevDeploy::getDeploymentRev($deployment); if (preg_match('/,/', $plugins)) { $tmpplugins = preg_split('/,\\s?/', $plugins); $results = array(); foreach ($tmpplugins as $plugin) { $plugindata = RevDeploy::getDeploymentNagiosPlugin($deployment, $plugin, $deployrev); if (empty($plugindata)) { $commonrev = RevDeploy::getDeploymentRev('common'); $plugindata = RevDeploy::getDeploymentNagiosPlugin('common', $plugin, $commonrev); if (empty($plugindata)) {
return; } $apiResponse = new APIViewData(1, $deployment, "Unable to detect modgearman config file for deployment: {$deployment}"); $app->halt(403, $apiResponse->returnJson()); })->name('saigon-api-consumer-modgearman-config'); /* * Cloud.com RouterVM Routine */ $app->get('/sapi/consumer/routervms/:zone', function ($zone) use($app) { $zone = strtoupper($zone); if (CDC_DS::isRouterZone($zone) === false) { $apiResponse = new APIViewData(1, false, "Unable to detect router vm zone specified: {$zone}"); $apiResponse->setExtraResponseData('zone', $zone); $app->halt(403, $apiResponse->returnJson()); } $results = json_decode(CDC_DS::getRouterInfo($zone), true); $apiResponse = new APIViewData(0, $zone, false); $apiResponse->setExtraResponseData('routervms', $results); $apiResponse->printJson(); })->name('saigon-api-consumer-routervms'); /* * Saigon Host Audit Consumer Output */ $app->get('/sapi/consumer/hostaudit/:deployment', function ($deployment) use($app) { check_deployment_exists($app, $deployment); $hostAuditInfo = array(); $hostAuditInfo = NagTester::getDeploymentHostAuditInfo($deployment); if (empty($hostAuditInfo)) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect Saigon Host Audit Results"); $app->halt(403, $apiResponse->returnJson()); }