update vm ticket
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Jobs\VirtualMachine;
|
||||
|
||||
use App\Http\Facade\SignRSA;
|
||||
use App\Mail\Customer\VmPasswordChanged;
|
||||
use App\Models\ModuleVmware;
|
||||
use App\Models\vCenter;
|
||||
use App\Services\VmProvisionService;
|
||||
use App\Services\VsphereHostSshService;
|
||||
@@ -14,6 +16,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* ChangeVmPasswordJob
|
||||
@@ -71,6 +74,8 @@ class ChangeVmPasswordJob implements ShouldQueue
|
||||
// Persist encrypted password to DB
|
||||
$provision->updatePassword($this->moduleVmwareId, $this->newPassword);
|
||||
|
||||
$this->notifyCustomer();
|
||||
|
||||
Log::info('ChangeVmPasswordJob: password changed successfully', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'vm_id' => $this->vmId,
|
||||
@@ -86,6 +91,19 @@ class ChangeVmPasswordJob implements ShouldQueue
|
||||
]);
|
||||
}
|
||||
|
||||
private function notifyCustomer(): void
|
||||
{
|
||||
$vm = ModuleVmware::with('customer')->find($this->moduleVmwareId);
|
||||
if (!$vm?->customer?->email) {
|
||||
return;
|
||||
}
|
||||
|
||||
Mail::to($vm->customer->email)->queue(new VmPasswordChanged([
|
||||
'fullname' => $vm->customer->fullname,
|
||||
'vm_name' => $vm->name,
|
||||
]));
|
||||
}
|
||||
|
||||
private function assertSuccess(string $output): void
|
||||
{
|
||||
if (str_contains(strtoupper(trim($output)), 'SUCCESS')) {
|
||||
|
||||
Reference in New Issue
Block a user