From a28d8e17d9a482b1c473e2deab6083a903cbf204 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 18 Feb 2013 16:06:35 -0800 Subject: Fix network list and show with quantum. The quantum driver was returning data in a format that was not compatible with the extension. This munges the data and handles fields that don't exist so the extensions still work. Fixes bug 1076519 Change-Id: I5e00bfa72e8ce1d486f9aa4dddbe1080ff74cd6a --- nova/api/openstack/compute/contrib/os_networks.py | 2 +- nova/api/openstack/compute/contrib/os_tenant_networks.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/os_networks.py b/nova/api/openstack/compute/contrib/os_networks.py index d1d172686..bef2c3d1f 100644 --- a/nova/api/openstack/compute/contrib/os_networks.py +++ b/nova/api/openstack/compute/contrib/os_networks.py @@ -46,7 +46,7 @@ def network_dict(context, network): # are only visible if they are an admin. if context.is_admin: fields += admin_fields - result = dict((field, network[field]) for field in fields) + result = dict((field, network.get(field)) for field in fields) if 'uuid' in network: result['id'] = network['uuid'] return result diff --git a/nova/api/openstack/compute/contrib/os_tenant_networks.py b/nova/api/openstack/compute/contrib/os_tenant_networks.py index 03178ab65..5b4e7f5ea 100644 --- a/nova/api/openstack/compute/contrib/os_tenant_networks.py +++ b/nova/api/openstack/compute/contrib/os_tenant_networks.py @@ -64,9 +64,9 @@ authorize = extensions.extension_authorizer('compute', 'os-tenant-networks') def network_dict(network): - return {"id": network.get("uuid") or network["id"], - "cidr": network["cidr"], - "label": network["label"]} + return {"id": network.get("uuid") or network.get("id"), + "cidr": network.get("cidr"), + "label": network.get("label")} class NetworkController(object): @@ -108,7 +108,7 @@ class NetworkController(object): network = self.network_api.get(context, id) except exception.NetworkNotFound: raise exc.HTTPNotFound(_("Network not found")) - return network_dict(network) + return {'network': network_dict(network)} def delete(self, req, id): context = req.environ['nova.context'] -- cgit