scripts: fix external provision to use correct power state & hyperv powersync (#11504)

* scripts: fix external provision to use correct power state

The valid states are poweron and poweroff.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

* strip string while processing powerstate for HyperV

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

* ignore warning that spills over to exten output string

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

---------

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2025-08-29 12:09:23 +05:30 committed by GitHub
parent e5e902a320
commit 5da7d2d01e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -16,6 +16,9 @@
# specific language governing permissions and limitations
# under the License.
import warnings
warnings.filterwarnings('ignore')
import json
import sys
import winrm
@ -200,12 +203,11 @@ class HyperVManager:
def status(self):
command = f'(Get-VM -Name "{self.data["vmname"]}").State'
state = self.run_ps(command)
if state.lower() == "running":
power_state = "unknown"
if state.strip().lower() == "running":
power_state = "poweron"
elif state.lower() == "off":
elif state.strip().lower() == "off":
power_state = "poweroff"
else:
power_state = "unknown"
succeed({"status": "success", "power_state": power_state})
def delete(self):

View File

@ -96,7 +96,7 @@ reboot() {
status() {
parse_json "$1" || exit 1
echo '{"status": "success", "power_state": "running"}'
echo '{"status": "success", "power_state": "poweron"}'
}
action=$1