Fix 'Edit Host' modal

When trying to edit a host, the modal is not able to save the changes
unless the max_cpu_mhz_configured parameter is modified since it's
set as required.

This change fixes that problem by setting the max_cpu_mhz_configured as
not required and removing the forced assignment during clean()
function.

Test Plan:
PASS: Change BMC type, IP, User and Password. Verify changes
are listed in system show command.
PASS: Modify host location, CPU frequency, Clock Synchronization.
Verify changes are listed in system show command.

Closes-Bug: 2000484

Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
Change-Id: Icb6d05fe170d9202e7cc01ede7154c8d2bb98c72
This commit is contained in:
Enzo Candotti 2022-12-26 16:38:51 -03:00
parent 40679dc464
commit 2cf939310e
2 changed files with 6 additions and 9 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2013-2021 Wind River Systems, Inc. # Copyright (c) 2013-2022 Wind River Systems, Inc.
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -141,6 +141,7 @@ class AddHostInfoAction(workflows.Action):
class UpdateHostInfoAction(workflows.Action): class UpdateHostInfoAction(workflows.Action):
failure_message = _('Unable to modify host "%s".')
host_id = forms.CharField(widget=forms.widgets.HiddenInput) host_id = forms.CharField(widget=forms.widgets.HiddenInput)
personality = forms.ChoiceField(label=_("Personality"), personality = forms.ChoiceField(label=_("Personality"),
@ -192,7 +193,7 @@ class UpdateHostInfoAction(workflows.Action):
label=_("Max CPU Frequency (MHz)"), label=_("Max CPU Frequency (MHz)"),
initial=1, initial=1,
min_value=1, min_value=1,
required=True, required=False,
widget=forms.TextInput( widget=forms.TextInput(
attrs={ attrs={
'class': 'switched', 'class': 'switched',
@ -283,9 +284,6 @@ class UpdateHostInfoAction(workflows.Action):
def clean(self): def clean(self):
cleaned_data = super(UpdateHostInfoAction, self).clean() cleaned_data = super(UpdateHostInfoAction, self).clean()
if cleaned_data['cpu_freq_config'] == 'max_cpu_mhz_allowed':
cleaned_data['max_cpu_mhz_configured'] = 'max_cpu_mhz_allowed'
disabled = self.fields['personality'].widget.attrs.get('disabled') disabled = self.fields['personality'].widget.attrs.get('disabled')
if disabled == 'disabled': if disabled == 'disabled':
if self.system_type == constants.TS_AIO: if self.system_type == constants.TS_AIO:
@ -316,7 +314,6 @@ class UpdateHostInfoAction(workflows.Action):
LOG.error(ce) LOG.error(ce)
msg = self.failure_message + " " + str(ce) msg = self.failure_message + " " + str(ce)
self.failure_message = msg self.failure_message = msg
exceptions.handle(request, msg)
return False return False
except Exception as e: except Exception as e:
msg = str(e) msg = str(e)

View File

@ -21,7 +21,7 @@ deps = -r{toxinidir}/test-requirements.txt
[testenv:linters] [testenv:linters]
basepython = python3 basepython = python3
whitelist_externals = bash allowlist_externals = bash
commands = commands =
bash -c "find {toxinidir} \ bash -c "find {toxinidir} \
-not \( -type d -name .?\* -prune \) \ -not \( -type d -name .?\* -prune \) \
@ -82,7 +82,7 @@ install_command = pip install -U {opts} {packages}
commands = commands =
rm -rf doc/build rm -rf doc/build
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whitelist_externals = rm allowlist_externals = rm
[testenv:releasenotes] [testenv:releasenotes]
basepython = python3 basepython = python3
@ -91,7 +91,7 @@ install_command = pip install -U {opts} {packages}
commands = commands =
rm -rf releasenotes/build rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
whitelist_externals = allowlist_externals =
rm rm
reno reno