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
+4 -1
View File
@@ -16,7 +16,10 @@ class Client
public function loginServer(Vcenter $vcenterModel): bool|string
{
$this->apiUri = 'console.tgs.com.vn';
// console.tgs.com.vn (HAProxy) only proxies WMKS console websockets
// to ESXi hosts by ?host= — the vCenter management API must be
// called directly against the vCenter's own host.
$this->apiUri = $vcenterModel->host;
$this->username = $vcenterModel->user;
$this->password = SignRSA::DecryptFunc($vcenterModel->password);
@@ -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 [