/** * view_dynamic_matches - view dynamic matches for global negate regex * * @access public * @return void */ public function view_dynamic_matches() { $viewData = new ViewData(); $deployment = $this->getDeployment('deployment_error'); $nregex = $this->getParam('nregex'); if ($nregex === false) { $viewData->header = $this->getErrorHeader('ngnt_error'); $viewData->error = 'Unable to detect negate regex specified in post params'; $this->sendResponse('generic_error', $viewData); } $hosts = RevDeploy::getDeploymentHosts($deployment); $resulthosts = array(); foreach ($hosts as $host => $hArray) { if (preg_match("/{$nregex}/", $host)) { array_push($resulthosts, $host); } } sort($resulthosts); $viewData = $resulthosts; $this->sendResponse('deployment_view_dynamic_matches', $viewData); }
public function view_dynamic_matches() { $viewData = new ViewData(); $deployment = $this->getDeployment('ngnt_error'); $regex = $this->getParam('regex'); if ($regex === false) { $viewData->header = $this->getErrorHeader('ngnt_error'); $viewData->error = 'Unable to detect regex specified in post params'; $this->sendError('generic_error', $viewData); } $nregex = $this->getParam('nregex'); $modrevision = RevDeploy::getDeploymentNextRev($deployment); $hosts = RevDeploy::getDeploymentHosts($deployment); $globalnegate = RevDeploy::getDeploymentGlobalNegate($deployment); $resulthosts = array(); foreach ($hosts as $host => $hArray) { if ($globalnegate !== false && preg_match("/{$globalnegate}/", $host)) { continue; } if (preg_match("/{$regex}/", $host)) { if ($nregex !== false) { if (!preg_match("/{$nregex}/", $host)) { array_push($resulthosts, $host); } } else { array_push($resulthosts, $host); } } } sort($resulthosts); $viewData = $resulthosts; $this->sendResponse('ngnt_view_dynamic_matches', $viewData); }
// // Copyright (c) 2013, Zynga Inc. // https://github.com/zynga/saigon // Author: Matt West (https://github.com/mhwest13) // License: BSD 2-Clause // /* * Saigon API - Matrix Node Mapper Routes */ $app->get('/sapi/matrix/:deployment/gethosts', function ($deployment) use($app) { check_deployment_exists($app, $deployment); $request = $app->request(); $regex = $request->get('regex'); $nregex = $request->get('nregex'); $hosts = RevDeploy::getDeploymentHosts($deployment); if (empty($hosts)) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect or retrieve hosts, empty results set detected"); $app->halt(404, $apiResponse->returnJson()); } $globalnegate = RevDeploy::getDeploymentGlobalNegate($deployment); $resulthosts = array(); if (isset($regex) && !empty($regex)) { foreach ($hosts as $host => $hArray) { if ($globalnegate !== false && preg_match("/{$globalnegate}/", $host)) { continue; } if (preg_match("/{$regex}/", $host)) { if (isset($nregex) && !empty($nregex)) { if (!preg_match("/{$nregex}/", $host)) { array_push($resulthosts, $host);