public function modify_write() { $viewData = new ViewData(); $deployment = $this->getDeployment('ngnt_error'); $this->checkGroupAuth($deployment); $this->checkDeploymentRevStatus($deployment); $modrevision = RevDeploy::getDeploymentNextRev($deployment); $ngntInfo = $this->fetchNGNTInfo($deployment, 'modify_write', $modrevision); if (RevDeploy::modifyDeploymentNodeTemplate($deployment, $ngntInfo['name'], $ngntInfo, $modrevision) === false) { $viewData->header = $this->getErrorHeader('ngnt_error'); $viewData->error = 'Unable to write node template information for ' . $ngntInfo['name'] . ' to ' . $deployment; $this->sendError('generic_error', $viewData); } $viewData->nodeTemp = $ngntInfo['name']; $viewData->deployment = $deployment; $this->sendResponse('ngnt_write', $viewData); }
unset($templateInfo['hostgroup']); } if (!isset($templateInfo['nregex']) || empty($templateInfo['nregex'])) { unset($templateInfo['nregex']); } if (!isset($templateInfo['subdeployment']) || empty($templateInfo['subdeployment'])) { unset($templateInfo['subdeployment']); } check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (RevDeploy::existsDeploymentNodeTemplate($deployment, $templateInfo['name'], $deployRev) === true) { if (RevDeploy::checkDeploymentNodeTemplateType($deployment, $templateInfo['name'], $deployRev, $templateInfo['type']) === false) { $apiResponse = new APIViewData(1, $deployment, "Template type specified doesn't match template type stored in data store"); $app->halt(404, $apiResponse->returnJson()); } RevDeploy::modifyDeploymentNodeTemplate($deployment, $templateInfo['name'], $templateInfo, $deployRev); $msg = "Successfully Modified Dynamic Template: " . $templateInfo['name']; } else { RevDeploy::createDeploymentNodeTemplate($deployment, $templateInfo['name'], $templateInfo, $deployRev); $msg = "Successfully Created Dynamic Template: " . $templateInfo['name']; } $apiResponse = new APIViewData(0, $deployment, $msg); $apiResponse->printJson(); })->name('saigon-api-create-dynamic-template'); $app->delete('/sapi/matrix/:deployment/dynamic/:template', function ($deployment, $template) use($app) { check_deployment_exists($app, $deployment); check_auth($app, $deployment); check_revision_status($deployment); $deployRev = RevDeploy::getDeploymentNextRev($deployment); if (preg_match('/,/', $template)) { $results = array();