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/virt/driver.py | 5 +++++ nova/virt/xenapi/connection.py | 4 ++++ nova/virt/xenapi/fake.py | 2 ++ nova/virt/xenapi/host.py | 5 +++++ 4 files changed, 16 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/driver.py b/nova/virt/driver.py index f7dfbf7cd..52e720801 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -548,6 +548,11 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() + def get_host_uptime(self, host): + """Returns the result of calling "uptime" on the target host.""" + # TODO(Vek): Need to pass context in for access to auth_token + raise NotImplementedError() + def plug_vifs(self, instance, network_info): """Plug VIFs into networks.""" # TODO(Vek): Need to pass context in for access to auth_token diff --git a/nova/virt/xenapi/connection.py b/nova/virt/xenapi/connection.py index 20f9745d2..3dd7ad971 100644 --- a/nova/virt/xenapi/connection.py +++ b/nova/virt/xenapi/connection.py @@ -474,6 +474,10 @@ class XenAPIDriver(driver.ComputeDriver): """Sets the specified host's ability to accept new instances.""" return self._host.set_host_enabled(host, enabled) + def get_host_uptime(self, host): + """Returns the result of calling "uptime" on the target host.""" + return self._host.get_host_uptime(host) + def host_maintenance_mode(self, host, mode): """Start/Stop host maintenance window. On start, it triggers guest VMs evacuation.""" diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 081d3c89e..2013e7184 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -522,6 +522,8 @@ class SessionBase(object): elif (plugin, method) == ('xenhost', 'set_host_enabled'): enabled = 'enabled' if _5.get('enabled') == 'true' else 'disabled' return jsonutils.dumps({"status": enabled}) + elif (plugin, method) == ('xenhost', 'host_uptime'): + return jsonutils.dumps({"uptime": "fake uptime"}) else: raise Exception('No simulation in host_call_plugin for %s,%s' % (plugin, method)) diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 7fe8a7b77..3fe5dc292 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -117,6 +117,11 @@ class Host(object): response = call_xenhost(self._session, "set_host_enabled", args) return response.get("status", response) + def get_host_uptime(self, _host): + """Returns the result of calling "uptime" on the target host.""" + response = call_xenhost(self._session, "host_uptime", {}) + return response.get("uptime", response) + class HostState(object): """Manages information about the XenServer host this compute -- cgit