From 6222385d837f90f769c94f21d003999741c4f800 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Fri, 29 Jun 2012 17:17:04 -0500 Subject: Get hypervisor uptime. Adds a call to retrieve the current uptime on a specific hypervisor. This version of the patch only adds the XenAPI variant; other virt drivers will raise a NotImplementedError until they implement the get_host_uptime() method. Change-Id: Ie259589757a460fcd91a49a8dd8099e4d91524e7 --- nova/compute/api.py | 6 ++++++ nova/compute/manager.py | 7 ++++++- nova/compute/rpcapi.py | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 557dbb930..504ed4eec 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1654,6 +1654,12 @@ class HostAPI(base.Base): return self.compute_rpcapi.set_host_enabled(context, enabled=enabled, host=host) + def get_host_uptime(self, context, host): + """Returns the result of calling "uptime" on the target host.""" + # NOTE(comstud): No instance_uuid argument to this compute manager + # call + return self.compute_rpcapi.get_host_uptime(context, host=host) + def host_power_action(self, context, host, action): """Reboots, shuts down or powers up the host.""" # NOTE(comstud): No instance_uuid argument to this compute manager diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 3cdf35266..e9fbb4e20 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -228,7 +228,7 @@ def _get_additional_capabilities(): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '1.0' + RPC_API_VERSION = '1.1' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -1592,6 +1592,11 @@ class ComputeManager(manager.SchedulerDependentManager): """Sets the specified host's ability to accept new instances.""" return self.driver.set_host_enabled(host, enabled) + @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) + def get_host_uptime(self, context, host): + """Returns the result of calling "uptime" on the target host.""" + return self.driver.get_host_uptime(host) + @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @wrap_instance_fault def get_diagnostics(self, context, instance_uuid): diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 7a531fcf5..116b2d34b 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -54,9 +54,10 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): API version history: 1.0 - Initial version. + 1.1 - Adds get_host_uptime() ''' - RPC_API_VERSION = '1.0' + RPC_API_VERSION = '1.1' def __init__(self): super(ComputeAPI, self).__init__(topic=FLAGS.compute_topic, @@ -313,6 +314,10 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): return self.call(ctxt, self.make_msg('set_host_enabled', enabled=enabled), topic) + def get_host_uptime(self, ctxt, host): + topic = _compute_topic(self.topic, ctxt, host, None) + return self.call(ctxt, self.make_msg('get_host_uptime'), topic) + def snapshot_instance(self, ctxt, instance, image_id, image_type, backup_type, rotation): self.cast(ctxt, self.make_msg('snapshot_instance', -- cgit