예제 #1
0
파일: drush.php 프로젝트: nataliejeremy/cli
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         throw new TerminusException("Command could not be completed. Unknown site specified.");
     }
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "******";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $this->send_command($server, 'drush', $args, $assoc_args);
 }
예제 #2
0
 /**
  * List an organization's sites
  *
  * ## OPTIONS
  *
  * [--org=<id>]
  * : Organization id
  *
  * [--tag=<tag>]
  * : Tag name to filter sites list by
  *
  * [--add=<site>]
  * : Site to add to organization
  *
  * [--remove=<site>]
  * : Site to remove from organization
  *
  * @subcommand sites
  *
  */
 public function sites($args, $assoc_args)
 {
     $org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
     $org = new Organization($org_id);
     if (isset($assoc_args['add'])) {
         $add = SiteFactory::instance(Input::sitename($assoc_args, 'add'));
         Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
         $org->addSite($add);
         Terminus::success("Added site!");
         return true;
     }
     if (isset($assoc_args['remove'])) {
         $remove = SiteFactory::instance(Input::sitename($assoc_args, 'remove'));
         Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
         $org->removeSite($remove);
         Terminus::success("Removed site!");
         return true;
     }
     $org->siteMemberships->fetch();
     $memberships = $org->siteMemberships->all();
     foreach ($memberships as $membership) {
         if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $membership->get('tags'))) {
             continue;
         }
         $site = $membership->get('site');
         $data[] = array('name' => $site->name, 'id' => $site->id, 'service_level' => $site->service_level, 'framework' => $site->framework, 'created' => date('Y-m-d H:i:s', $site->created), 'tags' => $membership->get('tags'));
     }
     $this->handleDisplay($data);
 }
예제 #3
0
파일: wp.php 프로젝트: nataliejeremy/cli
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         throw new TerminusException("Command could not be completed. Unknown site specified.");
     }
     # see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "******";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info("Running wp {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $this->send_command($server, 'wp', $args, $assoc_args);
 }
예제 #4
0
파일: WpCommand.php 프로젝트: Zacker/cli
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     /**
      * See https://github.com/pantheon-systems/titan-mt/blob/master/..
      *  ..dashboardng/app/workshops/site/models/environment.coffee
      */
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     // Sanitize assoc args so we don't try to pass our own flags.
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     // Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info('Running wp {cmd} {flags} on {site}-{env}', array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'wp', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
예제 #5
0
 /**
  * Show operation details for a workflow
  *
  * ## OPTIONS
  * [--workflow_id]
  * : Uuid of workflow to show
  * [--site=<site>]
  * : Site from which to list workflows
  *
  * @subcommand show
  */
 public function show($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $workflow = Input::workflow($site, $assoc_args, 'workflow_id');
     $workflow_data = $workflow->serialize();
     if (Terminus::getConfig('format') == 'normal') {
         $operations_data = $workflow_data['operations'];
         unset($workflow_data['operations']);
         $this->output()->outputRecord($workflow_data);
         if (count($operations_data)) {
             $this->log()->info('Workflow operations:');
             $this->output()->outputRecordList($operations_data);
         } else {
             $this->log()->info('Workflow has no operations');
         }
     } else {
         $this->output()->outputRecordList($workflow_data);
     }
 }
