From 6e1f825bd2cee79032705fc6dd034b19ba8b75d6 Mon Sep 17 00:00:00 2001 From: Naohiro Tamura Date: Mon, 24 Oct 2016 11:23:23 +0900 Subject: [PATCH] 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 --- ironic_staging_drivers/tests/unit/wol/test_power.py | 6 ++++++ ironic_staging_drivers/wol/power.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/ironic_staging_drivers/tests/unit/wol/test_power.py b/ironic_staging_drivers/tests/unit/wol/test_power.py index d226160..c65999c 100644 --- a/ironic_staging_drivers/tests/unit/wol/test_power.py +++ b/ironic_staging_drivers/tests/unit/wol/test_power.py @@ -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) diff --git a/ironic_staging_drivers/wol/power.py b/ironic_staging_drivers/wol/power.py index 95941f1..14b27d2 100644 --- a/ironic_staging_drivers/wol/power.py +++ b/ironic_staging_drivers/wol/power.py @@ -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]