Expose decom.erase_hardware command via API
Expose an async decom.erase_hardware command in the API. Executing this command simply calls erase_devices on the loaded HardwareManager implementation. Change-Id: I238264a4d5903200ad6a30d82b61804c1e3f5916
This commit is contained in:
parent
dff46583d3
commit
263f97c0e0
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user