diff options
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/metadata/handler.py | 17 |
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'] |
