コード例 #1
0
 public function copy_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('host_group_error');
     $this->checkGroupAuth($deployment);
     $this->checkDeploymentRevStatus($deployment);
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $hostGrpName = $this->getParam('hostName');
     $hostGrpInfo = $this->fetchHostInfo($deployment, 'copy_write');
     if (RevDeploy::existsDeploymentHostGroup($deployment, $hostGrpName, $modrevision) === true) {
         $viewData->error = 'Host information exists for ' . $hostGrpName . ' in ' . $deployment . ' Deployment';
         $viewData->hostGrpInfo = $hostGrpInfo;
         $viewData->action = 'copy_write';
         $this->sendResponse('host_group_action_stage', $viewData);
     }
     if (RevDeploy::createDeploymentHostGroup($deployment, $hostGrpName, $hostGrpInfo, $modrevision) === false) {
         $viewData->header = $this->getErrorHeader('host_group_error');
         $viewData->error = 'Unable to write host information for ' . $hostGrpName . ' into ' . $deployment . ' Deployment';
         $this->sendError('generic_error', $viewData);
     }
     $viewData->deployment = $deployment;
     $viewData->host = $hostGrpName;
     $this->sendResponse('host_group_write', $viewData);
 }
コード例 #2
0
 private static function copyHostGroups($deployment, $revision, array $hgInfo)
 {
     if (self::$init === false) {
         self::init();
     }
     foreach ($hgInfo as $hg => $hgArray) {
         if ($hgArray['deployment'] == self::$m_commonrepo && $hgArray['deployment'] == 'common') {
             continue;
         }
         if ($hgArray['deployment'] == self::$m_commonrepo) {
             continue;
         }
         unset($hgArray['deployment']);
         RevDeploy::createDeploymentHostGroup($deployment, $hg, $hgArray, $revision);
     }
 }
コード例 #3
0
        $apiResponse = new APIViewData(1, $deployment, "Unable to use host groups name specified, detected forbidden characters " . implode('', array_unique($forbidden[0])));
        $app->halt(404, $apiResponse->returnJson());
    }
    if (!isset($hostGroupsInfo['alias']) || empty($hostGroupsInfo['alias'])) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to detect alias parameter (longer human readable information about host, one simple line)");
        $app->halt(404, $apiResponse->returnJson());
    } elseif (preg_match_all('/[^\\w.-\\s]/s', $hostGroupsInfo['alias'], $forbidden)) {
        $apiResponse = new APIViewData(1, $deployment, "Unable to use host groups alias specified, detected forbidden characters " . implode('', array_unique($forbidden[0])));
        $app->halt(404, $apiResponse->returnJson());
    }
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentHostGroup($deployment, $hostGroupsInfo['name'], $deployRev) === true) {
        RevDeploy::modifyDeploymentHostGroup($deployment, $hostGroupsInfo['name'], $hostGroupsInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Host Group " . $hostGroupsInfo['name']);
    } else {
        RevDeploy::createDeploymentHostGroup($deployment, $hostGroupsInfo['name'], $hostGroupsInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Created Host Group " . $hostGroupsInfo['name']);
    }
    $apiResponse->printJson();
})->name('saigon-api-create-host-groups');
$app->delete('/sapi/hostgroup/:deployment/:hostgroup', function ($deployment, $hostgroup) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (preg_match('/,/', $hostgroup)) {
        $hostgroups = preg_split('/\\s?,\\s?/', $hostgroup);
        foreach ($hostgroups as $hgtemp) {
            RevDeploy::deleteDeploymentHostGroup($deployment, $hgtemp, $deployRev);
        }
    } else {