Fix wrong link to VM in admin volume table
Change-Id: I1f224fa544f80f749e692b321b4d4f46ea1ab940 Closes-Bug: #1567317
This commit is contained in:
parent
32e9e1d1b1
commit
4693a18975
|
@ -92,10 +92,16 @@ class UpdateVolumeStatusAction(tables.LinkAction):
|
||||||
"volume_extension:volume_admin_actions:reset_status"),)
|
"volume_extension:volume_admin_actions:reset_status"),)
|
||||||
|
|
||||||
|
|
||||||
|
class AttachmentColumn(volumes_tables.AttachmentColumn):
|
||||||
|
instance_detail_url = "horizon:admin:instances:detail"
|
||||||
|
|
||||||
|
|
||||||
class VolumesTable(volumes_tables.VolumesTable):
|
class VolumesTable(volumes_tables.VolumesTable):
|
||||||
name = tables.WrappingColumn("name",
|
name = tables.WrappingColumn("name",
|
||||||
verbose_name=_("Name"),
|
verbose_name=_("Name"),
|
||||||
link="horizon:admin:volumes:detail")
|
link="horizon:admin:volumes:detail")
|
||||||
|
attachments = AttachmentColumn("attachments",
|
||||||
|
verbose_name=_("Attached To"))
|
||||||
host = tables.Column("os-vol-host-attr:host", verbose_name=_("Host"))
|
host = tables.Column("os-vol-host-attr:host", verbose_name=_("Host"))
|
||||||
tenant = tables.Column(lambda obj: getattr(obj, 'tenant_name', None),
|
tenant = tables.Column(lambda obj: getattr(obj, 'tenant_name', None),
|
||||||
verbose_name=_("Project"))
|
verbose_name=_("Project"))
|
||||||
|
|
|
@ -346,7 +346,7 @@ def get_size(volume):
|
||||||
return _("%sGiB") % volume.size
|
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)
|
server_id = attachment.get("server_id", None)
|
||||||
if "instance" in attachment and attachment['instance']:
|
if "instance" in attachment and attachment['instance']:
|
||||||
name = attachment["instance"].name
|
name = attachment["instance"].name
|
||||||
|
@ -358,8 +358,10 @@ def get_attachment_name(request, attachment):
|
||||||
name = None
|
name = None
|
||||||
exceptions.handle(request, _("Unable to retrieve "
|
exceptions.handle(request, _("Unable to retrieve "
|
||||||
"attachment information."))
|
"attachment information."))
|
||||||
|
if not instance_detail_url:
|
||||||
|
instance_detail_url = "horizon:project:instances:detail"
|
||||||
try:
|
try:
|
||||||
url = reverse("horizon:project:instances:detail", args=(server_id,))
|
url = reverse(instance_detail_url, args=(server_id,))
|
||||||
instance = '<a href="%s">%s</a>' % (url, html.escape(name))
|
instance = '<a href="%s">%s</a>' % (url, html.escape(name))
|
||||||
except NoReverseMatch:
|
except NoReverseMatch:
|
||||||
instance = html.escape(name)
|
instance = html.escape(name)
|
||||||
|
@ -372,6 +374,9 @@ class AttachmentColumn(tables.WrappingColumn):
|
||||||
So it that does complex processing on the attachments
|
So it that does complex processing on the attachments
|
||||||
for a volume instance.
|
for a volume instance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
instance_detail_url = "horizon:project:instances:detail"
|
||||||
|
|
||||||
def get_raw_data(self, volume):
|
def get_raw_data(self, volume):
|
||||||
request = self.table.request
|
request = self.table.request
|
||||||
link = _('%(dev)s on %(instance)s')
|
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]:
|
for attachment in [att for att in volume.attachments if att]:
|
||||||
# When a volume is attached it may return the server_id
|
# When a volume is attached it may return the server_id
|
||||||
# without the server name...
|
# without the server name...
|
||||||
instance = get_attachment_name(request, attachment)
|
instance = get_attachment_name(request, attachment,
|
||||||
|
self.instance_detail_url)
|
||||||
vals = {"instance": instance,
|
vals = {"instance": instance,
|
||||||
"dev": html.escape(attachment.get("device", ""))}
|
"dev": html.escape(attachment.get("device", ""))}
|
||||||
attachments.append(link % vals)
|
attachments.append(link % vals)
|
||||||
|
|
Loading…
Reference in New Issue