diff --git a/openstack_dashboard/dashboards/admin/instances/tables.py b/openstack_dashboard/dashboards/admin/instances/tables.py index cc115ae3b..81d52779a 100644 --- a/openstack_dashboard/dashboards/admin/instances/tables.py +++ b/openstack_dashboard/dashboards/admin/instances/tables.py @@ -57,7 +57,7 @@ class AdminInstancesTable(tables.DataTable): TASK_DISPLAY_CHOICES = ( ("image_snapshot", "Snapshotting"), ) - tenant = tables.Column("tenant_name", verbose_name=_("Project Name")) + tenant = tables.Column("tenant_name", verbose_name=_("Project")) # 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 @@ -68,7 +68,7 @@ class AdminInstancesTable(tables.DataTable): classes=('nowrap-col',)) name = tables.Column("name", link=("horizon:project:instances:detail"), - verbose_name=_("Instance Name")) + verbose_name=_("Name")) ip = tables.Column(get_ips, verbose_name=_("IP Address")) size = tables.Column(get_size, verbose_name=_("Size"), diff --git a/openstack_dashboard/dashboards/admin/volumes/tables.py b/openstack_dashboard/dashboards/admin/volumes/tables.py index 268680e42..642c64460 100644 --- a/openstack_dashboard/dashboards/admin/volumes/tables.py +++ b/openstack_dashboard/dashboards/admin/volumes/tables.py @@ -26,6 +26,7 @@ class VolumesTable(_VolumesTable): verbose_name=_("Name"), link="horizon:admin:volumes:detail") host = tables.Column("os-vol-host-attr:host", verbose_name=_("Host")) + tenant = tables.Column("tenant_name", verbose_name=_("Project")) class Meta: name = "volumes" @@ -34,6 +35,8 @@ class VolumesTable(_VolumesTable): row_class = UpdateRow table_actions = (DeleteVolume,) row_actions = (DeleteVolume,) + columns = ('tenant', 'host', 'name', 'size', 'status', 'volume_type', + 'attachments',) class VolumeTypesTable(tables.DataTable): diff --git a/openstack_dashboard/dashboards/admin/volumes/tests.py b/openstack_dashboard/dashboards/admin/volumes/tests.py index f9ae005ca..a7c4d04ff 100644 --- a/openstack_dashboard/dashboards/admin/volumes/tests.py +++ b/openstack_dashboard/dashboards/admin/volumes/tests.py @@ -20,13 +20,15 @@ from mox import IsA from openstack_dashboard import api from openstack_dashboard.api import cinder +from openstack_dashboard.api import keystone from openstack_dashboard.test import helpers as test class VolumeTests(test.BaseAdminViewTests): @test.create_stubs({api.nova: ('server_list',), cinder: ('volume_list', - 'volume_type_list',)}) + 'volume_type_list',), + keystone: ('tenant_list',)}) def test_index(self): cinder.volume_list(IsA(http.HttpRequest), search_opts={ 'all_tenants': 1}).AndReturn(self.volumes.list()) @@ -34,6 +36,8 @@ class VolumeTests(test.BaseAdminViewTests): AndReturn(self.servers.list()) cinder.volume_type_list(IsA(http.HttpRequest)).\ AndReturn(self.volume_types.list()) + keystone.tenant_list(IsA(http.HttpRequest), + admin=True).AndReturn(self.tenants.list()) self.mox.ReplayAll() @@ -62,7 +66,8 @@ class VolumeTests(test.BaseAdminViewTests): @test.create_stubs({api.nova: ('server_list',), cinder: ('volume_list', 'volume_type_list', - 'volume_type_delete',)}) + 'volume_type_delete',), + keystone: ('tenant_list',)}) def test_delete_volume_type(self): volume_type = self.volume_types.first() formData = {'action': 'volume_types__delete__%s' % volume_type.id} @@ -75,6 +80,8 @@ class VolumeTests(test.BaseAdminViewTests): AndReturn(self.volume_types.list()) cinder.volume_type_delete(IsA(http.HttpRequest), str(volume_type.id)) + keystone.tenant_list(IsA(http.HttpRequest), + admin=True).AndReturn(self.tenants.list()) self.mox.ReplayAll() res = self.client.post(reverse('horizon:admin:volumes:index'), diff --git a/openstack_dashboard/dashboards/admin/volumes/views.py b/openstack_dashboard/dashboards/admin/volumes/views.py index 68e844d8e..1041875c1 100644 --- a/openstack_dashboard/dashboards/admin/volumes/views.py +++ b/openstack_dashboard/dashboards/admin/volumes/views.py @@ -18,11 +18,13 @@ Admin views for managing volumes. """ +from django.utils.datastructures import SortedDict from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse from openstack_dashboard.dashboards.project.volumes.views import \ VolumeTableMixIn, DetailView as _DetailView from openstack_dashboard.api import cinder +from openstack_dashboard.api import keystone from .tables import VolumesTable, VolumeTypesTable from .forms import CreateVolumeType @@ -40,6 +42,21 @@ class IndexView(tables.MultiTableView, VolumeTableMixIn): instances = self._get_instances() self._set_id_if_nameless(volumes, instances) self._set_attachments_string(volumes, instances) + + # Gather our tenants to correlate against IDs + try: + tenants = keystone.tenant_list(self.request, admin=True) + except: + tenants = [] + msg = _('Unable to retrieve volume tenant information.') + exceptions.handle(self.request, msg) + + tenant_dict = SortedDict([(t.id, t) for t in tenants]) + for volume in volumes: + tenant_id = getattr(volume, "os-vol-tenant-attr:tenant_id", None) + tenant = tenant_dict.get(tenant_id, None) + volume.tenant_name = getattr(tenant, "name", None) + return volumes def get_volume_types_data(self):