Tie vswitch core changes to openstack-compute label

Only allow vswitch cpu core changes if the host has the following label
openstack-compute-node=enabled

Change-Id: I23944ad1b7b61dbe7f287d55fb8ebc9a8901aa86
Story: 2004022
Task: 28948
Depends-On: https://review.openstack.org/#/c/631540
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
This commit is contained in:
David Sullivan 2019-01-17 10:58:43 -05:00
parent 37f5a0f048
commit 88d5b2e3ba
3 changed files with 22 additions and 3 deletions

View File

@ -18,6 +18,8 @@ from horizon import forms
from horizon import messages
from starlingx_dashboard.api import sysinv
from starlingx_dashboard.dashboards.admin.inventory.cpu_functions \
import utils as cpufunctions_utils
from starlingx_dashboard.horizon.forms.fields import DynamicIntegerField
LOG = logging.getLogger(__name__)
@ -146,7 +148,8 @@ class UpdateCpuFunctions(forms.SelfHandlingForm):
'platform_processor3'].help_text = \
"Processor 3 has %s physical cores." % avail_socket_cores
if 'worker' not in self.host.subfunctions:
if 'worker' not in self.host.subfunctions \
or not cpufunctions_utils.has_openstack_compute(self.host):
self.fields['vswitch'].widget = forms.widgets.HiddenInput()
self.fields[
'num_cores_on_processor0'].widget = forms.widgets.HiddenInput()

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2015 Wind River Systems, Inc.
# Copyright (c) 2013-2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -12,6 +12,7 @@ VSWITCH_CPU_TYPE = "Vswitch"
SHARED_CPU_TYPE = "Shared"
APPLICATIONS_CPU_TYPE = "Applications"
NONE_CPU_TYPE = "None"
COMPUTE_NODE_LABEL_KEY = 'openstack-compute-node'
CPU_TYPE_LIST = [PLATFORM_CPU_TYPE, VSWITCH_CPU_TYPE,
SHARED_CPU_TYPE, APPLICATIONS_CPU_TYPE,
@ -235,3 +236,17 @@ def check_core_functions(personality, icpus):
error_string = "There must be at least one" \
" core for %s." % APPLICATIONS_CPU_TYPE_FORMAT
return error_string
def has_openstack_compute(host):
"""Returns true if the host has the openstack compute label set """
labels = host.labels
if not labels:
return False
for label in labels:
if label.label_key == COMPUTE_NODE_LABEL_KEY:
return 'enabled' == label.label_value.lower()
# We haven't found the openstack compute node key. Return False
return False

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2015 Wind River Systems, Inc.
# Copyright (c) 2013-2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -44,6 +44,7 @@ class UpdateCpuFunctionsView(forms.ModalFormView):
host = sysinv.host_get(self.request, host_id)
host.nodes = sysinv.host_node_list(self.request, host.uuid)
host.cpus = sysinv.host_cpu_list(self.request, host.uuid)
host.labels = sysinv.host_label_list(self.request, host.uuid)
icpu_utils.restructure_host_cpu_data(host)
self._object = host
self._object.host_id = host_id