Add "Apparmor Module" on Edit Host modal
This change adds a dropdown menu in order to enable or disable the apparmor module when updating a host. By default, apparmor will be disabled on creation and this value can be modified using the Edit Host button, or system host-update command. Test Plan: PASS: Build and install starlingx-dashboard package. Verify that the changes are applied. PASS: Edit a locked host in order to change the apparmor value. Verify that the change impacts when running system host-show command. PASS: Edit a unlocked host by changing the apparmor value. Verify that an error message is shown since the host has to be locked. PASS: Verify that the correct apparmor value is shown in "Host Detail" page. Story: 2010310 Task: 47249 Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com> Change-Id: I814896806479e141ce86961cc08b48da5600afed
This commit is contained in:
parent
5e81ff8710
commit
adbbfc3fa5
|
@ -32,6 +32,9 @@ import sysinv.common.constants as constants
|
|||
SYSTEM_TYPE_STANDARD = constants.TIS_STD_BUILD
|
||||
SYSTEM_TYPE_AIO = constants.TIS_AIO_BUILD
|
||||
|
||||
APPARMOR_STATE_ENABLED = constants.APPARMOR_STATE_ENABLED
|
||||
APPARMOR_STATE_DISABLED = constants.APPARMOR_STATE_DISABLED
|
||||
|
||||
PERSONALITY_CONTROLLER = 'controller'
|
||||
PERSONALITY_WORKER = 'worker'
|
||||
PERSONALITY_NETWORK = 'network'
|
||||
|
@ -841,8 +844,8 @@ class Host(base.APIResourceWrapper):
|
|||
|
||||
_attrs = ['id', 'uuid', 'hostname', 'personality',
|
||||
'subfunctions', 'subfunction_oper', 'subfunction_avail',
|
||||
'location', 'serialid', 'operational', 'administrative',
|
||||
'invprovision', 'peers',
|
||||
'apparmor', 'location', 'serialid', 'operational',
|
||||
'administrative', 'invprovision', 'peers',
|
||||
'availability', 'uptime', 'task', 'capabilities',
|
||||
'created_at', 'updated_at', 'mgmt_mac', 'mgmt_ip',
|
||||
'bm_ip', 'bm_type', 'bm_username',
|
||||
|
@ -867,6 +870,12 @@ class Host(base.APIResourceWrapper):
|
|||
('disabled', _("Disabled")),
|
||||
('enabled', _("Enabled")),
|
||||
)
|
||||
|
||||
APPARMOR_DISPLAY_CHOICES = (
|
||||
(APPARMOR_STATE_ENABLED, _("enabled")),
|
||||
(APPARMOR_STATE_DISABLED, _("disabled")),
|
||||
)
|
||||
|
||||
AVAIL_DISPLAY_CHOICES = (
|
||||
('available', _("Available")),
|
||||
('intest', _("In-Test")),
|
||||
|
@ -909,6 +918,7 @@ class Host(base.APIResourceWrapper):
|
|||
self._subfunctions = self.subfunctions
|
||||
self._subfunction_oper = self.subfunction_oper
|
||||
self._subfunction_avail = self.subfunction_avail
|
||||
self._apparmor = self.apparmor
|
||||
self._location = self.location
|
||||
self._peers = self.peers
|
||||
self._bm_type = self.bm_type
|
||||
|
@ -968,6 +978,11 @@ class Host(base.APIResourceWrapper):
|
|||
return self._get_display_value(self.AVAIL_DISPLAY_CHOICES,
|
||||
self._subfunction_avail)
|
||||
|
||||
@property
|
||||
def apparmor(self):
|
||||
return self._get_display_value(self.APPARMOR_DISPLAY_CHOICES,
|
||||
self._apparmor)
|
||||
|
||||
@property
|
||||
def config_required(self):
|
||||
return self.config_status == 'config required'
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<dd>{{ host.serialid }}</dd>
|
||||
<dt>{% trans "Location" %}</dt>
|
||||
<dd>{{ host.location|default:_("Not Specified") }}</dd>
|
||||
<dt>{% trans "AppArmor Module" %}</dt>
|
||||
<dd>{{ host.apparmor }}</dd>
|
||||
<dt>{% trans "Serial Line Carrier Detect" %}</dt>
|
||||
<dd>{{ host.ttys_dcd }}</dd>
|
||||
<dt>{% trans "Clock Synchronization" %}</dt>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2023 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -75,6 +75,7 @@ class UpdateView(workflows.WorkflowView):
|
|||
'hostname': host.hostname,
|
||||
'personality': host._personality,
|
||||
'subfunctions': host._subfunctions,
|
||||
'apparmor': host.apparmor,
|
||||
'location': host.location,
|
||||
'bm_type': host.bm_type,
|
||||
'bm_ip': host.bm_ip,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2022 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2023 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -219,6 +219,11 @@ class UpdateHostInfoAction(workflows.Action):
|
|||
"port revoke any active session and a new login "
|
||||
"process is initiated when a new connection is detected."))
|
||||
|
||||
apparmor = forms.ChoiceField(
|
||||
label=_("AppArmor Module"),
|
||||
required=False,
|
||||
choices=stx_api.sysinv.Host.APPARMOR_DISPLAY_CHOICES)
|
||||
|
||||
class Meta(object):
|
||||
name = _("Host Info")
|
||||
help_text = _(
|
||||
|
@ -334,6 +339,7 @@ class UpdateHostInfo(workflows.Step):
|
|||
contributes = ("host_id",
|
||||
"personality",
|
||||
"subfunctions",
|
||||
"apparmor",
|
||||
"hostname",
|
||||
"location",
|
||||
"ttys_dcd",
|
||||
|
@ -636,6 +642,10 @@ class UpdateHost(workflows.Workflow):
|
|||
if host.clock_synchronization == data['clock_synchronization']:
|
||||
data.pop('clock_synchronization')
|
||||
|
||||
# if not trying to change apparmor choice, skip check
|
||||
if host.apparmor == data['apparmor']:
|
||||
data.pop('apparmor')
|
||||
|
||||
host = stx_api.sysinv.host_update(request, **data)
|
||||
return True if host else False
|
||||
|
||||
|
|
Loading…
Reference in New Issue