From a75c6018ba7e8a78004a8c072ba2f29b1ffe3ff0 Mon Sep 17 00:00:00 2001 From: suzhengwei Date: Tue, 20 Feb 2024 10:01:50 +0800 Subject: [PATCH] support for Masakari VMoves It supports for Masakari VMove API in microversion 1.3. Change-Id: Iafc9da3037c858a327b8805c137c6a074c56d7cc --- masakaridashboard/api/api.py | 5 +++++ masakaridashboard/notifications/tabs.py | 11 +++++------ masakaridashboard/notifications/views.py | 6 +++++- masakaridashboard/vmoves/tables.py | 4 ++-- .../vmoves/templates/vmoves/_detail_overview.html | 2 ++ masakaridashboard/vmoves/templates/vmoves/detail.html | 2 ++ masakaridashboard/vmoves/tests.py | 2 +- masakaridashboard/vmoves/views.py | 4 +++- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/masakaridashboard/api/api.py b/masakaridashboard/api/api.py index c000f78..f596bd7 100644 --- a/masakaridashboard/api/api.py +++ b/masakaridashboard/api/api.py @@ -183,6 +183,11 @@ def notification_list(request, filters=None, marker='', paginate=False): return entities, has_more_data, has_prev_data +def get_notification_list(request): + """return notifications list """ + return list(openstack_connection(request).notifications()) + + def get_notification(request, notification_id): """return single notifications""" return openstack_connection(request).get_notification(notification_id) diff --git a/masakaridashboard/notifications/tabs.py b/masakaridashboard/notifications/tabs.py index 37b0d14..99b1f8d 100644 --- a/masakaridashboard/notifications/tabs.py +++ b/masakaridashboard/notifications/tabs.py @@ -75,14 +75,13 @@ class VMoveTab(tabs.TableTab): preload = False def get_vmove_data(self): - vmove_list = [] - notification_type = self.tab_group.kwargs['type'] - if notification_type != "COMPUTE_HOST": - return vmove_list + notification = self.tab_group.kwargs['notification'] + if notification.type != "COMPUTE_HOST": + return [] - notification_id = self.tab_group.kwargs['notification_uuid'] + vmove_list = [] vmove_gen = api.get_vmoves_list( - self.request, notification_id, filters={}) + self.request, notification.notification_uuid, filters={}) for item in vmove_gen: vmove_list.append(item) diff --git a/masakaridashboard/notifications/views.py b/masakaridashboard/notifications/views.py index b6cb4c8..3ff3983 100644 --- a/masakaridashboard/notifications/views.py +++ b/masakaridashboard/notifications/views.py @@ -97,7 +97,11 @@ class DetailView(tabs.TabbedTableView): @memoized.memoized_method def get_data(self): try: - notification_id = self.kwargs['notification_id'] + notification_data = self.kwargs['notification_id'] + if len(notification_data.split(',')) > 1: + notification_id = notification_data.split(',')[0] + else: + notification_id = notification_data notification = api.get_notification(self.request, notification_id) except Exception: msg = _('Unable to get notification "%s".') % notification_id diff --git a/masakaridashboard/vmoves/tables.py b/masakaridashboard/vmoves/tables.py index 473b63c..c1cf718 100644 --- a/masakaridashboard/vmoves/tables.py +++ b/masakaridashboard/vmoves/tables.py @@ -18,7 +18,7 @@ from horizon import tables VMOVE_FILTER_CHOICES = ( - ('notification_id', _("Notification UUId ="), True), + ('notification_uuid', _("Notification UUId ="), True), ('type', _("Type ="), True), ('status', _("Status ="), True), ) @@ -53,7 +53,7 @@ class VMoveTable(tables.DataTable): 'status', verbose_name=_("Status")) def get_object_id(self, datum): - return datum.uuid + ',' + datum.notification_id + return datum.notification_id + ',' + datum.uuid class Meta(object): name = "vmove" diff --git a/masakaridashboard/vmoves/templates/vmoves/_detail_overview.html b/masakaridashboard/vmoves/templates/vmoves/_detail_overview.html index 5a8c3fe..968898f 100644 --- a/masakaridashboard/vmoves/templates/vmoves/_detail_overview.html +++ b/masakaridashboard/vmoves/templates/vmoves/_detail_overview.html @@ -21,5 +21,7 @@
{{ vmove.end_time }}
{% trans "Status" %}
{{ vmove.status }}
+
{% trans "message" %}
+
{{ vmove.message }}
\ No newline at end of file diff --git a/masakaridashboard/vmoves/templates/vmoves/detail.html b/masakaridashboard/vmoves/templates/vmoves/detail.html index 0614e87..158126e 100644 --- a/masakaridashboard/vmoves/templates/vmoves/detail.html +++ b/masakaridashboard/vmoves/templates/vmoves/detail.html @@ -14,6 +14,8 @@
{% trans "UUID" %}
{{ vmove.uuid }}
+
{% trans "Notification UUID" %}
+
{{ vmove.notification_uuid }}
{% trans "Server ID" %}
{{ vmove.server_id }}
{% trans "Server Name" %}
diff --git a/masakaridashboard/vmoves/tests.py b/masakaridashboard/vmoves/tests.py index 63467fe..d36d32c 100644 --- a/masakaridashboard/vmoves/tests.py +++ b/masakaridashboard/vmoves/tests.py @@ -26,7 +26,7 @@ class VMoveTest(test.TestCase): def test_index(self): vmoves = self.masakari_vmove.list() notifications = self.masakari_notification.list() - with mock.patch('masakaridashboard.api.api.notification_list', + with mock.patch('masakaridashboard.api.api.get_notification_list', return_value=notifications), mock.patch( 'masakaridashboard.api.api.get_notification', return_value=notifications[0]), mock.patch( diff --git a/masakaridashboard/vmoves/views.py b/masakaridashboard/vmoves/views.py index 0fd34aa..4db26ec 100644 --- a/masakaridashboard/vmoves/views.py +++ b/masakaridashboard/vmoves/views.py @@ -35,7 +35,7 @@ class IndexView(tables.DataTableView): return self._needs_filter_first def get_data(self): - notifications = api.notification_list(self.request) + notifications = api.get_notification_list(self.request) vmove_list = [] filters = self.get_filters() self._needs_filter_first = True @@ -48,6 +48,8 @@ class IndexView(tables.DataTableView): return vmove_list for notification in notifications: + if notification.type != "COMPUTE_HOST": + continue vmove_gen = api.get_vmoves_list( self.request, notification.notification_uuid, filters) for item in vmove_gen: