update change port
This commit is contained in:
@@ -898,11 +898,6 @@ PS;
|
||||
])
|
||||
->patch("https://{$this->apiUri}/rest/vcenter/vm/{$vmId}/hardware/cpu", $payload);
|
||||
|
||||
Log::info("📥 Response CPU", [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body()
|
||||
]);
|
||||
|
||||
if ($response->successful()) {
|
||||
Log::info("✅ API call cập nhật CPU thành công cho VM {$vmId}");
|
||||
return true;
|
||||
@@ -938,8 +933,6 @@ PS;
|
||||
]
|
||||
];
|
||||
|
||||
Log::info("📤 Payload RAM", ['payload' => $payload]);
|
||||
|
||||
$response = Http::withoutVerifying()
|
||||
->timeout(30)
|
||||
->withHeaders([
|
||||
@@ -948,11 +941,6 @@ PS;
|
||||
])
|
||||
->patch("https://{$this->apiUri}/rest/vcenter/vm/{$vmId}/hardware/memory", $payload);
|
||||
|
||||
Log::info("📥 Response RAM", [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body()
|
||||
]);
|
||||
|
||||
if ($response->successful()) {
|
||||
Log::info("✅ API call cập nhật RAM thành công cho VM {$vmId}");
|
||||
return true;
|
||||
@@ -2029,8 +2017,7 @@ PS;
|
||||
// Kiểm tra hệ điều hành
|
||||
if (str_contains($this->os, "Windows")) {
|
||||
$user = $data['user'] ?? 'administartor';
|
||||
$this->process = new WinRMClient($ip, $user, $password);
|
||||
;
|
||||
$this->process = new WinRMClient($ip, $user, $password);;
|
||||
return $this->process;
|
||||
}
|
||||
|
||||
@@ -2345,7 +2332,6 @@ PS;
|
||||
'error' => false,
|
||||
'message' => 'Test addon update completed'
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("🧪 TEST: Lỗi trong test addon update: " . $e->getMessage());
|
||||
return [
|
||||
@@ -2379,7 +2365,6 @@ PS;
|
||||
'message' => 'Test getSnapShot completed',
|
||||
'result' => $result
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("🧪 TEST: Lỗi trong test getSnapShot: " . $e->getMessage());
|
||||
return [
|
||||
@@ -2417,7 +2402,6 @@ PS;
|
||||
$dns = $product->ipAddress->dns ?? '8.8.8.8';
|
||||
$vmware_name = $product->name ?? $vmware_id;
|
||||
$vCenter = $product->ipAddress->host->datacenter->vCenter ?? null;
|
||||
|
||||
} elseif ($product && isset($product->IpAddress) && $product->IpAddress) {
|
||||
Log::info('✅ Using old Product structure for assignIPWindows', [
|
||||
'product_id' => $product->id,
|
||||
@@ -2482,7 +2466,6 @@ PS;
|
||||
'output' => $output
|
||||
];
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::channel('Custom')->error("Exception in assignIPWindows: " . $e->getMessage());
|
||||
return [
|
||||
@@ -2659,4 +2642,31 @@ PS;
|
||||
|
||||
return $snapshots;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get Window Remote Port
|
||||
*/
|
||||
public function getWindowsRdpPort(string $vmwareId, string $guestUser, string $guestPassword): ?int
|
||||
{
|
||||
$ps = "(Get-ItemProperty 'HKLM:\\System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp' -Name PortNumber).PortNumber";
|
||||
|
||||
$cmd = "Invoke-VMScript -VM '$vmwareId' "
|
||||
. "-ScriptText \"$ps\" "
|
||||
. "-ScriptType Powershell "
|
||||
. "-GuestUser '$guestUser' "
|
||||
. "-GuestPassword '$guestPassword'";
|
||||
|
||||
$output = $this->Command($cmd);
|
||||
|
||||
if (!$output || str_contains($output, 'Login_Fail')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/\b(\d{2,5})\b/', $output, $m)) {
|
||||
return (int) $m[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user