Merge "Set longer shutdown time and fix power state error log"
This commit is contained in:
commit
df8989e2a1
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2022 Wind River Systems, Inc.
|
# Copyright (c) 2019-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
@ -131,7 +131,7 @@ from redfish.rest.v1 import InvalidCredentialsError
|
|||||||
|
|
||||||
FEATURE_NAME = 'Redfish Virtual Media Controller'
|
FEATURE_NAME = 'Redfish Virtual Media Controller'
|
||||||
VERSION_MAJOR = 2
|
VERSION_MAJOR = 2
|
||||||
VERSION_MINOR = 1
|
VERSION_MINOR = 2
|
||||||
|
|
||||||
POWER_ON = 'On'
|
POWER_ON = 'On'
|
||||||
POWER_OFF = "Off"
|
POWER_OFF = "Off"
|
||||||
@ -1073,7 +1073,7 @@ class VmcObject(object):
|
|||||||
elog("BMC is not publishing any %s" % info)
|
elog("BMC is not publishing any %s" % info)
|
||||||
self._exit(1)
|
self._exit(1)
|
||||||
|
|
||||||
dlog3("ResetActions: %s" % reset_command_list)
|
ilog("ResetActions: %s" % reset_command_list)
|
||||||
|
|
||||||
# load the appropriate acceptable command list
|
# load the appropriate acceptable command list
|
||||||
if state == POWER_OFF:
|
if state == POWER_OFF:
|
||||||
@ -1088,6 +1088,7 @@ class VmcObject(object):
|
|||||||
for acceptable_command in acceptable_commands:
|
for acceptable_command in acceptable_commands:
|
||||||
for reset_command in reset_command_list:
|
for reset_command in reset_command_list:
|
||||||
if reset_command == acceptable_command:
|
if reset_command == acceptable_command:
|
||||||
|
ilog("Selected Command: %s" % reset_command)
|
||||||
command = reset_command
|
command = reset_command
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -1113,30 +1114,41 @@ class VmcObject(object):
|
|||||||
# this was not a power command
|
# this was not a power command
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Set the timeout in seconds (14 minutes = 840 seconds)
|
||||||
|
timeout = int(os.environ.get('RVMC_POWER_ACTION_TIMEOUT', 840))
|
||||||
|
ilog("%s timeout is %d seconds" % (stage, timeout))
|
||||||
|
|
||||||
|
# Get the start time
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
# init wait duration
|
||||||
|
duration = 0
|
||||||
|
|
||||||
# poll for requested power state.
|
# poll for requested power state.
|
||||||
poll_count = 0
|
while time.time() - start_time < timeout and self.power_state != state:
|
||||||
MAX_STATE_POLL_COUNT = 60 # some servers take longer than 10 seconds
|
time.sleep(10)
|
||||||
while poll_count < MAX_STATE_POLL_COUNT and self.power_state != state:
|
|
||||||
time.sleep(3)
|
# update wait duration
|
||||||
poll_count = poll_count + 1
|
duration = int(time.time() - start_time)
|
||||||
|
|
||||||
# get systems info
|
# get systems info
|
||||||
if self.make_request(operation=GET,
|
if self.make_request(operation=GET,
|
||||||
path=self.systems_member_url) is False:
|
path=self.systems_member_url) is False:
|
||||||
elog("Failed to Get System State (%i of %i)" %
|
elog("Failed to Get System State (after %d secs)" %
|
||||||
(poll_count, MAX_STATE_POLL_COUNT))
|
(duration))
|
||||||
else:
|
else:
|
||||||
# get powerState
|
# get powerState
|
||||||
self.power_state = self.get_key_value('PowerState')
|
self.power_state = self.get_key_value('PowerState')
|
||||||
if self.power_state != state:
|
if self.power_state != state:
|
||||||
dlog1("waiting for power %s (%s) (%d)" %
|
dlog1("Waiting for Power %s (currently %s) (%d secs)" %
|
||||||
(state, self.power_state, poll_count))
|
(state, self.power_state, duration))
|
||||||
|
|
||||||
if self.power_state != state:
|
if self.power_state != state:
|
||||||
elog("Failed to Set System Power State to %s (%s)" %
|
elog("Failed to Set System Power State to %s after %d secs (%s)" %
|
||||||
(self.power_state, self.systems_member_url))
|
(state, duration, self.systems_member_url))
|
||||||
self._exit(1)
|
self._exit(1)
|
||||||
else:
|
else:
|
||||||
ilog("%s verified (%d)" % (stage, poll_count))
|
ilog("%s verified (after %d seconds)" % (stage, duration))
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Get CD/DVD Virtual Media URL
|
# Get CD/DVD Virtual Media URL
|
||||||
|
Loading…
Reference in New Issue
Block a user