diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-31 04:15:07 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-31 04:15:07 +0000 |
| commit | 2a8b3d8f430ffb5e839d7b3800426a4f75c5f22b (patch) | |
| tree | b3d952a442a50a0b0bd4b7382ac7be64e0f0348d | |
| parent | dc65ed42db79d242cbcdf4beb7a287be0fc707b6 (diff) | |
| parent | 697f2bddf0e21368c69f13d0ec4e43df17d7f330 (diff) | |
Merge "Send a full instance in rescue_instance."
| -rw-r--r-- | nova/compute/manager.py | 31 | ||||
| -rw-r--r-- | nova/compute/rpcapi.py | 8 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 4 | ||||
| -rw-r--r-- | nova/tests/compute/test_rpcapi.py | 7 |
4 files changed, 30 insertions, 20 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index e23db6812..09c82035f 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -272,7 +272,7 @@ def _get_image_meta(context, image_ref): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '1.26' + RPC_API_VERSION = '1.27' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -1320,28 +1320,33 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @checks_instance_lock @wrap_instance_fault - def rescue_instance(self, context, instance_uuid, **kwargs): + def rescue_instance(self, context, instance=None, instance_uuid=None, + rescue_password=None): """ Rescue an instance on this host. :param rescue_password: password to set on rescue instance """ - - LOG.audit(_('Rescuing'), context=context, instance_uuid=instance_uuid) context = context.elevated() + if not instance: + instance = self.db.instance_get_by_uuid(context, instance_uuid) - instance_ref = self.db.instance_get_by_uuid(context, instance_uuid) - instance_ref.admin_pass = kwargs.get('rescue_password', - utils.generate_password(FLAGS.password_length)) - network_info = self._get_instance_nw_info(context, instance_ref) - image_meta = _get_image_meta(context, instance_ref['image_ref']) + LOG.audit(_('Rescuing'), context=context, instance=instance) - with self.error_out_instance_on_exception(context, instance_uuid): - self.driver.rescue(context, instance_ref, + admin_pass = (rescue_password if rescue_password else + utils.generate_password(FLAGS.password_length)) + self.db.instance_update(context, instance['uuid'], + dict(admin_pass=admin_pass)) + + network_info = self._get_instance_nw_info(context, instance) + image_meta = _get_image_meta(context, instance['image_ref']) + + with self.error_out_instance_on_exception(context, instance['uuid']): + self.driver.rescue(context, instance, self._legacy_nw_info(network_info), image_meta) - current_power_state = self._get_power_state(context, instance_ref) + current_power_state = self._get_power_state(context, instance) self._instance_update(context, - instance_uuid, + instance['uuid'], vm_state=vm_states.RESCUED, task_state=None, power_state=current_power_state) diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index d7cc3e2b9..d79cb0bba 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -96,6 +96,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): remove_fixed_ip_from_instance() 1.26 - Remove instance_id, add instance argument to remove_volume_connection() + 1.27 - Remove instance_uuid, add instance argument to + rescue_instance() ''' BASE_RPC_API_VERSION = '1.0' @@ -344,10 +346,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): version='1.26') def rescue_instance(self, ctxt, instance, rescue_password): + instance_p = jsonutils.to_primitive(instance) self.cast(ctxt, self.make_msg('rescue_instance', - instance_uuid=instance['uuid'], + instance=instance_p, rescue_password=rescue_password), - topic=_compute_topic(self.topic, ctxt, None, instance)) + topic=_compute_topic(self.topic, ctxt, None, instance), + version='1.27') def reset_network(self, ctxt, instance): self.cast(ctxt, self.make_msg('reset_network', diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 27f0eb565..de02a9d85 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -441,10 +441,10 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(nova.virt.fake.FakeDriver, 'unrescue', fake_unrescue) - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) instance_uuid = instance['uuid'] self.compute.run_instance(self.context, instance_uuid) - self.compute.rescue_instance(self.context, instance_uuid) + self.compute.rescue_instance(self.context, instance=instance) self.assertTrue(called['rescued']) self.compute.unrescue_instance(self.context, instance_uuid) self.assertTrue(called['unrescued']) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index edfbc309b..27d379eed 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -58,8 +58,8 @@ class ComputeRpcAPITestCase(test.TestCase): 'post_live_migration_at_destination', 'power_off_instance', 'power_on_instance', 'pre_live_migration', 'reboot_instance', 'rebuild_instance', 'remove_fixed_ip_from_instance', - 'remove_volume_connection', 'start_instance', 'stop_instance', - 'suspend_instance', 'unpause_instance' + 'remove_volume_connection', 'rescue_instance', 'start_instance', + 'stop_instance', 'suspend_instance', 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -266,7 +266,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_rescue_instance(self): self._test_compute_api('rescue_instance', 'cast', - instance=self.fake_instance, rescue_password='pw') + instance=self.fake_instance, rescue_password='pw', + version='1.27') def test_reset_network(self): self._test_compute_api('reset_network', 'cast', |
