From 19ef51302e5d13330df6fe6ebc962f667c058e35 Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Sun, 18 Mar 2012 21:35:43 -0700 Subject: [PATCH] Paring down the syspanel instances table. There was simply too much information in that table to be usable. It probably still needs to lose more weight in favor of moving things to a more admin-oriented detail page. However, we need to get real user feedback on what data is critical for the overview vs. what can be in a detail page. Fixes bug 944506. Change-Id: Iaad218bc6ed6647645c5943920467bec097a0a2d --- horizon/api/nova.py | 4 +++ .../dashboards/syspanel/instances/tables.py | 17 +++++----- .../dashboards/syspanel/instances/views.py | 31 +++++++++++-------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/horizon/api/nova.py b/horizon/api/nova.py index 943cec48dff..2f91d6688d7 100644 --- a/horizon/api/nova.py +++ b/horizon/api/nova.py @@ -100,6 +100,10 @@ def image_name(self): except glance_exceptions.NotFound: return "(not found)" + @property + def internal_name(self): + return getattr(self, 'OS-EXT-SRV-ATTR:instance_name', "") + def reboot(self, hardness=REBOOT_HARD): novaclient(self.request).servers.reboot(self.id, hardness) diff --git a/horizon/dashboards/syspanel/instances/tables.py b/horizon/dashboards/syspanel/instances/tables.py index 4d8bef56dd1..d9afde2badb 100644 --- a/horizon/dashboards/syspanel/instances/tables.py +++ b/horizon/dashboards/syspanel/instances/tables.py @@ -21,10 +21,11 @@ from django.utils.translation import ugettext as _ from horizon import tables -from horizon.dashboards.nova.instances_and_volumes.instances.tables import \ - (LaunchLink, TerminateInstance, EditInstance, ConsoleLink, LogLink, - SnapshotLink, TogglePause, ToggleSuspend, RebootInstance, get_size, - TerminateInstance, UpdateRow, get_ips, get_power_state) +from horizon.dashboards.nova.instances_and_volumes.instances.tables import ( + TerminateInstance, EditInstance, ConsoleLink, LogLink, SnapshotLink, + TogglePause, ToggleSuspend, RebootInstance, get_size, UpdateRow, + get_ips, get_power_state) + LOG = logging.getLogger(__name__) @@ -39,9 +40,11 @@ class SyspanelInstancesTable(tables.DataTable): ("error", False), ) tenant = tables.Column("tenant_name", verbose_name=_("Tenant")) - user = tables.Column("user_id", verbose_name=_("User")) - internal_id = tables.Column("internal_identifier", - verbose_name=_("Instance ID")) + # NOTE(gabriel): Commenting out the user column because all we have + # is an ID, and correlating that at production scale using our current + # techniques isn't practical. It can be added back in when we have names + # returned in a practical manner by the API. + #user = tables.Column("user_id", verbose_name=_("User")) host = tables.Column("OS-EXT-SRV-ATTR:host", verbose_name=_("Host")) name = tables.Column("name", link="horizon:nova:instances_and_volumes:" \ "instances:detail", diff --git a/horizon/dashboards/syspanel/instances/views.py b/horizon/dashboards/syspanel/instances/views.py index 492026c6a42..f6692705fa2 100644 --- a/horizon/dashboards/syspanel/instances/views.py +++ b/horizon/dashboards/syspanel/instances/views.py @@ -28,8 +28,8 @@ from horizon import exceptions from horizon import tables from horizon.dashboards.syspanel.instances.tables import SyspanelInstancesTable -from horizon.dashboards.nova.instances_and_volumes \ - .instances.views import console, DetailView, vnc +from horizon.dashboards.nova.instances_and_volumes .instances.views import ( + console, DetailView, vnc) LOG = logging.getLogger(__name__) @@ -47,20 +47,25 @@ def get_data(self): exceptions.handle(self.request, _('Unable to retrieve instance list.')) if instances: + # Gather our flavors to correlate against IDs try: flavors = api.nova.flavor_list(self.request) - tenants = SortedDict([(str(tenant.id), tenant) for \ - tenant in api.keystone.tenant_list( - self.request, admin=True)]) - full_flavors = SortedDict([(str(flavor.id), flavor) for \ - flavor in flavors]) - for inst in instances: - inst.full_flavor = full_flavors[inst.flavor["id"]] - inst.internal_identifier = "%s (%s)" % (inst.id, - getattr(inst, 'OS-EXT-SRV-ATTR:instance_name')) - inst.tenant_name = "%s (%s)" % (inst.tenant_id, - tenants[inst.tenant_id].name) except: + flavors = [] msg = _('Unable to retrieve instance size information.') exceptions.handle(self.request, msg) + # Gather our tenants to correlate against IDs + try: + tenants = api.keystone.tenant_list(self.request, admin=True) + except: + tenants = [] + msg = _('Unable to retrieve instance tenant information.') + exceptions.handle(self.request, msg) + + full_flavors = SortedDict([(f.id, f) for f in flavors]) + tenant_dict = SortedDict([(t.id, t) for t in tenants]) + for inst in instances: + inst.full_flavor = full_flavors.get(inst.flavor["id"], None) + tenant = tenant_dict.get(inst.tenant_id, None) + inst.tenant_name = getattr(tenant, "name", None) return instances