summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJason Kölker <jason@koelker.net>2012-02-17 11:07:40 -0600
committerJason Kölker <jason@koelker.net>2012-02-17 16:52:09 -0600
commit5d3dbb4127785c77604602cd1737b75e30126b6e (patch)
treec55ff0f23ddde2e488beb952166456f1ae72d4f8 /nova/api
parent9c1baff7467ac85fb912dedb580db8c244375e0e (diff)
Query directly for just the ip
* Fixes LP934356 Change-Id: I99b1501b1ef86eafb89fe9416f2668e4325a3656
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/metadata/handler.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/nova/api/metadata/handler.py b/nova/api/metadata/handler.py
index 4b47f7b70..99831fcf8 100644
--- a/nova/api/metadata/handler.py
+++ b/nova/api/metadata/handler.py
@@ -71,8 +71,9 @@ class MetadataRequestHandler(wsgi.Application):
"""Serve metadata."""
def __init__(self):
+ self.network_api = network.API()
self.compute_api = compute.API(
- network_api=network.API(),
+ network_api=self.network_api,
volume_api=volume.API())
def _get_mpi_data(self, context, project_id):
@@ -139,20 +140,16 @@ class MetadataRequestHandler(wsgi.Application):
return mappings
def get_metadata(self, address):
+ if not address:
+ raise exception.FixedIpNotFoundForAddress(address=address)
+
ctxt = context.get_admin_context()
- search_opts = {'fixed_ip': address, 'deleted': False}
try:
- instance_ref = self.compute_api.get_all(ctxt,
- search_opts=search_opts)
+ fixed_ip = self.network_api.get_fixed_ip_by_address(ctxt, address)
+ instance_ref = db.instance_get(ctxt, fixed_ip['instance_id'])
except exception.NotFound:
- instance_ref = None
- if not instance_ref:
return None
- # This ensures that all attributes of the instance
- # are populated.
- instance_ref = db.instance_get(ctxt, instance_ref[0]['id'])
-
mpi = self._get_mpi_data(ctxt, instance_ref['project_id'])
hostname = "%s.%s" % (instance_ref['hostname'], FLAGS.dhcp_domain)
host = instance_ref['host']