summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-07-20 10:56:29 -0400
committerRussell Bryant <rbryant@redhat.com>2012-07-25 19:52:14 -0400
commit6aac5f1308aa3e360204bd8f4dcfe90522f6db2e (patch)
tree46bb6eb0f526145fbf4f67e7b6544c5dc833c05e /nova/compute
parentd030e29f5b0ba215789739e443f25ca1c80bc3da (diff)
Convert reboot_instance to take a full instance.
Convert the reboot_instance method in the compute rpc API to take a full instance via 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: Id2c455f66966a9b446e5bbbe542ed3a2b0655289
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py14
-rw-r--r--nova/compute/rpcapi.py8
2 files changed, 13 insertions, 9 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 3e66bd20f..067bc584b 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -297,7 +297,7 @@ def _get_additional_capabilities():
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.3'
+ RPC_API_VERSION = '1.4'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -1090,18 +1090,19 @@ class ComputeManager(manager.SchedulerDependentManager):
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
@wrap_instance_fault
- def reboot_instance(self, context, instance_uuid, reboot_type="SOFT"):
+ def reboot_instance(self, context, instance=None, instance_uuid=None,
+ reboot_type="SOFT"):
"""Reboot an instance on this host."""
LOG.audit(_("Rebooting instance"), context=context,
instance_uuid=instance_uuid)
context = context.elevated()
- instance = self.db.instance_get_by_uuid(context, instance_uuid)
+ if not instance:
+ instance = self.db.instance_get_by_uuid(context, instance_uuid)
self._notify_about_instance_usage(context, instance, "reboot.start")
current_power_state = self._get_power_state(context, instance)
- self._instance_update(context,
- instance_uuid,
+ self._instance_update(context, instance['uuid'],
power_state=current_power_state,
vm_state=vm_states.ACTIVE)
@@ -1125,8 +1126,7 @@ class ComputeManager(manager.SchedulerDependentManager):
# Fall through and reset task_state to None
current_power_state = self._get_power_state(context, instance)
- self._instance_update(context,
- instance_uuid,
+ self._instance_update(context, instance['uuid'],
power_state=current_power_state,
vm_state=vm_states.ACTIVE,
task_state=None)
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index e637c9f64..296ee476c 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -20,6 +20,7 @@ Client side of the compute RPC API.
from nova import exception
from nova import flags
+from nova.openstack.common import jsonutils
from nova.openstack.common import rpc
from nova.openstack.common.rpc import common as rpc_common
import nova.openstack.common.rpc.proxy
@@ -58,6 +59,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.1 - Adds get_host_uptime()
1.2 - Adds check_can_live_migrate_[destination|source]
1.3 - Adds change_instance_metadata()
+ 1.4 - Remove instance_uuid, add instance argument to reboot_instance()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -235,9 +237,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
disk=disk), _compute_topic(self.topic, ctxt, host, None))
def reboot_instance(self, ctxt, instance, reboot_type):
+ instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('reboot_instance',
- instance_uuid=instance['uuid'], reboot_type=reboot_type),
- topic=_compute_topic(self.topic, ctxt, None, instance))
+ instance=instance_p, reboot_type=reboot_type),
+ topic=_compute_topic(self.topic, ctxt, None, instance),
+ version='1.4')
def rebuild_instance(self, ctxt, instance, new_pass, injected_files,
image_ref, orig_image_ref):