This commit is contained in:
baodev0
2026-07-23 10:51:58 +07:00
parent c13ff0229d
commit 1459fd49a3
7 changed files with 47 additions and 17 deletions
@@ -158,9 +158,28 @@ class PowerManagementService
"type" => "WEBMKS"
])->json();
if (!isset($response['error_type'])) {
// vCenter returns "wss://<esxi-host>/ticket/<id>" — the esxi
// host is only reachable through HAProxy's ?host= routing
// (see config('vmware.console_nodes')), so split it out here.
$esxiHost = parse_url((string) $response['ticket'], PHP_URL_HOST);
$ticketId = basename(parse_url((string) $response['ticket'], PHP_URL_PATH));
// Array access, not config('vmware.console_nodes.'.$esxiHost) —
// IPs contain dots, which collide with Laravel's dot notation.
$consoleHost = config('vmware.console_nodes')[$esxiHost] ?? null;
if (!$consoleHost) {
return [
'error' => true,
'data' => "Không tìm thấy console node cho ESXi host: $esxiHost",
];
}
return [
'error' => false,
'data' => $response['ticket']
'data' => [
'ticket' => $ticketId,
'host' => $consoleHost,
],
];
}
return [