diff options
author | Josh Kearney <josh@jk0.org> | 2012-02-23 15:01:30 -0600 |
---|---|---|
committer | Josh Kearney <josh@jk0.org> | 2012-02-23 15:08:11 -0600 |
commit | 3e157d586fddb1430f5cacc343fd158de4b803cc (patch) | |
tree | 585a9ba732d23649f565bbc47f84c639babbce95 /nova/virt/xenapi_conn.py | |
parent | d4199375078311961c2d65bb575556adf669e40f (diff) | |
download | nova-3e157d586fddb1430f5cacc343fd158de4b803cc.tar.gz |
Add hypervisor_hostname to compute_nodes table and use it in XenServer.
This ensures the dom0 hostname is available to the API even when dom0 is "offline."
Change-Id: I1230c1871606fadc30f63ed97b56d54e51fd8833
Diffstat (limited to 'nova/virt/xenapi_conn.py')
-rw-r--r-- | nova/virt/xenapi_conn.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index 85e94c4316..6fae558b5d 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -181,6 +181,8 @@ class XenAPIConnection(driver.ComputeDriver): self._initiator = None self._pool = pool.ResourcePool(self._session) + self._capture_dom0_hostname() + @property def host_state(self): if not self._host_state: @@ -194,6 +196,22 @@ class XenAPIConnection(driver.ComputeDriver): #e.g. to do session logout? pass + def _capture_dom0_hostname(self): + """Find dom0's hostname and log it to the DB.""" + ctxt = context.get_admin_context() + service = db.service_get_by_host_and_topic(ctxt, FLAGS.host, "compute") + + try: + compute_node = db.compute_node_get_for_service(ctxt, service["id"]) + except TypeError: + return + + host_stats = self.get_host_stats() + + db.compute_node_update(ctxt, compute_node["id"], + {"hypervisor_hostname": host_stats["host_hostname"]}, + auto_adjust=False) + def list_instances(self): """List VM instances""" return self._vmops.list_instances() @@ -390,7 +408,6 @@ class XenAPIConnection(driver.ComputeDriver): :param host: hostname that compute manager is currently running """ - try: service_ref = db.service_get_all_compute_by_host(ctxt, host)[0] except exception.NotFound: |