diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index 2032114441..2ec98853aa 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -187,6 +187,10 @@ class VolumePool(base.APIResourceWrapper): 'storage_protocol', 'extra_specs'] +class Message(base.APIResourceWrapper): + _attrs = ['id', 'event_id', 'created_at', 'resource_type', 'user_message'] + + class Group(base.APIResourceWrapper): _attrs = ['id', 'status', 'availability_zone', 'created_at', 'name', 'description', 'group_type', 'volume_types', diff --git a/openstack_dashboard/dashboards/admin/snapshots/tabs.py b/openstack_dashboard/dashboards/admin/snapshots/tabs.py index 29b35e4f21..bea8398b53 100644 --- a/openstack_dashboard/dashboards/admin/snapshots/tabs.py +++ b/openstack_dashboard/dashboards/admin/snapshots/tabs.py @@ -16,10 +16,12 @@ from django.utils.translation import ugettext_lazy as _ from horizon import tabs from openstack_dashboard.dashboards.project.snapshots \ - import tabs as overview_tab + import tables as snap_messages_tables +from openstack_dashboard.dashboards.project.snapshots \ + import tabs as project_tab -class OverviewTab(overview_tab.OverviewTab): +class OverviewTab(project_tab.OverviewTab): name = _("Overview") slug = "overview" template_name = ("project/snapshots/_detail_overview.html") @@ -28,6 +30,10 @@ class OverviewTab(overview_tab.OverviewTab): return reverse('horizon:admin:snapshots:index') +class SnapshotMessagesTab(project_tab.SnapshotMessagesTab): + table_classes = (snap_messages_tables.SnapshotMessagesTable,) + + class SnapshotDetailsTabs(tabs.TabGroup): slug = "snapshot_details" - tabs = (OverviewTab,) + tabs = (OverviewTab, SnapshotMessagesTab) diff --git a/openstack_dashboard/dashboards/admin/volumes/tabs.py b/openstack_dashboard/dashboards/admin/volumes/tabs.py index 7535dbd615..3571475be2 100644 --- a/openstack_dashboard/dashboards/admin/volumes/tabs.py +++ b/openstack_dashboard/dashboards/admin/volumes/tabs.py @@ -11,6 +11,8 @@ # under the License. from openstack_dashboard.dashboards.admin.snapshots import tables +from openstack_dashboard.dashboards.project.volumes \ + import tables as vol_messages_tables from openstack_dashboard.dashboards.project.volumes import tabs as project_tabs @@ -34,5 +36,9 @@ class SnapshotTab(project_tabs.SnapshotTab): table_classes = (tables.VolumeDetailsSnapshotsTable,) +class VolumeMessagesTab(project_tabs.VolumeMessagesTab): + table_classes = (vol_messages_tables.VolumeMessagesTable,) + + class VolumeDetailTabs(project_tabs.VolumeDetailTabs): - tabs = (OverviewTab, SnapshotTab) + tabs = (OverviewTab, SnapshotTab, VolumeMessagesTab) diff --git a/openstack_dashboard/dashboards/admin/volumes/tests.py b/openstack_dashboard/dashboards/admin/volumes/tests.py index f7bf53f6c5..a633c8e2ac 100644 --- a/openstack_dashboard/dashboards/admin/volumes/tests.py +++ b/openstack_dashboard/dashboards/admin/volumes/tests.py @@ -380,7 +380,7 @@ class VolumeTests(test.BaseAdminViewTests): @test.create_mocks({ api.nova: ['server_get'], api.cinder: ['tenant_absolute_limits', 'volume_get', - 'volume_snapshot_list', 'message_list']}) + 'volume_snapshot_list']}) def test_detail_view_snapshot_tab(self): volume = self.cinder_volumes.first() server = self.servers.first() @@ -394,7 +394,6 @@ class VolumeTests(test.BaseAdminViewTests): self.mock_tenant_absolute_limits.return_value = volume_limits self.mock_volume_get.return_value = volume self.mock_volume_snapshot_list.return_value = this_volume_snapshots - self.mock_message_list.return_value = [] url = (reverse(DETAIL_URL, args=[volume.id]) + '?' + '='.join(['tab', 'volume_details__snapshots_tab'])) @@ -414,9 +413,3 @@ class VolumeTests(test.BaseAdminViewTests): self.mock_volume_snapshot_list.assert_called_once_with( test.IsHttpRequest(), search_opts={'volume_id': volume.id, 'all_tenants': True}) - self.mock_message_list.assert_called_once_with( - test.IsHttpRequest(), - { - 'resource_uuid': volume.id, - 'resource_type': 'volume' - }) diff --git a/openstack_dashboard/dashboards/project/snapshots/tables.py b/openstack_dashboard/dashboards/project/snapshots/tables.py index 5db1b52b68..c43c7a740d 100644 --- a/openstack_dashboard/dashboards/project/snapshots/tables.py +++ b/openstack_dashboard/dashboards/project/snapshots/tables.py @@ -263,3 +263,21 @@ class VolumeSnapshotsTable(VolumeDetailsSnapshotsTable): class Meta(VolumeDetailsSnapshotsTable.Meta): pass + + +class SnapshotMessagesTable(tables.DataTable): + message_id = tables.Column("id", verbose_name=_("ID")) + message_level = tables.Column("message_level", + verbose_name=_("Message Level")) + event_id = tables.Column("event_id", + verbose_name=_("Event Id")) + user_message = tables.Column("user_message", + verbose_name=_("User Message")) + created_at = tables.Column("created_at", + verbose_name=_("Created At")) + guaranteed_until = tables.Column("guaranteed_until", + verbose_name=_("Guaranteed Until")) + + class Meta(object): + name = "snapshot_messages" + verbose_name = _("Messages") diff --git a/openstack_dashboard/dashboards/project/snapshots/tabs.py b/openstack_dashboard/dashboards/project/snapshots/tabs.py index 548fd4044c..2c29e99ccd 100644 --- a/openstack_dashboard/dashboards/project/snapshots/tabs.py +++ b/openstack_dashboard/dashboards/project/snapshots/tabs.py @@ -19,6 +19,8 @@ from horizon import exceptions from horizon import tabs from openstack_dashboard.api import cinder +from openstack_dashboard.dashboards.project.snapshots \ + import tables as snap_messages_tables class OverviewTab(tabs.Tab): @@ -43,6 +45,29 @@ class OverviewTab(tabs.Tab): return reverse('horizon:project:snapshots:index') +class SnapshotMessagesTab(tabs.TableTab): + table_classes = (snap_messages_tables.SnapshotMessagesTable,) + name = _("Messages") + slug = "messages_tab" + template_name = ("horizon/common/_detail_table.html") + preload = False + + def get_snapshot_messages_data(self): + messages = [] + snapshot = self.tab_group.kwargs['snapshot'] + snap_id = snapshot.id + try: + snap_msgs = cinder.message_list(self.request, search_opts={ + 'resource_type': 'volume_snapshot', 'resource_uuid': snap_id}) + for snap_msg in snap_msgs: + messages.append(snap_msg) + + except Exception: + exceptions.handle(self.request, _("Unable to retrieve " + "snapshot messages.")) + return messages + + class SnapshotDetailTabs(tabs.TabGroup): slug = "snapshot_details" - tabs = (OverviewTab,) + tabs = (OverviewTab, SnapshotMessagesTab) diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py index ecb8e4ce20..418514314a 100644 --- a/openstack_dashboard/dashboards/project/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/tables.py @@ -656,3 +656,21 @@ class AttachmentsTable(tables.DataTable): verbose_name = _("Attachments") table_actions = (DetachVolume,) row_actions = (DetachVolume,) + + +class VolumeMessagesTable(tables.DataTable): + message_id = tables.Column("id", verbose_name=_("ID")) + message_level = tables.Column("message_level", + verbose_name=_("Message Level")) + event_id = tables.Column("event_id", + verbose_name=_("Event Id")) + user_message = tables.Column("user_message", + verbose_name=_("User Message")) + created_at = tables.Column("created_at", + verbose_name=_("Created At")) + guaranteed_until = tables.Column("guaranteed_until", + verbose_name=_("Guaranteed Until")) + + class Meta(object): + name = "volume_messages" + verbose_name = _("Messages") diff --git a/openstack_dashboard/dashboards/project/volumes/tabs.py b/openstack_dashboard/dashboards/project/volumes/tabs.py index 22322e520d..13f7031494 100644 --- a/openstack_dashboard/dashboards/project/volumes/tabs.py +++ b/openstack_dashboard/dashboards/project/volumes/tabs.py @@ -19,6 +19,8 @@ from horizon import tabs from openstack_dashboard.api import cinder from openstack_dashboard.dashboards.project.snapshots import tables +from openstack_dashboard.dashboards.project.volumes \ + import tables as vol_messages_tables class OverviewTab(tabs.Tab): @@ -77,6 +79,28 @@ class SnapshotTab(tabs.TableTab): return snapshots +class VolumeMessagesTab(tabs.TableTab): + table_classes = (vol_messages_tables.VolumeMessagesTable,) + name = _("Messages") + slug = "messages_tab" + template_name = ("horizon/common/_detail_table.html") + preload = False + + def get_volume_messages_data(self): + messages = [] + volume = self.tab_group.kwargs['volume'].id + try: + vol_msgs = cinder.message_list(self.request, search_opts={ + 'resource_type': 'volume', 'resource_uuid': volume}) + for vol_msg in vol_msgs: + messages.append(vol_msg) + + except Exception: + exceptions.handle(self.request, _("Unable to retrieve " + "volume messages.")) + return messages + + class VolumeDetailTabs(tabs.DetailTabsGroup): slug = "volume_details" - tabs = (OverviewTab, SnapshotTab) + tabs = (OverviewTab, SnapshotTab, VolumeMessagesTab) diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/_detail_overview.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/_detail_overview.html index 96e9e638eb..e3d8204117 100644 --- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/_detail_overview.html +++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/_detail_overview.html @@ -105,22 +105,4 @@