From 7ec1745d1143701b1322de21719be02bcc2cd520 Mon Sep 17 00:00:00 2001 From: Serhii Tonkoshkuryk Date: Tue, 7 May 2024 15:35:56 +0200 Subject: [PATCH] feat: add guest operating system to perform a reboot --- src/Traits/Rest/VmApis.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Traits/Rest/VmApis.php b/src/Traits/Rest/VmApis.php index 9751313..c620ca2 100644 --- a/src/Traits/Rest/VmApis.php +++ b/src/Traits/Rest/VmApis.php @@ -51,8 +51,6 @@ public function startPower(string $vmId) public function stopPower(string $vmId) { - $a = 5; - return $this->request( 'post', $this->version >= 7 ? "/api/vcenter/vm/$vmId/power?action=stop" : "/rest/vcenter/vm/$vmId/power/stop" @@ -132,14 +130,17 @@ public function getGuestOperations() // TODO: } - public function getGuestPower() + public function getGuestPower(string $vmId) { - // TODO: + return $this->request('get', "$this->apiUrlPrefix/vcenter/vm/$vmId/guest/power"); } - public function rebootGuestPower() + public function rebootGuestPower(string $vmId) { - // TODO: + return $this->request( + 'post', + "/api/vcenter/vm/$vmId/guest/power?action=reboot" + ); } public function shutdownGuestPower(string $vmId) @@ -284,11 +285,12 @@ public function getHardwareCpu() public function updateHardwareCpu( string $vmId, - int $coresPerSocket, - int $count, - bool $hotAddEnabled = false, - bool $hotRemoveEnabled = false - ) { + int $coresPerSocket, + int $count, + bool $hotAddEnabled = false, + bool $hotRemoveEnabled = false + ) + { $requestBody = [ 'cores_per_socket' => $coresPerSocket, 'count' => $count,