From 6310b0981b6e8dfab0fbee2d474b736db0129f71 Mon Sep 17 00:00:00 2001 From: Gustavo Herzmann Date: Mon, 6 Mar 2023 16:57:40 -0300 Subject: [PATCH] Add the upload-only option to the Horizon patch orchestration UI This change adds the new DC patch orchestration upload-only option to the patch orchestration UI. A new 'Upload Only' checkbox was added to the 'Create Strategy' form when the selected strategy type is 'Patch'. In the 'Orchestration Strategy' tab, if the current strategy is a patch strategy, a new field 'Upload Only' with its current value is now shown so that the user can know if an existing strategy is using this option. Test Plan: 1. PASS - Verify that the 'Upload Only' checkbox appears correctly inside of the create strategy form only when the selected strategy type is equal to 'Patch'; 2. PASS - Create a patch strategy with and without the upload-only option and verify that it gets created successfully; 3. PASS - Verify that the interface shows the 'Upload Only' field and its current value on the 'Orchestration Strategy' page only when using the patch strategy type; 4. PASS - Create and delete another orchestration type (e.g. Kubernetes upgrade) through Horizon and verify that it still works as expected; 5. PASS - Run the entire patch orchestration procedure through Horizon and verify that it completes successfully. Depends-On: https://review.opendev.org/c/starlingx/distcloud-client/+/876629 Story: 2010584 Task: 47592 Signed-off-by: Gustavo Herzmann Change-Id: I18f680810fab367e8c0e123887a4e3dcd3bdf8d5 --- .../starlingx_dashboard/api/dc_manager.py | 4 ++-- .../dc_admin/dc_orchestration/forms.py | 21 ++++++++++++++++++- .../_cloud_strategy_orchestration.html | 6 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py index 82a38488..7a95e8f1 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/dc_manager.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. # -# Copyright (c) 2017-2022 Wind River Systems, Inc. +# Copyright (c) 2017-2023 Wind River Systems, Inc. # import logging @@ -125,7 +125,7 @@ def subcloud_group_update(request, subcloud_group_id, **kwargs): class Strategy(base.APIResourceWrapper): _attrs = ['strategy_type', 'subcloud_apply_type', 'max_parallel_subclouds', 'stop_on_failure', 'state', - 'created_at', 'updated_at'] + 'created_at', 'updated_at', 'extra_args'] def get_strategy(request): diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/forms.py index 70de1f5b..4e196f30 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/forms.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2018-2022 Wind River Systems, Inc. +# Copyright (c) 2018-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -195,6 +195,20 @@ class CreateCloudStrategyForm(forms.SelfHandlingForm): ) ) + upload_only = forms.BooleanField( + label=_("Upload Only"), + initial=False, + required=False, + help_text=_('Stops strategy after uploading patches to subclouds'), + widget=forms.CheckboxInput( + attrs={ + 'class': 'switched', + 'data-switch-on': 'strategy_types', + 'data-strategy_types-patch': _("Upload Only") + } + ) + ) + def __init__(self, request, *args, **kwargs): super(CreateCloudStrategyForm, self).__init__(request, *args, **kwargs) @@ -250,6 +264,11 @@ class CreateCloudStrategyForm(forms.SelfHandlingForm): del data['to-version'] del data['force-kubernetes'] + if data['type'] == 'patch': + data['upload-only'] = str(data['upload-only']).lower() + else: + del data['upload-only'] + response = api.dc_manager.strategy_create(request, data) if not response: messages.error(request, "Strategy creation failed") diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/templates/dc_orchestration/_cloud_strategy_orchestration.html b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/templates/dc_orchestration/_cloud_strategy_orchestration.html index 23ebd66b..08aa24c1 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/templates/dc_orchestration/_cloud_strategy_orchestration.html +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_orchestration/templates/dc_orchestration/_cloud_strategy_orchestration.html @@ -1,4 +1,4 @@ -{% load i18n sizeformat %} +{% load i18n sizeformat getvalue %} {% block main %} @@ -17,6 +17,10 @@
{{ strategy.max_parallel_subclouds }}
{% trans "Stop On Failure" %}
{{ strategy.stop_on_failure }}
+ {% if strategy.strategy_type == 'patch' and strategy.extra_args %} +
{% trans "Upload Only" %}
+
{{ strategy.extra_args|get_value:"upload-only" }}
+ {% endif %}
{% trans "State" %}
{{ strategy.state }}