feat: implement VM snapshot management, enhance client resource loading, and refactor deployment workflow for production

This commit is contained in:
pbao9
2026-05-11 11:09:55 +07:00
parent 8aef607e1f
commit 96778e7bed
51 changed files with 2536 additions and 1249 deletions
+33
View File
@@ -103,6 +103,39 @@ class vCenter
return "Login_Again";
}
/**
* Search VM by exact name in vCenter.
* Returns the first matching VM array or null if not found.
*/
public function findVirtualMachineByName(string $vmName): ?array
{
$check = $this->checkApiExits();
if (!$check) {
Log::warning('findVirtualMachineByName: API check failed');
return null;
}
$response = Http::withoutVerifying()
->withHeaders([
'vmware-api-session-id' => $this->token
])
->get("https://$this->apiUri/rest/vcenter/vm", [
'filter.names.1' => $vmName,
]);
if (!$response->successful()) {
Log::warning('findVirtualMachineByName: HTTP failed', ['status' => $response->status()]);
return null;
}
$json = $response->json();
if (isset($json['type']) || empty($json['value'])) {
return null;
}
return $json['value'][0] ?? null;
}
public function checkApiExits(): bool
{