예제 #6
0
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI command you intend to run with its arguments, in quotes
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     /**
      * See https://github.com/pantheon-systems/titan-mt/blob/master/..
      *  ..dashboardng/app/workshops/site/models/environment.coffee
      */
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     $this->log()->info('Running wp {cmd} on {site}-{env}', array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'wp', 'command' => $command));
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
예제 #7
0
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI command you intend to run, with its arguments
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $assoc_args['site'] = Input::sitename($assoc_args);
     $site = $sites->get($assoc_args['site']);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $assoc_args['env'] = $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} on {site}-{env}", array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'drush', 'command' => $command));
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
예제 #8
0
파일: workflows.php 프로젝트: RobLoach/cli
 /**
  * List Worflows for a Site
  *
  * ## OPTIONS
  * [--site=<site>]
  * : Site from which to list workflows
  *
  * @subcommand list
  */
 public function index($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $workflows = $site->workflows->all();
     $data = array();
     foreach ($workflows as $workflow) {
         $user = '******';
         if (isset($workflow->get('user')->email)) {
             $user = $workflow->get('user')->email;
         }
         if ($workflow->get('total_time')) {
             $elapsed_time = $workflow->get('total_time');
         } else {
             $elapsed_time = time() - $workflow->get('created_at');
         }
         $data[] = array('id' => $workflow->id, 'env' => $workflow->get('environment'), 'workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'time' => sprintf("%ds", $elapsed_time));
     }
     if (count($data) == 0) {
         $this->log()->warning('No workflows have been run on {site}', array('site' => $site->get('name')));
     }
     $this->output()->outputRecordList($data, array('update' => 'Last update'));
 }
예제 #9
0
 /**
  * List an organization's sites
  *
  * ## OPTIONS
  *
  * [--org=<id|name>]
  * : Organization UUID or name
  *
  * [--tag=<tag>]
  * : Tag name to filter sites list by
  *
  * [--add=<site>]
  * : Site to add to organization
  *
  * [--remove=<site>]
  * : Site to remove from organization
  *
  * @subcommand sites
  *
  */
 public function sites($args, $assoc_args)
 {
     $org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
     $orgs = new UserOrganizationMemberships();
     $org = $orgs->get($org_id);
     $memberships = $org->site_memberships;
     if (isset($assoc_args['add'])) {
         $site = $this->sites->get(Input::sitename($assoc_args, 'add'));
         Terminus::confirm('Are you sure you want to add %s to %s ?', $assoc_args, array($site->get('name'), $org->get('name')));
         $memberships->addMember($site);
         Terminus::success('Added site!');
         return true;
     }
     if (isset($assoc_args['remove'])) {
         $site_id = $assoc_args['remove'];
         $member = $memberships->get($assoc_args['remove']);
         $site = $member->get('site');
         Terminus::confirm('Are you sure you want to remove %s from %s ?', $assoc_args, array($site->name, $org->get('name')));
         $member->removeMember();
         Terminus::success('Removed site!');
         return true;
     }
     $memberships = $org->getSites();
     foreach ($memberships as $membership) {
         if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $membership->get('tags'))) {
             continue;
         }
         $site = $membership->get('site');
         $data_array = array('name' => null, 'id' => null, 'service_level' => null, 'framework' => null, 'created' => null, 'tags' => $membership->get('tags'));
         foreach ($data_array as $key => $value) {
             if ($value == null && isset($site->{$key})) {
                 $data_array[$key] = $site->{$key};
             }
         }
         $data_array['created'] = date('Y-m-dTH:i:s', $data_array['created']);
         $data[] = $data_array;
     }
     $this->outputter->outputRecordList($data);
 }
예제 #10
0
파일: drush.php 프로젝트: RobLoach/cli
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $assoc_args['site'] = Input::sitename($assoc_args);
     $site = $sites->get($assoc_args['site']);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $assoc_args['env'] = $environment = Input::env($assoc_args);
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     if (isset($assoc_args['site'])) {
         unset($assoc_args['site']);
     }
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'drush', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
예제 #11
0
 /**
  * List an organizations sites
  *
  * ## OPTIONS
  *
  * [--org=<org>]
  * : Organization name or Id
  *
  * [--tag=<tag>]
  * : Tag name to filter sites list by
  *
  * [--add=<site>]
  * : Site to add to organization
  *
  * [--remove=<site>]
  * : Site to remove from organization
  *
  * @subcommand sites
  *
  */
 public function sites($args, $assoc_args)
 {
     $orgs = array();
     $user = new User();
     foreach ($user->organizations() as $id => $org) {
         $orgs[$id] = $org->name;
     }
     if (!isset($assoc_args['org']) or empty($assoc_args['org'])) {
         $selected_org = Terminus::menu($orgs, false, "Choose an organization");
     } else {
         $selected_org = $assoc_args['org'];
     }
     $org = new Organization($selected_org);
     if (isset($assoc_args['add'])) {
         $add = SiteFactory::instance(Input::sitename($assoc_args, 'add'));
         Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
         $org->addSite($add);
         Terminus::success("Added site!");
         return true;
     }
     if (isset($assoc_args['remove'])) {
         $remove = SiteFactory::instance(Input::sitename($assoc_args, 'remove'));
         Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
         $org->removeSite($remove);
         Terminus::success("Removed site!");
         return true;
     }
     $sites = $org->getSites();
     $data = array();
     foreach ($sites as $site) {
         if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $site->tags)) {
             continue;
         }
         $data[] = array('name' => $site->site->name, 'id' => $site->site->id, 'service_level' => isset($site->site->service_level) ? $site->site->service_level : '', 'framework' => isset($site->site->framework) ? $site->site->framework : '', 'created' => date('Y-m-d H:i:s', $site->site->created), 'tags' => $site->tags);
     }
     $this->handleDisplay($data);
 }
