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:
@@ -13,8 +13,14 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from ironic_python_agent.extensions import base
|
from ironic_python_agent.extensions import base
|
||||||
|
from ironic_python_agent import hardware
|
||||||
|
|
||||||
|
|
||||||
class DecomExtension(base.BaseAgentExtension):
|
class DecomExtension(base.BaseAgentExtension):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DecomExtension, self).__init__()
|
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
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
from oslotest import base as test_base
|
from oslotest import base as test_base
|
||||||
|
|
||||||
from ironic_python_agent.extensions import decom
|
from ironic_python_agent.extensions import decom
|
||||||
@@ -21,3 +22,10 @@ class TestDecomExtension(test_base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDecomExtension, self).setUp()
|
super(TestDecomExtension, self).setUp()
|
||||||
self.agent_extension = decom.DecomExtension()
|
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()
|
||||||
|
Reference in New Issue
Block a user