Add an user prompt confirmation on apply strategy
With the inclusion of a generic confirmation layer in the CLI, some commands were also impacted on the GUI side. This change adds a user confirmation to apply strategy in software deploy. [PASS] Build, install [PASS] With the RegionOne region selected, go to Admin dashboard and then Software Management select Deploy Orchestration tab and create and apply a strategy. Story: 2011240 Task: 52050 Change-Id: I45a6dadf884295d7f7607a4b0af7df6136a32ba2 Signed-off-by: idoregol <Italo.doRegoLemos@windriver.com>
This commit is contained in:
parent
5c36699fec
commit
7e619bcd1b
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2016-2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2016-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -276,3 +276,23 @@ class CreateSoftwareDeployStrategyForm(forms.SelfHandlingForm):
|
||||
exceptions.handle(request, "Strategy creation failed",
|
||||
redirect=redirect)
|
||||
return True
|
||||
|
||||
|
||||
class ApplySoftwareDeployStrategyForm(forms.SelfHandlingForm):
|
||||
failure_url = 'horizon:admin:software_management:index'
|
||||
strategy_name = stx_api.vim.STRATEGY_SW_DEPLOY
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
result = stx_api.vim.apply_strategy(request, self.strategy_name)
|
||||
if result:
|
||||
messages.success(request, "Strategy apply in progress")
|
||||
else:
|
||||
messages.error(request, "Strategy apply failed")
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
redirect = reverse(self.failure_url)
|
||||
msg = _('Strategy apply failed.')
|
||||
exceptions.handle(request, msg,
|
||||
redirect=redirect)
|
||||
return True
|
||||
|
@ -490,10 +490,12 @@ class DeleteSoftwareDeployStrategy(DeleteStrategy):
|
||||
strategy_name = stx_api.vim.STRATEGY_SW_DEPLOY
|
||||
|
||||
|
||||
class ApplyStrategy(tables.Action):
|
||||
requires_input = False
|
||||
disabled = False
|
||||
class ApplyStrategy(tables.LinkAction):
|
||||
url = "horizon:admin:software_management:apply_software_deploy_strategy"
|
||||
verbose_name = _("Apply Strategy")
|
||||
classes = ("ajax-modal", "btn-confirm")
|
||||
disabled = False
|
||||
requires_input = False
|
||||
|
||||
def allowed(self, request, datum):
|
||||
try:
|
||||
@ -516,20 +518,6 @@ class ApplyStrategy(tables.Action):
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
|
||||
def single(self, table, request, obj_id):
|
||||
try:
|
||||
result = stx_api.vim.apply_strategy(request, self.strategy_name)
|
||||
if result:
|
||||
messages.success(request, "Strategy apply in progress")
|
||||
else:
|
||||
messages.error(request, "Strategy apply failed")
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
messages.error(request, str(ex))
|
||||
|
||||
url = reverse('horizon:admin:software_management:index')
|
||||
return shortcuts.redirect(url)
|
||||
|
||||
|
||||
class ApplySoftwareDeployStrategy(ApplyStrategy):
|
||||
name = "apply_software_deploy_strategy"
|
||||
|
@ -0,0 +1,29 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block form_action %}{% url 'horizon:admin:software_management:apply_software_deploy_strategy' %}{% endblock %}
|
||||
|
||||
{% block modal-header %}{% trans "Apply Strategy" %}{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
{% if out_of_date == True %}
|
||||
<p>
|
||||
{% trans "<b>WARNING:</b> The strategy was created " %}
|
||||
{{hours}}
|
||||
{% trans " hours and " %}
|
||||
{{minutes}}
|
||||
{% trans " minutes ago." %}
|
||||
{% trans "Please, verify that this strategy is still valid" %}
|
||||
{% trans "for your environment" %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% trans "Are you sure you want to apply the strategy?" %}
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
<a class="btn btn-default cancel" data-dismiss="modal">Cancel</a>
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Yes" %}" />
|
||||
{% endblock %}
|
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Apply Strategy" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Apply Strategy") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'admin/software_management/_apply_cloud_strategy.html' %}
|
||||
{% endblock %}
|
@ -1,11 +1,13 @@
|
||||
#
|
||||
# Copyright (c) 2013-2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from starlingx_dashboard.dashboards.admin.software_management.views import \
|
||||
ApplySoftwareDeployStrategyView
|
||||
from starlingx_dashboard.dashboards.admin.software_management.views import \
|
||||
CreateSoftwareDeployStrategyView
|
||||
from starlingx_dashboard.dashboards.admin.software_management.views import \
|
||||
@ -30,5 +32,8 @@ urlpatterns = [
|
||||
name='softwaredeploystagedetail'),
|
||||
url(r'^createsoftwaredeploystrategy/$',
|
||||
CreateSoftwareDeployStrategyView.as_view(),
|
||||
name='create_software_deploy_strategy')
|
||||
name='create_software_deploy_strategy'),
|
||||
url(r'^applysoftwaredeploystrategy/$',
|
||||
ApplySoftwareDeployStrategyView.as_view(),
|
||||
name='apply_software_deploy_strategy')
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2013-2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -17,6 +17,8 @@ from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon import views
|
||||
from starlingx_dashboard import api as stx_api
|
||||
from starlingx_dashboard.dashboards.admin.software_management.forms import \
|
||||
ApplySoftwareDeployStrategyForm
|
||||
from starlingx_dashboard.dashboards.admin.software_management.forms import \
|
||||
CreateSoftwareDeployStrategyForm
|
||||
from starlingx_dashboard.dashboards.admin.software_management.forms import \
|
||||
@ -90,6 +92,13 @@ class CreateSoftwareDeployStrategyView(forms.ModalFormView):
|
||||
return context
|
||||
|
||||
|
||||
class ApplySoftwareDeployStrategyView(forms.ModalFormView):
|
||||
form_class = ApplySoftwareDeployStrategyForm
|
||||
template_name = 'admin/software_management/apply_cloud_strategy.html'
|
||||
context_object_name = 'strategy'
|
||||
success_url = reverse_lazy("horizon:admin:software_management:index")
|
||||
|
||||
|
||||
class DetailStageView(tables.DataTableView):
|
||||
template_name = 'admin/software_management/_detail_stage.html'
|
||||
page_title = 'Stage Detail'
|
||||
|
@ -25,5 +25,5 @@
|
||||
|
||||
{% block modal-footer %}
|
||||
<a class="btn btn-default cancel" data-dismiss="modal">Cancel</a>
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Ok" %}" />
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Yes" %}" />
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user