Skip to content

Commit

Permalink
implement shutdown for vmhost devices
Browse files Browse the repository at this point in the history
  • Loading branch information
apurvaraghu authored Jan 18, 2024
1 parent 422ca38 commit cbf6cba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/jnpr/junos/utils/sw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,8 @@ def _system_operation(
) and member_id is not None:
cmd.append(E("member", str(member_id)))
if in_min >= 0 and at is None:
cmd.append(E("in", str(in_min)))
if vmhost is not True:
cmd.append(E("in", str(in_min)))
elif at is not None:
cmd.append(E("at", str(at)))
try:
Expand Down Expand Up @@ -1230,7 +1231,7 @@ def reboot(
# -------------------------------------------------------------------------
# poweroff - system shutdown
# -------------------------------------------------------------------------
def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False):
def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False, vmhost=False):
"""
Perform a system shutdown, with optional delay (in minutes) .
Expand All @@ -1252,6 +1253,8 @@ def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False)
:param str other_re: If the system has dual Routing Engines and this option is C(true),
then the action is performed on the other REs in the system.
:param str vmhost: If the device is vmhost device then the shutdown will be performed on the device
:returns:
* power-off message (string) if command successful
Expand All @@ -1265,11 +1268,14 @@ def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False)
else:
cmd = E("request-node-power-off")
cmd.append(E("node", on_node))
elif vmhost is True:
cmd = E("request-vmhost-poweroff")
all_re = False
else:
cmd = E("request-power-off")
try:
return self._system_operation(
cmd, in_min, at, all_re, other_re, vmhost=False
cmd, in_min, at, all_re, other_re, vmhost
)
except Exception as err:
if err.rsp.findtext(".//error-severity") != "warning":
Expand Down

0 comments on commit cbf6cba

Please sign in to comment.