summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-07-27 15:13:39 -0400
committerRussell Bryant <rbryant@redhat.com>2012-07-30 20:18:38 -0400
commit697f2bddf0e21368c69f13d0ec4e43df17d7f330 (patch)
tree5c07846e8750cd92ca4ab0b4f4294d81c58635ec /nova/compute
parent73af6fa9722b720923002f62e115d84b74c9fe33 (diff)
Send a full instance in rescue_instance.
Change the rescue_instance method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: I559bd45a8dda4537f6f4a3b8d744095291c7f058
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py31
-rw-r--r--nova/compute/rpcapi.py8
2 files changed, 24 insertions, 15 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',