summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-05-15 10:54:13 -0400
committerDan Prince <dprince@redhat.com>2012-05-15 11:31:25 -0400
commitcdcb64f045764017a7fba4d86207e2ec30a957f9 (patch)
tree3255c0b4c398a922e2d13ec799470328090ea5a9 /nova
parent8823f7bef2142a807b3c92e512f602b6b415a3e2 (diff)
downloadnova-cdcb64f045764017a7fba4d86207e2ec30a957f9.tar.gz
nova-cdcb64f045764017a7fba4d86207e2ec30a957f9.tar.xz
nova-cdcb64f045764017a7fba4d86207e2ec30a957f9.zip
Implement get_hypervisor_hostname for libvirt.
Implements get_hypervisor_hostname so that the OS-EXT-SRV-ATTR:hypervisor_hostname extension can properly display this information when using libvirt. Fixes LP Bug #999729. Change-Id: I124d48ca352dc225f88999046f9d212ffb9e4c6e
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/fakelibvirt.py3
-rw-r--r--nova/tests/test_libvirt.py4
-rw-r--r--nova/virt/libvirt/connection.py6
3 files changed, 13 insertions, 0 deletions
diff --git a/nova/tests/fakelibvirt.py b/nova/tests/fakelibvirt.py
index 5a317dca1..693330408 100644
--- a/nova/tests/fakelibvirt.py
+++ b/nova/tests/fakelibvirt.py
@@ -507,6 +507,9 @@ class Connection(object):
def getVersion(self):
return 14000
+ def getHostname(self):
+ return 'compute1'
+
def getCapabilities(self):
return '''<capabilities>
<host>
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index b0b165c70..426246fe3 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -1695,6 +1695,9 @@ class HostStateTestCase(test.TestCase):
def get_hypervisor_version(self):
return 13091
+ def get_hypervisor_hostname(self):
+ return 'compute1'
+
def get_disk_available_least(self):
return 13091
@@ -1721,6 +1724,7 @@ class HostStateTestCase(test.TestCase):
self.assertEquals(stats["host_memory_free"], 409)
self.assertEquals(stats["hypervisor_type"], 'QEMU')
self.assertEquals(stats["hypervisor_version"], 13091)
+ self.assertEquals(stats["hypervisor_hostname"], 'compute1')
class NWFilterFakes:
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index a5c65ff04..507fea973 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -1964,6 +1964,10 @@ class LibvirtConnection(driver.ComputeDriver):
return method()
+ def get_hypervisor_hostname(self):
+ """Returns the hostname of the hypervisor."""
+ return self._conn.getHostname()
+
def get_cpu_info(self):
"""Get cpuinfo information.
@@ -2075,6 +2079,7 @@ class LibvirtConnection(driver.ComputeDriver):
'local_gb_used': self.get_local_gb_used(),
'hypervisor_type': self.get_hypervisor_type(),
'hypervisor_version': self.get_hypervisor_version(),
+ 'hypervisor_hostname': self.get_hypervisor_hostname(),
'cpu_info': self.get_cpu_info(),
'service_id': service_ref['id'],
'disk_available_least': self.get_disk_available_least()}
@@ -2656,6 +2661,7 @@ class HostState(object):
self.connection.get_memory_mb_used())
data["hypervisor_type"] = self.connection.get_hypervisor_type()
data["hypervisor_version"] = self.connection.get_hypervisor_version()
+ data["hypervisor_hostname"] = self.connection.get_hypervisor_hostname()
self._stats = data