Overrides get_supported_power_states() for WOL Power

This patch overrides the default implementation of
get_supported_power_states() in the base power I/F for WOL Power.
The get_supported_power_states() is newly introduced in the base power
I/F to support SOFT_REBOOT and SOFT_POWER_OFF functions.

Change-Id: I4b46ebbbe8a976c382adb9e062c32d8670a15670
Partial-Bug: #1526226
Depends-On: I1c9bbd1f11f6a8565607c874b3c99aa10eeb62a5
This commit is contained in:
Naohiro Tamura 2016-10-24 11:23:23 +09:00
parent 6718d638eb
commit 6e1f825bd2
2 changed files with 15 additions and 0 deletions

View File

@ -194,3 +194,9 @@ class WakeOnLanDriverTestCase(db_base.DbTestCase):
mock_log.assert_called_once_with(mock.ANY, self.node.uuid)
mock_power.assert_called_once_with(task.driver.power, task,
states.POWER_ON)
def test_get_supported_power_states(self):
with task_manager.acquire(
self.context, self.node.uuid, shared=True) as task:
pstate = task.driver.power.get_supported_power_states(task)
self.assertEqual([states.POWER_ON, states.REBOOT], pstate)

View File

@ -181,3 +181,12 @@ class WakeOnLanPower(base.PowerInterface):
'not fully support this operation. Trying to '
'power on the node.'), task.node.uuid)
self.set_power_state(task, states.POWER_ON)
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.
:returns: A list with the supported power states defined
in :mod:`ironic.common.states`.
"""
return [states.POWER_ON, states.REBOOT]