diff --git a/horizon/dashboards/nova/access_and_security/floating_ips/tables.py b/horizon/dashboards/nova/access_and_security/floating_ips/tables.py index b71fea112..dd3c26c8e 100644 --- a/horizon/dashboards/nova/access_and_security/floating_ips/tables.py +++ b/horizon/dashboards/nova/access_and_security/floating_ips/tables.py @@ -19,6 +19,7 @@ import logging from django import shortcuts from django.contrib import messages +from django.core import urlresolvers from django.utils.translation import ugettext_lazy as _ from horizon import api @@ -87,9 +88,18 @@ class DisassociateIP(tables.Action): return shortcuts.redirect('horizon:nova:access_and_security:index') +def get_instance_link(datum): + view = "horizon:nova:instances_and_volumes:instances:detail" + if datum.instance_id: + return urlresolvers.reverse(view, args=(datum.instance_id,)) + else: + return None + + class FloatingIPsTable(tables.DataTable): ip = tables.Column("ip", verbose_name=_("IP Address")) instance = tables.Column("instance_id", + link=get_instance_link, verbose_name=_("Instance"), empty_value="-") pool = tables.Column("pool", diff --git a/horizon/tables/base.py b/horizon/tables/base.py index fc39f362d..03bbebeae 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -448,8 +448,9 @@ class Cell(html.HTMLElement): raise template.TemplateSyntaxError, exc_info[1], exc_info[2] if self.column.link: url = self.column.get_link_url(self.datum) - # Escape the data inside while allowing our HTML to render - data = mark_safe('%s' % (url, escape(data))) + if url: + # Escape the data inside while allowing our HTML to render + data = mark_safe('%s' % (url, escape(data))) return data @property