55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?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 CheckIPAddress implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
protected string $vmware_id;
|
|
protected $serviceVCenter;
|
|
protected $data;
|
|
protected array $info;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($vmware_id, $data,$virtual_info,$service)
|
|
{
|
|
$this->vmware_id = $vmware_id;
|
|
$this->serviceVCenter = $service;
|
|
$this->data = $data;
|
|
$this->info = $virtual_info;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
$DetailVirtualMachine = $this->serviceVCenter->GetIPAddressVirtualMachine($this->vmware_id);
|
|
|
|
if ($DetailVirtualMachine['error']) {
|
|
throw new \Exception(json_encode($DetailVirtualMachine['message']));
|
|
}
|
|
|
|
if (!$DetailVirtualMachine['data']['ip_address'] === $this->data->IpAddress->ip) {
|
|
throw new \Exception(json_encode($DetailVirtualMachine['message']));
|
|
}
|
|
$jobs_configDB = new ConfigDatabase($this->data,$this->info);
|
|
dispatch($jobs_configDB)->delay(now()->addSeconds(5));
|
|
|
|
}
|
|
}
|