diff --git a/openstack_dashboard/dashboards/admin/volumes/tables.py b/openstack_dashboard/dashboards/admin/volumes/tables.py index ae88850fa5..a06740c0ed 100644 --- a/openstack_dashboard/dashboards/admin/volumes/tables.py +++ b/openstack_dashboard/dashboards/admin/volumes/tables.py @@ -92,10 +92,16 @@ class UpdateVolumeStatusAction(tables.LinkAction): "volume_extension:volume_admin_actions:reset_status"),) +class AttachmentColumn(volumes_tables.AttachmentColumn): + instance_detail_url = "horizon:admin:instances:detail" + + class VolumesTable(volumes_tables.VolumesTable): name = tables.WrappingColumn("name", verbose_name=_("Name"), link="horizon:admin:volumes:detail") + attachments = AttachmentColumn("attachments", + verbose_name=_("Attached To")) host = tables.Column("os-vol-host-attr:host", verbose_name=_("Host")) tenant = tables.Column(lambda obj: getattr(obj, 'tenant_name', None), verbose_name=_("Project")) diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py index e616b3c8ec..d57cf37e48 100644 --- a/openstack_dashboard/dashboards/project/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/tables.py @@ -346,7 +346,7 @@ def get_size(volume): return _("%sGiB") % volume.size -def get_attachment_name(request, attachment): +def get_attachment_name(request, attachment, instance_detail_url=None): server_id = attachment.get("server_id", None) if "instance" in attachment and attachment['instance']: name = attachment["instance"].name @@ -358,8 +358,10 @@ def get_attachment_name(request, attachment): name = server_id exceptions.handle(request, _("Unable to retrieve " "attachment information.")) + if not instance_detail_url: + instance_detail_url = "horizon:project:instances:detail" try: - url = reverse("horizon:project:instances:detail", args=(server_id,)) + url = reverse(instance_detail_url, args=(server_id,)) instance = '%s' % (url, html.escape(name)) except NoReverseMatch: instance = html.escape(name) @@ -372,6 +374,9 @@ class AttachmentColumn(tables.WrappingColumn): So it that does complex processing on the attachments for a volume instance. """ + + instance_detail_url = "horizon:project:instances:detail" + def get_raw_data(self, volume): request = self.table.request link = _('%(dev)s on %(instance)s') @@ -380,7 +385,8 @@ class AttachmentColumn(tables.WrappingColumn): for attachment in [att for att in volume.attachments if att]: # When a volume is attached it may return the server_id # without the server name... - instance = get_attachment_name(request, attachment) + instance = get_attachment_name(request, attachment, + self.instance_detail_url) vals = {"instance": instance, "dev": html.escape(attachment.get("device", ""))} attachments.append(link % vals)