summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-02-18 00:52:54 +0000
committerGerrit Code Review <review@openstack.org>2012-02-18 00:52:54 +0000
commitc0f1227c7bc0a57e4ccf228444f7a16f8a57f8de (patch)
treea5adf82e61bf9c3e3999cabadab5582e4edc8280 /nova/api
parent0a955186f295dddde1b70b5944464a70fe2cdcaf (diff)
parent5d3dbb4127785c77604602cd1737b75e30126b6e (diff)
Merge "Query directly for just the ip"
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']