Handle instances being missing while listing floating IPs

This resolves bug 964950, which is a nova-manage crash while
listing floating IPs when an instance has gone missing.

Change-Id: Ib628356608bc0cbb9089029876ab1df7e9f02531
This commit is contained in:
Michael Still 2012-03-26 14:37:48 +11:00 committed by Vishvananda Ishaya
parent 3842f2f7bd
commit 37dad352a1

View File

@ -680,8 +680,13 @@ class FloatingIpCommands(object):
instance_id = None
if floating_ip['fixed_ip_id']:
fixed_ip = db.fixed_ip_get(ctxt, floating_ip['fixed_ip_id'])
instance = db.instance_get(ctxt, fixed_ip['instance_id'])
instance_id = instance.get('uuid', "none")
try:
instance = db.instance_get(ctxt, fixed_ip['instance_id'])
instance_id = instance.get('uuid', "none")
except exception.InstanceNotFound:
msg = _('Missing instance %s')
instance_id = msg % fixed_ip['instance_id']
print "%s\t%s\t%s\t%s\t%s" % (floating_ip['project_id'],
floating_ip['address'],
instance_id,