$this->moduleVmwareId, 'new_vm_id' => $this->newVmId, ]); $ctx = $rebuildService ->buildContext($this->moduleVmwareId, $this->newOsId, $this->newVmId); $passwordService->rotate($ctx, $this->reinstallLogId); RebuildAddonInstallJob::dispatch( $this->moduleVmwareId, $this->newOsId, $this->newVmId, $this->reinstallLogId, )->onQueue('default'); Log::info('RebuildChangePasswordJob: completed, addon job dispatched', [ 'module_vmware_id' => $this->moduleVmwareId, 'new_vm_id' => $this->newVmId, ]); $vmAfter = ModuleVmware::find($this->moduleVmwareId); (new Telegram)->SendRebuildStepNotification( $ctx->vmName, $ctx->ip, 'Đổi mật khẩu' . ($ctx->isWindows ? ' & Port RDP' : ''), true, $ctx->isWindows ? "Port RDP mới: {$vmAfter?->port}" : null, ); } public function failed(Throwable $e): void { Log::error('RebuildChangePasswordJob: failed — old VM preserved', [ 'module_vmware_id' => $this->moduleVmwareId, 'new_vm_id' => $this->newVmId, 'error' => $e->getMessage(), ]); \App\Models\ReinstallLog::where('id', $this->reinstallLogId)->update([ 'status' => \App\Models\ReinstallLog::STATUS_FAILED, 'error_message' => 'ChangePassword failed: ' . $e->getMessage(), 'updated_at' => now(), ]); $vm = ModuleVmware::with('customer')->find($this->moduleVmwareId); (new Telegram)->SendRebuildStepNotification( $vm->name ?? "VM #{$this->moduleVmwareId}", $vm->ip ?? '', 'Đổi mật khẩu & Port', false, $e->getMessage(), ); VmRebuildFailedJob::dispatch([ 'customer_email' => $vm?->customer?->email, 'customer_name' => $vm?->customer?->fullname, 'vm_name' => $vm->name ?? "VM #{$this->moduleVmwareId}", 'ip' => $vm->ip ?? '', 'module_vmware_id' => $this->moduleVmwareId, ]); } }