update sync vm

This commit is contained in:
pbao9
2026-02-05 21:57:57 +07:00
parent 3a01d07a74
commit eef04846a8
11 changed files with 436 additions and 76 deletions
+23
View File
@@ -77,6 +77,29 @@ class vCenter
return "Login_Again";
}
public function getAllVirtualMachine($datacenter = '')
{
$check = $this->checkApiExits();
if ($check) {
$params = [];
if (!empty($datacenter)) {
$params['filter.datacenters'] = $datacenter;
}
$response = Http::withoutVerifying()
->withHeaders([
'vmware-api-session-id' => $this->token
])
->get("https://$this->apiUri/rest/vcenter/vm", $params)->json();
if (!isset($response['type'])) {
return $response['value'];
}
return false;
}
return "Login_Again";
}
public function checkApiExits(): bool
{