Fix Load Balancer table Subnet row displays CIDR
Now the Load Balancer table Subnet row displays the CIDR, the better solution is that both the Subnet Name and the CIDR should be displayed. Change-Id: Id64fa7a33f2ebd76e1e9abd96a0ba092fd9959e1 Closes-Bug: #1495188
This commit is contained in:
parent
fc64d3b191
commit
2f059f2548
@ -173,8 +173,7 @@ def _pool_list(request, expand_subnet=False, expand_vip=False, **kwargs):
|
||||
subnets = neutron.subnet_list(request)
|
||||
subnet_dict = OrderedDict((s.id, s) for s in subnets)
|
||||
for p in pools:
|
||||
subnet = subnet_dict.get(p['subnet_id'])
|
||||
p['subnet_name'] = subnet.cidr if subnet else None
|
||||
p['subnet'] = subnet_dict.get(p['subnet_id'])
|
||||
if expand_vip:
|
||||
vips = vip_list(request)
|
||||
vip_dict = OrderedDict((v.id, v) for v in vips)
|
||||
|
@ -434,6 +434,15 @@ def get_vip_name(pool):
|
||||
return None
|
||||
|
||||
|
||||
def get_subnet(pool):
|
||||
if hasattr(pool, "subnet") and pool.subnet:
|
||||
template_name = 'project/loadbalancers/_pool_table_subnet_cell.html'
|
||||
context = {"subnet": pool.subnet}
|
||||
return template.loader.render_to_string(template_name, context)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class PoolsTable(tables.DataTable):
|
||||
METHOD_DISPLAY_CHOICES = (
|
||||
("round_robin", pgettext_lazy("load balancing method",
|
||||
@ -450,7 +459,7 @@ class PoolsTable(tables.DataTable):
|
||||
description = tables.Column('description', verbose_name=_("Description"))
|
||||
provider = tables.Column('provider', verbose_name=_("Provider"),
|
||||
filters=(lambda v: filters.default(v, _('N/A')),))
|
||||
subnet_name = tables.Column('subnet_name', verbose_name=_("Subnet"))
|
||||
subnet_name = tables.Column(get_subnet, verbose_name=_("Subnet"))
|
||||
protocol = tables.Column('protocol', verbose_name=_("Protocol"))
|
||||
method = tables.Column('lb_method',
|
||||
verbose_name=_("LB Method"),
|
||||
|
@ -0,0 +1,8 @@
|
||||
<ul>
|
||||
<li>
|
||||
{% if subnet.name|length > 0 %}
|
||||
<b>{{ subnet.name }}</b>
|
||||
{% endif %}
|
||||
{{ subnet.cidr }}
|
||||
</li>
|
||||
</ul>
|
Loading…
Reference in New Issue
Block a user