Fix displaying pool name for floating ip

It fixes an issue when pool name is not
displayed for floating ip in a case when any
floating ip is not associated with an instance.

Change-Id: Ic20ec3709fa7c5313f59a16aa32b975eb004f753
Closes-Bug: #1716431
This commit is contained in:
Max Yatsenko 2017-10-01 20:14:22 +03:00
parent 9adb636437
commit aec3a33a22

View File

@ -112,6 +112,7 @@ class IndexView(tables.DataTableView):
attached_instance_ids = [ip.instance_id for ip in floating_ips
if ip.instance_id is not None]
instances_dict = {}
if attached_instance_ids:
instances = []
try:
@ -125,8 +126,8 @@ class IndexView(tables.DataTableView):
instances_dict = dict([(obj.id, obj.name) for obj in instances])
for ip in floating_ips:
ip.instance_name = instances_dict.get(ip.instance_id)
ip.pool_name = pool_dict.get(ip.pool, ip.pool)
for ip in floating_ips:
ip.instance_name = instances_dict.get(ip.instance_id)
ip.pool_name = pool_dict.get(ip.pool, ip.pool)
return floating_ips