fixed list warn when ip allocated to missing inst.

Update 'nova-manage fixed list' so it prints a warning if an IP
is allocated to a deleted/missing instance.

Fixes LP Bug #953685.

Change-Id: I72b7ad2cb01e31cf9bb6cab904ab10d8769a3526
This commit is contained in:
Dan Prince 2012-03-12 23:52:40 -04:00
parent fd80f1b2e1
commit da23487487

View File

@ -584,9 +584,13 @@ class FixedIpCommands(object):
network = db.network_get(context.get_admin_context(),
fixed_ip['network_id'])
if fixed_ip['instance_id']:
instance = instances_by_id[fixed_ip['instance_id']]
hostname = instance['hostname']
host = instance['host']
instance = instances_by_id.get(fixed_ip['instance_id'])
if instance:
hostname = instance['hostname']
host = instance['host']
else:
print 'WARNING: fixed ip %s allocated to missing' \
' instance' % str(fixed_ip['address'])
print "%-18s\t%-15s\t%-15s\t%s" % (
network['cidr'],
fixed_ip['address'],