[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/drydock/management/ -> DrydockManagementLeaseWorkflow.php (source)

   1  <?php
   2  
   3  final class DrydockManagementLeaseWorkflow
   4    extends DrydockManagementWorkflow {
   5  
   6    public function didConstruct() {
   7      $this
   8        ->setName('lease')
   9        ->setSynopsis('Lease a resource.')
  10        ->setArguments(
  11          array(
  12            array(
  13              'name'      => 'type',
  14              'param'     => 'resource_type',
  15              'help'      => 'Resource type.',
  16            ),
  17            array(
  18              'name'      => 'attributes',
  19              'param'     => 'name=value,...',
  20              'help'      => 'Resource specficiation.',
  21            ),
  22          ));
  23    }
  24  
  25    public function execute(PhutilArgumentParser $args) {
  26      $console = PhutilConsole::getConsole();
  27  
  28      $resource_type = $args->getArg('type');
  29      if (!$resource_type) {
  30        throw new PhutilArgumentUsageException(
  31          'Specify a resource type with `--type`.');
  32      }
  33  
  34      $attributes = $args->getArg('attributes');
  35      if ($attributes) {
  36        $options = new PhutilSimpleOptions();
  37        $options->setCaseSensitive(true);
  38        $attributes = $options->parse($attributes);
  39      }
  40  
  41      PhabricatorWorker::setRunAllTasksInProcess(true);
  42  
  43      $lease = id(new DrydockLease())
  44        ->setResourceType($resource_type);
  45      if ($attributes) {
  46        $lease->setAttributes($attributes);
  47      }
  48      $lease
  49        ->queueForActivation()
  50        ->waitUntilActive();
  51  
  52      $console->writeOut("Acquired Lease %s\n", $lease->getID());
  53      return 0;
  54    }
  55  
  56  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1