From 3e39dc948002b4b9838c91b9016d3c602e939c2d Mon Sep 17 00:00:00 2001 From: Italo Lemos Date: Mon, 28 Oct 2024 09:49:49 -0300 Subject: [PATCH] Add Deploy Activate Rollback Action (Admin) This change add Deploy Activate Rollback action. The deploy action works for a Patch Release or Major Release. TEST PLAN: [PASS] Build, install. [PASS] Check if GUI shows and work 'Deploy Activate Rollback action. Go to Admin > Platform > Software Management On Release Table: Verify if 'Deploy Activate Rollback' is displayed in the action menu after 'Deploy Abort' has been selected before 'Deploy Complete'. Story: 2010676 Task: 50589 Change-Id: I79ca740c44ea9b1ef1d4068dfcc3d8be643014ee Signed-off-by: Italo Lemos --- .../admin/software_management/tables.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py index 7d8836c1..11569252 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py @@ -254,6 +254,38 @@ class DeployDelete(tables.Action): return shortcuts.redirect(url) +class DeployActivateRollback(tables.Action): + name = "deploy-activate-rollback" + verbose_name = _("Deploy Activate Rollback") + + def allowed(self, request, release=None): + deploy_show = stx_api.usm.deploy_show_req(request) + if not deploy_show: + return False + + deploy_show_state = deploy_show[0]['state'] + valid_states = { + "activate-rollback-failed", + "activate-rollback-pending", + } + + if release is None: + return True + + return (release.state in ["deploying", "removing"] and + deploy_show_state in valid_states) + + def single(self, table, request, obj_id): + try: + result = stx_api.usm.deploy_activate_rollback_req(request) + messages.success(request, result) + except Exception as ex: + messages.error(request, str(ex)) + + url = reverse(table.index_url) + return shortcuts.redirect(url) + + class ReleaseFilterAction(tables.FilterAction): def filter(self, table, releases, filter_string): """Naive case-insensitive search.""" @@ -361,6 +393,7 @@ class ReleasesTable(tables.DataTable): DeployDelete, DeleteRelease, DeployAbort, + DeployActivateRollback, ) table_actions = ( ReleaseFilterAction,