diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-04-09 22:11:10 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-04-10 13:31:33 -0700 |
| commit | a0e37c6d29c57cde416b047cd38c93b6a9588005 (patch) | |
| tree | a714cd2a1ccff01191395c91c99a619cf092a7cc /nova/api | |
| parent | 7a1957dfe91011510d34b849fadbb973b53d0414 (diff) | |
| download | nova-a0e37c6d29c57cde416b047cd38c93b6a9588005.tar.gz nova-a0e37c6d29c57cde416b047cd38c93b6a9588005.tar.xz nova-a0e37c6d29c57cde416b047cd38c93b6a9588005.zip | |
Fix errors in os-networks extension
* Makes sure the uuid is returned as id if it exists
* Simplifies db get for manager.get_networks
* Removes direct db access from manager which was breaking test
* Updates tests to verify the new logic
* Makes sure Remote NotFounds are turned into 404s
(The RemoteError blocks can be removed once
https://review.openstack.org/5749 lands)
* Fixes bug 977712
* Fixes bug 977723
Change-Id: I6aa815960782c7ae5165aeebd83bdaaa62c19b04
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/networks.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/networks.py b/nova/api/openstack/compute/contrib/networks.py index cc838ab45..3da8964b0 100644 --- a/nova/api/openstack/compute/contrib/networks.py +++ b/nova/api/openstack/compute/contrib/networks.py @@ -24,6 +24,7 @@ from nova import exception from nova import flags from nova import log as logging import nova.network.api +from nova.rpc import common FLAGS = flags.FLAGS @@ -40,7 +41,10 @@ def network_dict(network): 'netmask', 'injected', 'cidr', 'vpn_public_address', 'multi_host', 'dns1', 'host', 'gateway_v6', 'netmask_v6', 'created_at') - return dict((field, network[field]) for field in fields) + result = dict((field, network[field]) for field in fields) + if 'uuid' in network: + result['id'] = network['uuid'] + return result else: return {} @@ -72,6 +76,11 @@ class NetworkController(object): self.network_api.disassociate(context, network_id) except exception.NetworkNotFound: raise exc.HTTPNotFound(_("Network not found")) + except common.RemoteError as ex: + if ex.exc_type in ["NetworkNotFound", "NetworkNotFoundForUUID"]: + raise exc.HTTPNotFound(_("Network not found")) + else: + raise return exc.HTTPAccepted() def index(self, req): @@ -89,6 +98,11 @@ class NetworkController(object): network = self.network_api.get(context, id) except exception.NetworkNotFound: raise exc.HTTPNotFound(_("Network not found")) + except common.RemoteError as ex: + if ex.exc_type in ["NetworkNotFound", "NetworkNotFoundForUUID"]: + raise exc.HTTPNotFound(_("Network not found")) + else: + raise return {'network': network_dict(network)} def delete(self, req, id): @@ -99,6 +113,11 @@ class NetworkController(object): self.network_api.delete(context, id) except exception.NetworkNotFound: raise exc.HTTPNotFound(_("Network not found")) + except common.RemoteError as ex: + if ex.exc_type in ["NetworkNotFound", "NetworkNotFoundForUUID"]: + raise exc.HTTPNotFound(_("Network not found")) + else: + raise return exc.HTTPAccepted() def create(self, req, id, body=None): |
