Implement the reboot command on the Ironic Driver

Closes-Bug: #1310137
Change-Id: I63266d73537573f132b4914d15a87a8ccfa732e6
This commit is contained in:
Lucas Alvares Gomes 2014-05-07 10:38:12 +01:00
parent f587d4750d
commit 29548ec6e8
2 changed files with 25 additions and 4 deletions

View File

@ -774,9 +774,15 @@ class IronicDriverTestCase(test.NoDBTestCase):
mock_sps.assert_called_once_with(node_uuid, 'deleted')
mock_get_by_iuuid.assert_called_with(instance.uuid)
def test_reboot(self):
#TODO(lucasagomes): Not implemented in the driver.py
pass
@mock.patch.object(FAKE_CLIENT.node, 'set_power_state')
@mock.patch.object(ironic_driver, 'validate_instance_and_node')
def test_reboot(self, mock_val_inst, mock_set_power):
node = ironic_utils.get_test_node()
mock_val_inst.return_value = node
instance = fake_instance.fake_instance_obj(self.ctx,
node=node.uuid)
self.driver.reboot(self.ctx, instance, None, None)
mock_set_power.assert_called_once_with(node.uuid, 'reboot')
def test_power_off(self):
node_uuid = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'

View File

@ -509,7 +509,22 @@ class IronicDriver(virt_driver.ComputeDriver):
def reboot(self, context, instance, network_info, reboot_type,
block_device_info=None, bad_volumes_callback=None):
pass
"""Reboot the specified instance.
:param instance: The instance object.
:param network_info: Instance network information. Ignored by
this driver.
:param reboot_type: Either a HARD or SOFT reboot. Ignored by
this driver.
:param block_device_info: Info pertaining to attached volumes.
Ignored by this driver.
:param bad_volumes_callback: Function to handle any bad volumes
encountered. Ignored by this driver.
"""
icli = client_wrapper.IronicClientWrapper()
node = validate_instance_and_node(icli, instance)
icli.call("node.set_power_state", node.uuid, 'reboot')
def power_off(self, instance, node=None):
# TODO(nobodycam): check the current power state first.