예제 #12
0
 /**
  * Show quicksilver logs from a workflow
  *
  * ## OPTIONS
  * [--latest]
  * : Display the most-recent workflow with logs
  * [--workflow_id]
  * : Uuid of workflow to fetch logs for
  * [--site=<site>]
  * : Site from which to list workflows
  *
  * @subcommand logs
  */
 public function logs($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     if (isset($assoc_args['latest'])) {
         $site->workflows->fetchWithOperationsAndLogs(array('paged' => false));
         $workflow = $site->workflows->findLatestWithLogs();
         if (is_null($workflow)) {
             return $this->failure('No recent workflows contain logs');
         }
     } else {
         $site->workflows->fetchWithOperations(array('paged' => false));
         $workflows = $site->workflows->all();
         $workflow = Input::workflow($workflows, $assoc_args, 'workflow_id');
         $workflow->fetchWithLogs();
     }
     if (Terminus::getConfig('format') == 'normal') {
         $operations = $workflow->operations();
         if (count($operations) == 0) {
             $this->log()->info('Workflow has no operations');
             return;
         }
         $operations_with_logs = array_filter($operations, function ($operation) {
             return $operation->get('log_output');
         });
         if (count($operations_with_logs) == 0) {
             $this->log()->info('Workflow has no operations with logs');
             return;
         }
         foreach ($operations as $operation) {
             if ($operation->get('log_output')) {
                 $operation_data = $operation->serialize();
                 $this->output()->outputRecord($operation_data);
             }
         }
     } else {
         $workflow_data = $workflow->serialize();
         $operations_data = $workflow_data['operations'];
         $this->output()->outputRecordList($operations_data);
     }
 }
