summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-08 00:50:15 +0000
committerGerrit Code Review <review@openstack.org>2015-04-08 00:50:15 +0000
commitbb75894ba2de508a9eab9ac766f16d8f23bf3a50 (patch)
tree9684dcd69178c06d1341fc8e4e2437d95c0c997a
parent54c9af6cb46a3f79494575121e09a9ba286c7f62 (diff)
parentaf625b8b19567ff8618ab9f0a0ba76c086a5042f (diff)
downloadironic-bb75894ba2de508a9eab9ac766f16d8f23bf3a50.tar.gz
Merge "Fix VM stuck when deploying with pxe_ssh + local boot"
-rw-r--r--ironic/drivers/modules/iscsi_deploy.py12
-rw-r--r--ironic/tests/drivers/test_iscsi_deploy.py25
2 files changed, 37 insertions, 0 deletions
diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py
index 411ceda2b..1f3234b74 100644
--- a/ironic/drivers/modules/iscsi_deploy.py
+++ b/ironic/drivers/modules/iscsi_deploy.py
@@ -26,7 +26,9 @@ from ironic.common.i18n import _LE
from ironic.common.i18n import _LI
from ironic.common import image_service as service
from ironic.common import keystone
+from ironic.common import states
from ironic.common import utils
+from ironic.conductor import utils as manager_utils
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules import image_cache
from ironic.drivers import utils as driver_utils
@@ -613,5 +615,15 @@ def finish_deploy(task, address):
deploy_utils.set_failed_state(task, msg)
raise exception.InstanceDeployFailure(msg)
+ # TODO(lucasagomes): When deploying a node with the DIB ramdisk
+ # Ironic will not power control the node at the end of the deployment,
+ # it's the DIB ramdisk that reboots the node. But, for the SSH driver
+ # some changes like setting the boot device only gets applied when the
+ # machine is powered off and on again. So the code below is enforcing
+ # it. For Liberty we need to change the DIB ramdisk so that Ironic
+ # always controls the power state of the node for all drivers.
+ if get_boot_option(node) == "local" and 'ssh' in node.driver:
+ manager_utils.node_power_action(task, states.REBOOT)
+
LOG.info(_LI('Deployment to node %s done'), node.uuid)
task.process_event('done')
diff --git a/ironic/tests/drivers/test_iscsi_deploy.py b/ironic/tests/drivers/test_iscsi_deploy.py
index 70bc3b765..a0b1f40ba 100644
--- a/ironic/tests/drivers/test_iscsi_deploy.py
+++ b/ironic/tests/drivers/test_iscsi_deploy.py
@@ -868,3 +868,28 @@ class IscsiDeployMethodsTestCase(db_base.DbTestCase):
self.assertRaises(exception.InstanceDeployFailure,
iscsi_deploy.finish_deploy, task, '1.2.3.4')
set_fail_state_mock.assert_called_once_with(task, mock.ANY)
+
+ @mock.patch.object(manager_utils, 'node_power_action')
+ @mock.patch.object(deploy_utils, 'notify_ramdisk_to_proceed',
+ autospec=True)
+ def test_finish_deploy_ssh_with_local_boot(self, notify_mock,
+ node_power_mock):
+ instance_info = dict(INST_INFO_DICT)
+ instance_info['capabilities'] = {'boot_option': 'local'}
+ n = {
+ 'uuid': uuidutils.generate_uuid(),
+ 'driver': 'fake_ssh',
+ 'instance_info': instance_info,
+ 'provision_state': states.DEPLOYING,
+ 'target_provision_state': states.ACTIVE,
+ }
+ mgr_utils.mock_the_extension_manager(driver="fake_ssh")
+ node = obj_utils.create_test_node(self.context, **n)
+
+ with task_manager.acquire(self.context, node.uuid,
+ shared=False) as task:
+ iscsi_deploy.finish_deploy(task, '1.2.3.4')
+ notify_mock.assert_called_once_with('1.2.3.4')
+ self.assertEqual(states.ACTIVE, task.node.provision_state)
+ self.assertEqual(states.NOSTATE, task.node.target_provision_state)
+ node_power_mock.assert_called_once_with(task, states.REBOOT)