From d1c22e49a95f92e91049b96f44e685f46785977c Mon Sep 17 00:00:00 2001 From: Bin Qian Date: Fri, 29 Nov 2019 10:17:31 -0500 Subject: [PATCH] Use new board management type enumuration Change horizon to list new board management type enumeration list below: redfish ipmi dynamic none (bm is not provisioned) Closes-Bug: 1852328 Depends-On: https://review.opendev.org/#/c/698281 Change-Id: If64eff8b0ee63509bdada6bba05847d292ce8032 Signed-off-by: Bin Qian --- .../starlingx_dashboard/api/sysinv.py | 16 +++----- .../dashboards/admin/inventory/workflows.py | 37 ++++++++++++++----- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py index d18e387b..68af178a 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py @@ -21,7 +21,6 @@ import math from cgtsclient.v1 import client as cgts_client from cgtsclient.v1 import icpu as icpu_utils - from django.conf import settings from django.utils import timezone from django.utils.translation import ugettext_lazy as _ @@ -43,10 +42,6 @@ PERSONALITY_UNKNOWN = 'unknown' SUBFUNCTIONS_WORKER = 'worker' SUBFUNCTIONS_LOWLATENCY = 'lowlatency' -BM_TYPE_NULL = '' -BM_TYPE_NONE = 'none' -BM_TYPE_GENERIC = 'bmc' - RECORDTYPE_INSTALL = 'install' RECORDTYPE_INSTALL_ANSWER = 'install_answers' RECORDTYPE_RECONFIG = 'reconfig' @@ -108,6 +103,12 @@ CLOCK_SYNCHRONIZATION_CHOICES = ( (constants.PTP, _("ptp")), ) +# Host Board Management Constants +HOST_BM_TYPE_DEPROVISIONED = "none" +HOST_BM_TYPE_IPMI = "ipmi" +HOST_BM_TYPE_REDFISH = "redfish" +HOST_BM_TYPE_DYNAMIC = "dynamic" + LOG = logging.getLogger(__name__) @@ -1009,11 +1010,6 @@ class Host(base.APIResourceWrapper): @property def bm_type(self): bm_type = self._bm_type - if bm_type and not bm_type.lower().startswith(BM_TYPE_NONE): - bm_type = BM_TYPE_GENERIC - else: - bm_type = BM_TYPE_NULL - return bm_type @property diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/workflows.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/workflows.py index 18b470f9..63999a2c 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/workflows.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/workflows.py @@ -51,8 +51,10 @@ PERSONALITY_CHOICE_CONTROLLER = ( ) BM_TYPES_CHOICES = ( - (stx_api.sysinv.BM_TYPE_NULL, _('No Board Management')), - (stx_api.sysinv.BM_TYPE_GENERIC, _("Board Management Controller")), + (sysinv.HOST_BM_TYPE_DEPROVISIONED, _('No Board Management')), + (sysinv.HOST_BM_TYPE_DYNAMIC, _("Dynamic (learn)")), + (sysinv.HOST_BM_TYPE_IPMI, _("IPMI")), + (sysinv.HOST_BM_TYPE_REDFISH, _("Redfish")), ) @@ -589,8 +591,12 @@ class BoardManagementAction(workflows.Action): widget=forms.TextInput(attrs={ 'class': 'switched', 'data-switch-on': 'bm_type', - 'data-bm_type-' + - stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_IP})) + 'data-bm_type-' + sysinv.HOST_BM_TYPE_DYNAMIC: + FIELD_LABEL_BM_IP, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_IPMI: + FIELD_LABEL_BM_IP, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_REDFISH: + FIELD_LABEL_BM_IP})) bm_username = forms.CharField( label=FIELD_LABEL_BM_USERNAME, @@ -599,8 +605,12 @@ class BoardManagementAction(workflows.Action): 'autocomplete': 'off', 'class': 'switched', 'data-switch-on': 'bm_type', - 'data-bm_type-' + - stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_USERNAME})) + 'data-bm_type-' + sysinv.HOST_BM_TYPE_DYNAMIC: + FIELD_LABEL_BM_USERNAME, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_IPMI: + FIELD_LABEL_BM_USERNAME, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_REDFISH: + FIELD_LABEL_BM_USERNAME})) bm_password = forms.RegexField( label=FIELD_LABEL_BM_PASSWORD, @@ -610,8 +620,12 @@ class BoardManagementAction(workflows.Action): 'autocomplete': 'off', 'class': 'switched', 'data-switch-on': 'bm_type', - 'data-bm_type-' + - stx_api.sysinv.BM_TYPE_GENERIC: FIELD_LABEL_BM_PASSWORD}), + 'data-bm_type-' + sysinv.HOST_BM_TYPE_DYNAMIC: + FIELD_LABEL_BM_PASSWORD, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_IPMI: + FIELD_LABEL_BM_PASSWORD, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_REDFISH: + FIELD_LABEL_BM_PASSWORD}), regex=validators.password_validator(), required=False, error_messages={'invalid': validators.password_validator_msg()}) @@ -624,8 +638,11 @@ class BoardManagementAction(workflows.Action): 'autocomplete': 'off', 'class': 'switched', 'data-switch-on': 'bm_type', - 'data-bm_type-' + - stx_api.sysinv.BM_TYPE_GENERIC: + 'data-bm_type-' + sysinv.HOST_BM_TYPE_DYNAMIC: + FIELD_LABEL_BM_CONFIRM_PASSWORD, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_IPMI: + FIELD_LABEL_BM_CONFIRM_PASSWORD, + 'data-bm_type-' + sysinv.HOST_BM_TYPE_REDFISH: FIELD_LABEL_BM_CONFIRM_PASSWORD}), required=False)