예제 #13
0
파일: site.php 프로젝트: aaronbauman/cli
 /**
  * List a site's workflows
  *
  * ## OPTIONS
  * [--site=<site>]
  * : Site to check
  *
  * @subcommand workflows
  */
 public function workflows($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $workflows = $site->workflows->all();
     $data = array();
     foreach ($workflows as $workflow) {
         $user = '******';
         if (isset($workflow->get('user')->email)) {
             $user = $workflow->get('user')->email;
         }
         $data[] = array('workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'update' => date('Y-m-dTH:i:s', $workflow->get('created_at') + $workflow->get('total_time')), 'tasks' => $workflow->get('number_of_tasks'), 'complete' => $workflow->get('step'));
     }
     if (count($data) == 0) {
         $this->log()->warning('No workflows have been run on {site}', array('site' => $site->getName()));
     }
     $this->output()->outputRecordList($data, array('update' => 'Last update'));
 }
예제 #14
0
파일: site.php 프로젝트: skyywalk3rr/cli
 /**
  * List a site's workflows
  *
  * ## OPTIONS
  * [--site=<site>]
  * : Site to check
  *
  * @subcommand workflows
  */
 public function workflows($args, $assoc_args)
 {
     $site = SiteFactory::instance(Input::sitename($assoc_args));
     $workflows = $site->getWorkflows();
     $data = array();
     foreach ($workflows as $workflow) {
         $user = '******';
         if (isset($workflow->get('user')->email)) {
             $user = $workflow->get('user')->email;
         }
         $data[] = array('workflow' => $workflow->get('description'), 'user' => $user, 'status' => $workflow->get('phase'), 'last_update' => date('Y-m-dTH:i:s', $workflow->get('created_at') + $workflow->get('total_time')), 'tasks/complete' => $workflow->get('step') . '/' . $workflow->get('number_of_tasks'));
     }
     if (count($data) > 0) {
         $this->constructTableForResponse($data);
     } else {
         Terminus::error('No workflows have been run on ' . $site->getName());
     }
 }
예제 #15
0
파일: SiteCommand.php 프로젝트: Zacker/cli
 /**
  * Loads a single backup
  *
  * @params [array] $assoc_args Parameters and flags from the command line
  * @return [boolean] Always true, else the function has thrown an exception
  */
 private function loadBackup($assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $env = $site->environments->get(Input::env(array('args' => $assoc_args, 'site' => $site)));
     $assoc_args['to'] = '/tmp';
     $assoc_args['element'] = 'database';
     if (isset($assoc_args['database'])) {
         $database = $assoc_args['database'];
     } else {
         $database = escapeshellarg(Terminus::prompt('Name of database to import to'));
     }
     if (isset($assoc_args['username'])) {
         $username = $assoc_args['username'];
     } else {
         $username = escapeshellarg(Terminus::prompt('Username'));
     }
     if (isset($assoc_args['password'])) {
         $password = $assoc_args['password'];
     } else {
         $password = escapeshellarg(Terminus::prompt('Password'));
     }
     exec('mysql -e "show databases"', $stdout, $exit);
     if ($exit != 0) {
         $this->failure('MySQL does not appear to be installed on your server.');
     }
     $assoc_args['env'] = $env->get('id');
     $target = $this->backup(array('get'), $assoc_args);
     $target = '/tmp/' . Utils\getFilenameFromUrl($target);
     if (!file_exists($target)) {
         $this->failure('Cannot read database file {target}', compact('target'));
     }
     $this->log()->info('Unziping database');
     exec("gunzip {$target}", $stdout, $exit);
     // trim the gz of the target
     $target = Utils\sqlFromZip($target);
     $target = escapeshellarg($target);
     exec(sprintf('mysql %s -u %s -p"%s" < %s', $database, $username, $password, $target), $stdout, $exit);
     if ($exit != 0) {
         $this->failure('Could not import database');
     }
     $this->log()->info('{target} successfully imported to {db}', array('target' => $target, 'db' => $database));
     return true;
 }
예제 #16
0
파일: site.php 프로젝트: reynoldsalec/cli
 /**
  * Delete a site from pantheon
  *
  * ## OPTIONS
  * [--site=<site>]
  * : ID of the site you want to delete
  *
  * [--force]
  * : to skip the confirmations
  */
 function delete($args, $assoc_args)
 {
     $sitename = Input::sitename($assoc_args);
     $site_id = $this->sitesCache->findID($sitename);
     $site_to_delete = new Site($site_id);
     if (!isset($assoc_args['force']) and !Terminus::get_config('yes')) {
         // if the force option isn't used we'll ask you some annoying questions
         Terminus::confirm(sprintf("Are you sure you want to delete %s?", $site_to_delete->information->name));
         Terminus::confirm("Are you really sure?");
     }
     Terminus::line(sprintf("Deleting %s ...", $site_to_delete->information->name));
     $response = \Terminus_Command::request('sites', $site_to_delete->id, '', 'DELETE');
     $this->sitesCache->remove($sitename);
     Terminus::success("Deleted %s!", $sitename);
 }
예제 #17
0
파일: site.php 프로젝트: RobLoach/cli
 /**
  * Complete wipe and reset a site
  *
  * ## OPTIONS
  *
  * [--site=<site>]
  * : Site to use
  *
  * [--env=<env>]
  * : Environment to be wiped
  */
 public function wipe($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $env = $site->environments->get(Input::env($assoc_args, 'env'));
     Terminus::confirm('Are you sure you want to wipe {site}-{env}?', array('site' => $site->get('name'), 'env' => $env->get('id')));
     $workflow = $env->wipe();
     $workflow->wait();
     $this->log()->info('Successfully wiped {site}-{env}', array('site' => $site->get('name'), 'env' => $env->get('id')));
 }
예제 #18
0
 /**
  * Displays an environment's regular backup schedule
  *
  * @params [array] $assoc_args Parameters and flags from the command line
  * @return [void]
  */
 private function showBackupSchedule($assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     $env = $site->environments->get(Input::env(array('args' => $assoc_args, 'choices' => array('dev', 'live'))));
     $schedule = $env->backups->getBackupSchedule();
     if (is_null($schedule['daily_backup_hour'])) {
         $this->log()->info('Backups are not currently scheduled to be run.');
     } else {
         $this->output()->outputRecord($schedule);
     }
 }
예제 #19
0
 /**
  * Streams new and finished workflows to the console
  *
  * ## OPTIONS
  * [--site=<site>]
  * : Site from which to list workflows
  *
  * @subcommand watch
  */
 public function watch($args, $assoc_args)
 {
     $site = $this->sites->get(Input::sitename($assoc_args));
     // Keep track of workflows that have been printed.
     // This is necessary because the local clock may drift from
     // the server's clock, causing events to be printed twice.
     $started = array();
     $finished = array();
     $this->logger->info('Watching workflows...');
     $site->workflows->fetchWithOperations();
     while (true) {
         $last_created_at = $site->workflows->lastCreatedAt();
         $last_finished_at = $site->workflows->lastFinishedAt();
         sleep(WORKFLOWS_WATCH_INTERVAL);
         $site->workflows->fetchWithOperations();
         $workflows = $site->workflows->all();
         foreach ($workflows as $workflow) {
             if ($workflow->get('created_at') > $last_created_at && !in_array($workflow->id, $started)) {
                 array_push($started, $workflow->id);
                 $started_message = sprintf("Started %s %s (%s)", $workflow->id, $workflow->get('description'), $workflow->get('environment'));
                 $this->logger->info($started_message);
             }
             if ($workflow->get('finished_at') > $last_finished_at && !in_array($workflow->id, $finished)) {
                 array_push($finished, $workflow->id);
                 $finished_message = sprintf("Finished Workflow %s %s (%s)", $workflow->id, $workflow->get('description'), $workflow->get('environment'));
                 $this->logger->info($finished_message);
                 if ($workflow->get('has_operation_log_output')) {
                     $workflow->fetchWithLogs();
                     $operations = $workflow->operations();
                     foreach ($operations as $operation) {
                         if ($operation->has('log_output')) {
                             $log_msg = sprintf("\n------ %s ------\n%s", $operation->description(), $operation->get('log_output'));
                             $this->log()->info($log_msg);
                         }
                     }
                 }
             }
         }
     }
 }