Soft power operations for OneView hardware type
Oneview hardware type currently performs power operations using OneView "Press and Hold" mode. There is a "Momentary Press" and a reboot mode that could be directly mapped to the different options supported by Ironic. Closes-Bug: 1722374 Change-Id: I5df8a814384f140b5e5c768c78c57cab7fbdaaa2
This commit is contained in:
parent
180234b445
commit
24df981b58
@ -36,7 +36,7 @@ POWER_ON = {'powerState': 'On'}
|
||||
POWER_OFF = {'powerState': 'Off', 'powerControl': 'PressAndHold'}
|
||||
REBOOT = {'powerState': 'On', 'powerControl': 'ColdBoot'}
|
||||
SOFT_REBOOT = {'powerState': 'On', 'powerControl': 'Reset'}
|
||||
SOFT_POWER_OFF = {'powerState': 'Off', 'powerControl': 'PressAndHold'}
|
||||
SOFT_POWER_OFF = {'powerState': 'Off', 'powerControl': 'MomentaryPress'}
|
||||
|
||||
GET_POWER_STATE_MAP = {
|
||||
'On': states.POWER_ON,
|
||||
@ -162,9 +162,14 @@ class OneViewPower(base.PowerInterface):
|
||||
oneview_client.server_hardware.update_power_state(
|
||||
SET_POWER_STATE_MAP.get(power_state),
|
||||
server_hardware, timeout=timeout)
|
||||
elif power_state == states.REBOOT:
|
||||
elif (power_state == states.REBOOT or
|
||||
power_state == states.SOFT_REBOOT):
|
||||
power_off_mode = (states.POWER_OFF
|
||||
if power_state == states.REBOOT
|
||||
else states.SOFT_POWER_OFF)
|
||||
|
||||
oneview_client.server_hardware.update_power_state(
|
||||
SET_POWER_STATE_MAP.get(states.POWER_OFF),
|
||||
SET_POWER_STATE_MAP.get(power_off_mode),
|
||||
server_hardware, timeout=timeout)
|
||||
management.set_boot_device(task)
|
||||
oneview_client.server_hardware.update_power_state(
|
||||
@ -198,3 +203,15 @@ class OneViewPower(base.PowerInterface):
|
||||
self.set_power_state(task, states.REBOOT, timeout=timeout)
|
||||
else:
|
||||
self.set_power_state(task, states.POWER_ON, timeout=timeout)
|
||||
|
||||
@METRICS.timer('OneViewPower.get_supported_power_states')
|
||||
def get_supported_power_states(self, task):
|
||||
"""Get a list of the supported power states.
|
||||
|
||||
:param task: A TaskManager instance containing the node to act on.
|
||||
Currently not used.
|
||||
:returns: A list with the supported power states defined
|
||||
in :mod:`ironic.common.states`.
|
||||
"""
|
||||
return [states.POWER_ON, states.POWER_OFF, states.REBOOT,
|
||||
states.SOFT_REBOOT, states.SOFT_POWER_OFF]
|
||||
|
@ -174,6 +174,21 @@ class OneViewPowerDriverTestCase(db_base.DbTestCase):
|
||||
update = client.server_hardware.update_power_state
|
||||
update.assert_has_calls(calls)
|
||||
|
||||
@mock.patch.object(common, 'get_hponeview_client')
|
||||
@mock.patch.object(management, 'set_boot_device')
|
||||
def test_set_power_soft_reboot(
|
||||
self, mock_set_boot_device, mock_get_ov_client):
|
||||
client = mock_get_ov_client()
|
||||
self.driver.power.client = client
|
||||
server_hardware = self.node.driver_info.get('server_hardware_uri')
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
self.driver.power.set_power_state(task, states.SOFT_REBOOT)
|
||||
calls = [mock.call(power.SOFT_POWER_OFF, server_hardware,
|
||||
timeout=-1),
|
||||
mock.call(power.POWER_ON, server_hardware, timeout=-1)]
|
||||
update = client.server_hardware.update_power_state
|
||||
update.assert_has_calls(calls)
|
||||
|
||||
@mock.patch.object(common, 'get_hponeview_client')
|
||||
@mock.patch.object(management, 'set_boot_device')
|
||||
def test_set_power_on_fail(self, mock_set_boot_device, mock_get_ov_client):
|
||||
@ -291,3 +306,11 @@ class OneViewPowerDriverTestCase(db_base.DbTestCase):
|
||||
update.assert_called_once_with(power.POWER_ON, server_hardware,
|
||||
timeout=2)
|
||||
mock_set_boot_device.assert_called_once_with(task)
|
||||
|
||||
def test_get_supported_power_states(self):
|
||||
with task_manager.acquire(self.context, self.node.uuid,
|
||||
shared=True) as task:
|
||||
supported_power_states = (
|
||||
task.driver.power.get_supported_power_states(task))
|
||||
self.assertEqual(set(power.SET_POWER_STATE_MAP),
|
||||
set(supported_power_states))
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Enables support for soft power off and soft
|
||||
reboot in the ``oneview`` hardware type.
|
Loading…
Reference in New Issue
Block a user