Beispiel #1
0
 /**
  * Handle the command
  *
  * @return mixed
  */
 public function fire()
 {
     parent::fire();
     $_request = PortableServiceRequest::makeImport($this->argument('instance-id'), $this->argument('snapshot'), array_merge(['owner-id' => $this->argument('owner-id')], $this->getOptions()));
     $_job = new ImportJob($_request);
     $_result = $this->dispatch($_job);
     return [$_result, $_job];
 }
 /**
  * Create a new portability job
  *
  * @param PortableServiceRequest $request The request
  */
 public function __construct(PortableServiceRequest $request)
 {
     $this->target = $request->getTarget();
     $this->outputFile = $request->get('output-file');
     $this->ownerId = $request->get('owner-id');
     $this->ownerType = $request->get('owner-type');
     parent::__construct($request->getInstanceId(), $request->toArray());
 }
 /**
  * @param \DreamFactory\Enterprise\Services\Jobs\ExportJob $job
  *
  * @return array The list of files in the instance's snapshot mount that were created.
  */
 public function export(ExportJob $job)
 {
     try {
         $_instance = $this->_findInstance($job->getInstanceId());
     } catch (ModelNotFoundException $_ex) {
         throw new \RuntimeException('Instance "' . $job->getInstanceId() . '" not found.', Response::HTTP_NOT_FOUND);
     }
     //  Get the portable services of this instance provisioner
     $_services = $this->getPortableServices($_instance->guest_location_nbr);
     //  Allow each service to export individually, collecting the output
     $_exports = [];
     foreach ($_services as $_type => $_service) {
         //@todo I think the following may be replaced with "$_exports[$_type] = $_service->export($job);"
         $_exports[$_type] = $_service->export(PortableServiceRequest::makeExport($_instance, $job->getTarget()));
     }
     return Snapshot::createFromExports($_instance, $_exports, $job->getTarget() ?: array_get($job->getOptions(), 'target'), array_get($job->getOptions(), 'keep-days'));
 }