コード例 #1
0
 /**
  * Handle a deprovisioning request
  *
  * @param DeprovisionJob $command
  *
  * @return bool|mixed
  */
 public function handle(DeprovisionJob $command)
 {
     $_options = $command->getOptions();
     $this->debug('>>> deprovision "' . $command->getInstanceId() . '" request received');
     try {
         //  Find the instance
         $_instance = $this->_findInstance($command->getInstanceId());
     } catch (\Exception $_ex) {
         $this->error('deprovision request failure: instance not found.');
         return false;
     }
     try {
         $_provisioner = Provision::getProvisioner($_instance->guest_location_nbr);
         if (empty($_provisioner)) {
             throw new \RuntimeException('The provisioner of the request is not valid.');
         }
         $_response = $_provisioner->deprovision(new ProvisionServiceRequest($_instance, null, true, false, $_options));
         if (!$_response) {
             throw new ProvisioningException('deprovision failure');
         }
         $this->info('deprovision request complete in ' . number_format($_response->getElapsedTime(), 4) . 's');
         $this->debug('<<< deprovision "' . $command->getInstanceId() . '" request SUCCESS');
         $command->setResult($_response);
         return $_response;
     } catch (\Exception $_ex) {
         $this->error('deprovision "' . $command->getInstanceId() . '" request exception: ' . $_ex->getMessage());
     }
     $this->debug('<<< deprovision "' . $command->getInstanceId() . '" request FAILURE');
     return false;
 }
コード例 #2
0
 /** @inheritdoc */
 public function deprovision(DeprovisionJob $job)
 {
     return $this->resolve($job->getInstance()->guest_location_nbr)->deprovision(ProvisionServiceRequest::createDeprovision($job->getInstance()));
 }