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 <gustavo.herzmann@windriver.com>
Change-Id: I18f680810fab367e8c0e123887a4e3dcd3bdf8d5
This commit is contained in:
Gustavo Herzmann 2023-03-06 16:57:40 -03:00
parent adbbfc3fa5
commit 6310b0981b
3 changed files with 27 additions and 4 deletions

View File

@ -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):

View File

@ -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")

View File

@ -1,4 +1,4 @@
{% load i18n sizeformat %}
{% load i18n sizeformat getvalue %}
{% block main %}
@ -17,6 +17,10 @@
<dd>{{ strategy.max_parallel_subclouds }}</dd>
<dt>{% trans "Stop On Failure" %}</dt>
<dd>{{ strategy.stop_on_failure }}</dd>
{% if strategy.strategy_type == 'patch' and strategy.extra_args %}
<dt>{% trans "Upload Only" %}</dt>
<dd>{{ strategy.extra_args|get_value:"upload-only" }}</dd>
{% endif %}
<dt>{% trans "State" %}</dt>
<dd>{{ strategy.state }}</dd>
</dl>