diff --git a/openstack_dashboard/api/lbaas.py b/openstack_dashboard/api/lbaas.py
index 63624c271e..5d3b5c8ff9 100644
--- a/openstack_dashboard/api/lbaas.py
+++ b/openstack_dashboard/api/lbaas.py
@@ -141,7 +141,7 @@ def pool_create(request, **kwargs):
return Pool(pool)
-def _get_vip(request, pool, vip_dict, expand_name_only=False):
+def _get_vip(request, pool, vip_dict):
if pool['vip_id'] is not None:
try:
if vip_dict:
@@ -152,8 +152,6 @@ def _get_vip(request, pool, vip_dict, expand_name_only=False):
messages.warning(request, _("Unable to get VIP for pool "
"%(pool)s.") % {"pool": pool["id"]})
vip = Vip({'id': pool['vip_id'], 'name': ''})
- if expand_name_only:
- vip = vip.name_or_id
return vip
else:
return None
@@ -175,8 +173,7 @@ def _pool_list(request, expand_subnet=False, expand_vip=False, **kwargs):
vips = vip_list(request)
vip_dict = SortedDict((v.id, v) for v in vips)
for p in pools:
- p['vip_name'] = _get_vip(request, p, vip_dict,
- expand_name_only=True)
+ p['vip'] = _get_vip(request, p, vip_dict)
return [Pool(p) for p in pools]
@@ -202,8 +199,7 @@ def _pool_get(request, pool_id, expand_resource=False):
except Exception:
messages.warning(request, _("Unable to get subnet for pool "
"%(pool)s.") % {"pool": pool_id})
- pool['vip'] = _get_vip(request, pool, vip_dict=None,
- expand_name_only=False)
+ pool['vip'] = _get_vip(request, pool, vip_dict=None)
try:
pool['members'] = _member_list(request, expand_pool=False,
pool_id=pool_id)
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tables.py b/openstack_dashboard/dashboards/project/loadbalancers/tables.py
index 762adabe99..8828a6f903 100644
--- a/openstack_dashboard/dashboards/project/loadbalancers/tables.py
+++ b/openstack_dashboard/dashboards/project/loadbalancers/tables.py
@@ -14,6 +14,7 @@
from django.core.urlresolvers import reverse
+from django import template
from django.template import defaultfilters as filters
from django.utils import http
from django.utils.translation import pgettext_lazy
@@ -220,14 +221,6 @@ class UpdateMonitorLink(policy.PolicyTargetMixin, tables.LinkAction):
return base_url
-def get_vip_link(pool):
- if pool.vip_id:
- return reverse("horizon:project:loadbalancers:vipdetails",
- args=(http.urlquote(pool.vip_id),))
- else:
- return None
-
-
class AddPMAssociationLink(policy.PolicyTargetMixin,
tables.LinkAction):
name = "addassociation"
@@ -273,9 +266,9 @@ class UpdatePoolsRow(tables.Row):
pool = api.lbaas.pool_get(request, pool_id)
try:
vip = api.lbaas.vip_get(request, pool.vip_id)
- pool.vip_name = vip.name
+ pool.vip = vip
except Exception:
- pool.vip_name = pool.vip_id
+ pass
try:
subnet = api.neutron.subnet_get(request, pool.subnet_id)
pool.subnet_name = subnet.cidr
@@ -311,6 +304,15 @@ STATUS_DISPLAY_CHOICES = (
)
+def get_vip_name(pool):
+ if hasattr(pool, "vip") and pool.vip:
+ template_name = 'project/loadbalancers/_pool_table_vip_cell.html'
+ context = {"vip": pool.vip, }
+ 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",
@@ -337,8 +339,7 @@ class PoolsTable(tables.DataTable):
status=True,
status_choices=STATUS_CHOICES,
display_choices=STATUS_DISPLAY_CHOICES)
- vip_name = tables.Column('vip_name', verbose_name=_("VIP"),
- link=get_vip_link)
+ vip_name = tables.Column(get_vip_name, verbose_name=_("VIP"))
class Meta(object):
name = "poolstable"
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tabs.py b/openstack_dashboard/dashboards/project/loadbalancers/tabs.py
index 179330aab4..019d8d056f 100644
--- a/openstack_dashboard/dashboards/project/loadbalancers/tabs.py
+++ b/openstack_dashboard/dashboards/project/loadbalancers/tabs.py
@@ -30,12 +30,22 @@ class PoolsTab(tabs.TableTab):
template_name = "horizon/common/_detail_table.html"
def get_poolstable_data(self):
+ pools = []
try:
+ request = self.tab_group.request
tenant_id = self.request.user.tenant_id
- pools = api.lbaas.pool_list(self.tab_group.request,
+ pools = api.lbaas.pool_list(request,
tenant_id=tenant_id)
+ fips = None
+ for pool in pools:
+ if hasattr(pool, "vip") and pool.vip:
+ if not fips:
+ fips = api.network.tenant_floating_ip_list(request)
+ vip_fip = [fip for fip in fips
+ if fip.port_id == pool.vip.port_id]
+ if vip_fip:
+ pool.vip.fip = vip_fip[0]
except Exception:
- pools = []
exceptions.handle(self.tab_group.request,
_('Unable to retrieve pools list.'))
return pools
@@ -100,10 +110,15 @@ class VipDetailsTab(tabs.Tab):
def get_context_data(self, request):
vid = self.tab_group.kwargs['vip_id']
+ vip = []
try:
vip = api.lbaas.vip_get(request, vid)
+ fips = api.network.tenant_floating_ip_list(self.tab_group.request)
+ vip_fip = [fip for fip in fips
+ if fip.port_id == vip.port.id]
+ if vip_fip:
+ vip.fip = vip_fip[0]
except Exception:
- vip = []
exceptions.handle(self.tab_group.request,
_('Unable to retrieve VIP details.'))
return {'vip': vip}
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_pool_table_vip_cell.html b/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_pool_table_vip_cell.html
new file mode 100644
index 0000000000..38c6adf854
--- /dev/null
+++ b/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_pool_table_vip_cell.html
@@ -0,0 +1,9 @@
+ {% load i18n %}
+ {% url 'horizon:project:loadbalancers:vipdetails' vip.id as vip_url %}
+ {{ vip.name }}
+
+ {% trans "Address:" %} {{ vip.address }}
+ {% if vip.fip %}
+
+ {% trans "Floating IP:" %} {{ vip.fip.floating_ip_address }}
+ {% endif %}
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_vip_details.html b/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_vip_details.html
index 2906bd48fa..67179587b6 100644
--- a/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_vip_details.html
+++ b/openstack_dashboard/dashboards/project/loadbalancers/templates/loadbalancers/_vip_details.html
@@ -22,6 +22,11 @@