diff options
Diffstat (limited to 'ironic_python_agent')
| -rw-r--r-- | ironic_python_agent/extensions/decom.py | 6 | ||||
| -rw-r--r-- | ironic_python_agent/tests/extensions/decom.py | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ironic_python_agent/extensions/decom.py b/ironic_python_agent/extensions/decom.py index 454df683..20b7c8ad 100644 --- a/ironic_python_agent/extensions/decom.py +++ b/ironic_python_agent/extensions/decom.py @@ -13,8 +13,14 @@ # limitations under the License. from ironic_python_agent.extensions import base +from ironic_python_agent import hardware class DecomExtension(base.BaseAgentExtension): def __init__(self): super(DecomExtension, self).__init__() + self.command_map['erase_hardware'] = self.erase_hardware + + @base.async_command() + def erase_hardware(self): + hardware.get_manager().erase_devices() diff --git a/ironic_python_agent/tests/extensions/decom.py b/ironic_python_agent/tests/extensions/decom.py index 10dc3d84..6a571d28 100644 --- a/ironic_python_agent/tests/extensions/decom.py +++ b/ironic_python_agent/tests/extensions/decom.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import mock from oslotest import base as test_base from ironic_python_agent.extensions import decom @@ -21,3 +22,10 @@ class TestDecomExtension(test_base.BaseTestCase): def setUp(self): super(TestDecomExtension, self).setUp() self.agent_extension = decom.DecomExtension() + + @mock.patch('ironic_python_agent.hardware.get_manager', autospec=True) + def test_erase_hardware(self, mocked_get_manager): + hardware_manager = mocked_get_manager.return_value + result = self.agent_extension.erase_hardware('erase_hardware') + result.join() + hardware_manager.erase_devices.assert_called_once_with() |
