summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJustin Santa Barbara <justin@fathomdb.com>2011-02-18 17:27:25 -0800
committerJustin Santa Barbara <justin@fathomdb.com>2011-02-18 17:27:25 -0800
commitaeab8eeb038ca1d1dde05705028144a78552c4f7 (patch)
treeefbcd7186db801a77c0b83bd90c236a799016faf /nova/api
parent5dfa5ce7d1374509fea51f8d0b132ea865f34dc6 (diff)
downloadnova-aeab8eeb038ca1d1dde05705028144a78552c4f7.tar.gz
nova-aeab8eeb038ca1d1dde05705028144a78552c4f7.tar.xz
nova-aeab8eeb038ca1d1dde05705028144a78552c4f7.zip
Don't crash if there's no 'fixed_ip' attribute (was returning None, which was unsubscriptable)
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/servers.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 486eca508..b54e28c0c 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -63,20 +63,22 @@ def _translate_detail_keys(inst):
inst_dict['status'] = power_mapping[inst_dict['status']]
inst_dict['addresses'] = dict(public=[], private=[])
- # grab single private fixed ip
- try:
- private_ip = inst['fixed_ip']['address']
- if private_ip:
- inst_dict['addresses']['private'].append(private_ip)
- except KeyError:
- LOG.debug(_("Failed to read private ip"))
-
- # grab all public floating ips
- try:
- for floating in inst['fixed_ip']['floating_ips']:
- inst_dict['addresses']['public'].append(floating['address'])
- except KeyError:
- LOG.debug(_("Failed to read public ip(s)"))
+ fixed_ip = inst['fixed_ip']
+ if fixed_ip:
+ # grab single private fixed ip
+ try:
+ private_ip = fixed_ip['address']
+ if private_ip:
+ inst_dict['addresses']['private'].append(private_ip)
+ except KeyError:
+ LOG.debug(_("Failed to read private ip"))
+
+ # grab all public floating ips
+ try:
+ for floating in fixed_ip['floating_ips']:
+ inst_dict['addresses']['public'].append(floating['address'])
+ except KeyError:
+ LOG.debug(_("Failed to read public ip(s)"))
inst_dict['metadata'] = {}
inst_dict['hostId'] = ''