Fixes power-on failure for 'ilo' hardware type
Server fails to return success for power-on operation if no bootable device is found. Change-Id: I0e6ab307ecd0caaf7b79edff67373be3490bfed7 Story: 2006288 Task: 35997
This commit is contained in:
@@ -94,12 +94,13 @@ def _get_power_state(node):
|
|||||||
return states.ERROR
|
return states.ERROR
|
||||||
|
|
||||||
|
|
||||||
def _wait_for_state_change(node, target_state,
|
def _wait_for_state_change(node, target_state, requested_state,
|
||||||
is_final_state=True, timeout=None):
|
is_final_state=True, timeout=None):
|
||||||
"""Wait for the power state change to get reflected.
|
"""Wait for the power state change to get reflected.
|
||||||
|
|
||||||
:param node: The node.
|
:param node: The node.
|
||||||
:param target_state: target power state of the node.
|
:param target_state: calculated target power state of the node.
|
||||||
|
:param requested_state: actual requested power state of the node.
|
||||||
:param is_final_state: True, if the given target state is the final
|
:param is_final_state: True, if the given target state is the final
|
||||||
expected power state of the node. Default is True.
|
expected power state of the node. Default is True.
|
||||||
:param timeout: timeout (in seconds) positive integer (> 0) for any
|
:param timeout: timeout (in seconds) positive integer (> 0) for any
|
||||||
@@ -130,7 +131,14 @@ def _wait_for_state_change(node, target_state,
|
|||||||
target_state == states.SOFT_REBOOT and not is_final_state):
|
target_state == states.SOFT_REBOOT and not is_final_state):
|
||||||
state_to_check = ilo_common.POST_POWEROFF_STATE
|
state_to_check = ilo_common.POST_POWEROFF_STATE
|
||||||
else:
|
else:
|
||||||
state_to_check = ilo_common.POST_FINISHEDPOST_STATE
|
# It may not be able to finish POST if no bootable device is
|
||||||
|
# found. Track (POST_FINISHEDPOST_STATE) only for soft reboot.
|
||||||
|
# For other power-on cases track for beginning of POST operation
|
||||||
|
# (POST_INPOST_STATE) to return.
|
||||||
|
state_to_check = (
|
||||||
|
ilo_common.POST_FINISHEDPOST_STATE if
|
||||||
|
requested_state == states.SOFT_REBOOT else
|
||||||
|
ilo_common.POST_INPOST_STATE)
|
||||||
|
|
||||||
def _wait(state):
|
def _wait(state):
|
||||||
if use_post_state:
|
if use_post_state:
|
||||||
@@ -187,6 +195,7 @@ def _set_power_state(task, target_state, timeout=None):
|
|||||||
# Check if its soft power operation
|
# Check if its soft power operation
|
||||||
soft_power_op = target_state in [states.SOFT_POWER_OFF, states.SOFT_REBOOT]
|
soft_power_op = target_state in [states.SOFT_POWER_OFF, states.SOFT_REBOOT]
|
||||||
|
|
||||||
|
requested_state = target_state
|
||||||
if target_state == states.SOFT_REBOOT:
|
if target_state == states.SOFT_REBOOT:
|
||||||
if _get_power_state(node) == states.POWER_OFF:
|
if _get_power_state(node) == states.POWER_OFF:
|
||||||
target_state = states.POWER_ON
|
target_state = states.POWER_ON
|
||||||
@@ -229,7 +238,8 @@ def _set_power_state(task, target_state, timeout=None):
|
|||||||
is_final_state = target_state in (states.SOFT_POWER_OFF,
|
is_final_state = target_state in (states.SOFT_POWER_OFF,
|
||||||
states.POWER_ON)
|
states.POWER_ON)
|
||||||
time_consumed = _wait_for_state_change(
|
time_consumed = _wait_for_state_change(
|
||||||
node, target_state, is_final_state=is_final_state, timeout=timeout)
|
node, target_state, requested_state,
|
||||||
|
is_final_state=is_final_state, timeout=timeout)
|
||||||
if target_state == states.SOFT_REBOOT:
|
if target_state == states.SOFT_REBOOT:
|
||||||
_attach_boot_iso_if_needed(task)
|
_attach_boot_iso_if_needed(task)
|
||||||
try:
|
try:
|
||||||
@@ -242,11 +252,12 @@ def _set_power_state(task, target_state, timeout=None):
|
|||||||
# Re-calculate timeout available for power-on operation
|
# Re-calculate timeout available for power-on operation
|
||||||
rem_timeout = timeout - time_consumed
|
rem_timeout = timeout - time_consumed
|
||||||
time_consumed += _wait_for_state_change(
|
time_consumed += _wait_for_state_change(
|
||||||
node, states.SOFT_REBOOT, is_final_state=True,
|
node, states.SOFT_REBOOT, requested_state, is_final_state=True,
|
||||||
timeout=rem_timeout)
|
timeout=rem_timeout)
|
||||||
else:
|
else:
|
||||||
time_consumed = _wait_for_state_change(
|
time_consumed = _wait_for_state_change(
|
||||||
node, target_state, is_final_state=True, timeout=timeout)
|
node, target_state, requested_state, is_final_state=True,
|
||||||
|
timeout=timeout)
|
||||||
LOG.info("The node %(node_id)s operation of '%(state)s' "
|
LOG.info("The node %(node_id)s operation of '%(state)s' "
|
||||||
"is completed in %(time_consumed)s seconds.",
|
"is completed in %(time_consumed)s seconds.",
|
||||||
{'node_id': node.uuid, 'state': target_state,
|
{'node_id': node.uuid, 'state': target_state,
|
||||||
|
@@ -99,7 +99,7 @@ class IloPowerInternalMethodsTestCase(test_common.BaseIloTest):
|
|||||||
get_ilo_object_mock):
|
get_ilo_object_mock):
|
||||||
ilo_mock_object = get_ilo_object_mock.return_value
|
ilo_mock_object = get_ilo_object_mock.return_value
|
||||||
get_post_mock.side_effect = (['FinishedPost', 'PowerOff',
|
get_post_mock.side_effect = (['FinishedPost', 'PowerOff',
|
||||||
'FinishedPost'])
|
'InPost'])
|
||||||
|
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
shared=True) as task:
|
||||||
@@ -131,7 +131,7 @@ class IloPowerInternalMethodsTestCase(test_common.BaseIloTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
def test__set_power_state_on_ok(self, get_post_mock, get_ilo_object_mock):
|
def test__set_power_state_on_ok(self, get_post_mock, get_ilo_object_mock):
|
||||||
ilo_mock_object = get_ilo_object_mock.return_value
|
ilo_mock_object = get_ilo_object_mock.return_value
|
||||||
get_post_mock.side_effect = ['PowerOff', 'PowerOff', 'FinishedPost']
|
get_post_mock.side_effect = ['PowerOff', 'PowerOff', 'InPost']
|
||||||
|
|
||||||
target_state = states.POWER_ON
|
target_state = states.POWER_ON
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes an issue in powering-on of server in ``ilo`` hardware type. Server
|
||||||
|
was failing to return success for power-on operation if no bootable
|
||||||
|
device was found. See `story 2006288
|
||||||
|
<https://storyboard.openstack.org/#!/story/2006288>`__ for details.
|
Reference in New Issue
Block a user