diff options
| author | Brian Waldon <brian.waldon@rackspace.com> | 2011-08-21 22:59:46 -0400 |
|---|---|---|
| committer | Brian Waldon <brian.waldon@rackspace.com> | 2011-08-21 22:59:46 -0400 |
| commit | 34e310eff24b96bcc27df176bfecbd02ac863e7c (patch) | |
| tree | 476e4ea2180fdb7da0ae749ddc131ebecaba9923 /nova/api | |
| parent | 271817cdce37c55f29bb9782429ee8b6ad57364e (diff) | |
| download | nova-34e310eff24b96bcc27df176bfecbd02ac863e7c.tar.gz nova-34e310eff24b96bcc27df176bfecbd02ac863e7c.tar.xz nova-34e310eff24b96bcc27df176bfecbd02ac863e7c.zip | |
fixing bug lp:830817
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/views/addresses.py | 26 | ||||
| -rw-r--r-- | nova/api/openstack/wsgi.py | 6 |
2 files changed, 26 insertions, 6 deletions
diff --git a/nova/api/openstack/views/addresses.py b/nova/api/openstack/views/addresses.py index ddbf7a144..05028db41 100644 --- a/nova/api/openstack/views/addresses.py +++ b/nova/api/openstack/views/addresses.py @@ -15,11 +15,15 @@ # License for the specific language governing permissions and limitations # under the License. +import traceback + from nova import flags from nova import utils +from nova import log as logging from nova.api.openstack import common FLAGS = flags.FLAGS +LOG = logging.getLogger('nova.api.openstack.views.addresses') class ViewBuilder(object): @@ -48,7 +52,11 @@ class ViewBuilderV11(ViewBuilder): def build(self, interfaces): networks = {} for interface in interfaces: - network_label = interface['network']['label'] + try: + network_label = self._extract_network_label(interface) + except TypeError: + LOG.error(traceback.format_exc()) + continue if network_label not in networks: networks[network_label] = [] @@ -64,9 +72,14 @@ class ViewBuilderV11(ViewBuilder): return networks - def build_network(self, interfaces, network_label): + def build_network(self, interfaces, requested_network): for interface in interfaces: - if interface['network']['label'] == network_label: + try: + network_label = self._extract_network_label(interface) + except TypeError: + continue + + if network_label == requested_network: ips = list(self._extract_ipv4_addresses(interface)) ipv6 = self._extract_ipv6_address(interface) if ipv6 is not None: @@ -74,6 +87,13 @@ class ViewBuilderV11(ViewBuilder): return {network_label: ips} return None + def _extract_network_label(self, interface): + try: + return interface['network']['label'] + except (TypeError, KeyError): + LOG.error(traceback.format_exc()) + raise TypeError + def _extract_ipv4_addresses(self, interface): for fixed_ip in interface['fixed_ips']: yield self._build_ip_entity(fixed_ip['address'], 4) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 0eb47044e..c2185ebfd 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -516,6 +516,6 @@ class Resource(wsgi.Application): controller_method = getattr(self.controller, action) try: return controller_method(req=request, **action_args) - except TypeError, exc: - LOG.debug(str(exc)) - return webob.exc.HTTPBadRequest() + except TypeError: + LOG.debug(traceback.format_exc()) + return faults.Fault(webob.exc.HTTPBadRequest()) |
