Update source into github
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\VirtualMachine\Create;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CheckStatusVirtualMachine implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $vmware_id;
|
||||
protected $serviceVCenter;
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($vmware_id, $data,$service)
|
||||
{
|
||||
$this->vmware_id = $vmware_id;
|
||||
$this->serviceVCenter = $service;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$status = $this->serviceVCenter->CheckVirtualMachine($this->vmware_id);
|
||||
|
||||
if ($status['error'] === true) {
|
||||
throw new \Exception(json_encode($status['message']));
|
||||
}
|
||||
if ($status['data']['operations_ready'] === false) {
|
||||
do {
|
||||
sleep(10);
|
||||
$status = $this->serviceVCenter->CheckVirtualMachine($this->vmware_id);
|
||||
} while ($status['data']['operations_ready'] !== true);
|
||||
}
|
||||
|
||||
$jobs_configNetwork = new GetNetworkVirtualMachine($this->vmware_id,$this->data,$this->serviceVCenter);
|
||||
dispatch($jobs_configNetwork)->delay(now()->addSeconds(5));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user