summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2013-02-18 16:06:35 -0800
committerVishvananda Ishaya <vishvananda@gmail.com>2013-02-18 16:06:35 -0800
commita28d8e17d9a482b1c473e2deab6083a903cbf204 (patch)
tree05ba15eb23b884649ee12f2717f3c4c12626160a
parentb23c557cc8d03028caba95777f98adfe9b1031d9 (diff)
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
-rw-r--r--nova/api/openstack/compute/contrib/os_networks.py2
-rw-r--r--nova/api/openstack/compute/contrib/os_tenant_networks.py8
-rw-r--r--nova/network/quantumv2/api.py9
3 files changed, 12 insertions, 7 deletions
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']
diff --git a/nova/network/quantumv2/api.py b/nova/network/quantumv2/api.py
index ee4ceb9cd..60991600a 100644
--- a/nova/network/quantumv2/api.py
+++ b/nova/network/quantumv2/api.py
@@ -425,11 +425,16 @@ class API(base.Base):
def get_all(self, context):
client = quantumv2.get_client(context)
- return client.list_networks()
+ networks = client.list_networks().get('networks') or {}
+ for network in networks:
+ network['label'] = network['name']
+ return networks
def get(self, context, network_uuid):
client = quantumv2.get_client(context)
- return client.show_network(network_uuid)
+ network = client.show_network(network_uuid).get('network') or {}
+ network['label'] = network['name']
+ return network
def delete(self, context, network_uuid):
raise NotImplementedError()