Skip to content

Commit 5da7d2d

Browse files
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 <[email protected]> * strip string while processing powerstate for HyperV Signed-off-by: Rohit Yadav <[email protected]> * ignore warning that spills over to exten output string Signed-off-by: Rohit Yadav <[email protected]> --------- Signed-off-by: Rohit Yadav <[email protected]>
1 parent e5e902a commit 5da7d2d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

extensions/HyperV/hyperv.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818

19+
import warnings
20+
warnings.filterwarnings('ignore')
21+
1922
import json
2023
import sys
2124
import winrm
@@ -200,12 +203,11 @@ def reboot(self):
200203
def status(self):
201204
command = f'(Get-VM -Name "{self.data["vmname"]}").State'
202205
state = self.run_ps(command)
203-
if state.lower() == "running":
206+
power_state = "unknown"
207+
if state.strip().lower() == "running":
204208
power_state = "poweron"
205-
elif state.lower() == "off":
209+
elif state.strip().lower() == "off":
206210
power_state = "poweroff"
207-
else:
208-
power_state = "unknown"
209211
succeed({"status": "success", "power_state": power_state})
210212

211213
def delete(self):

scripts/vm/hypervisor/external/provisioner/provisioner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ reboot() {
9696

9797
status() {
9898
parse_json "$1" || exit 1
99-
echo '{"status": "success", "power_state": "running"}'
99+
echo '{"status": "success", "power_state": "poweron"}'
100100
}
101101

102102
action=$1

0 commit comments

Comments
 (0)