58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\VirtualMachine\Create;
|
|
|
|
use App\Http\Services\vCenter as ServiceVCenter;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class GetVirtualMachine implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected string $name;
|
|
protected $data;
|
|
protected $response = '';
|
|
protected ServiceVCenter $serviceVCenter;
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($name = '', $data,$service)
|
|
{
|
|
//
|
|
$this->name = $name;
|
|
$this->data = $data;
|
|
$this->serviceVCenter = $service;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return bool|string
|
|
*/
|
|
public function handle()
|
|
{
|
|
|
|
$vmware_id = $this->serviceVCenter->FindVirtualMachine($this->name);
|
|
|
|
Log::channel('detail')->info("==================");
|
|
|
|
Log::channel('detail')->info($vmware_id);
|
|
|
|
return $vmware_id;
|
|
|
|
}
|
|
|
|
public function failed(\Throwable $error)
|
|
{
|
|
Log::channel('error')->info($error->getMessage());
|
|
}
|
|
|
|
}
|