feat: implement VM snapshot management, enhance client resource loading, and refactor deployment workflow for production
This commit is contained in:
@@ -58,7 +58,7 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public function handle(VsphereHostSshService $ssh): void
|
||||
public function handle(VsphereHostSshService $ssh, vCenter $vCenterService): void
|
||||
{
|
||||
Log::info('AssignIpToGuestJob: start', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
@@ -198,6 +198,38 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
]);
|
||||
|
||||
ModuleVmware::where('id', $this->moduleVmwareId)->update(['status' => 0]);
|
||||
|
||||
// Still send credential email — try to get IP from vSphere guest identity
|
||||
// so the customer at least gets server info even if IP assignment failed
|
||||
try {
|
||||
$moduleVmware = ModuleVmware::find($this->moduleVmwareId);
|
||||
if ($moduleVmware && !$moduleVmware->ip) {
|
||||
$vcenter = $moduleVmware->vCenter ?? vCenter::first();
|
||||
if ($vcenter && $vCenterService->loginServer($vcenter)) {
|
||||
$guestInfo = $vCenterService->GetIPAddressVirtualMachine($this->vmId);
|
||||
if (isset($guestInfo['error']) && $guestInfo['error'] === false) {
|
||||
$guestIp = $guestInfo['data']['ip_address'] ?? null;
|
||||
if ($guestIp) {
|
||||
$moduleVmware->update(['ip' => $guestIp, 'status' => 1]);
|
||||
Log::info('AssignIpToGuestJob: recovered IP from guest identity', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'ip' => $guestIp,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendVmCredentialsEmailJob::dispatch($this->moduleVmwareId);
|
||||
Log::info('AssignIpToGuestJob: dispatched SendVmCredentialsEmailJob after failed attempts', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('AssignIpToGuestJob: failed to send email after exhausted attempts', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e): void
|
||||
|
||||
Reference in New Issue
Block a user