Update export system config class and constants
Change-Id: I271444d34d223b366215e107a43e115464cb18f0
This commit is contained in:
parent
b957aeb454
commit
ed70d136ac
|
@ -1,21 +0,0 @@
|
|||
# Copyright (c) 2020-2021 Dell Inc. or its subsidiaries.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
|
||||
|
||||
class ExportActionField(common.ActionField):
|
||||
allowed_values = base.Field('ShareParameters',
|
||||
adapter=dict)
|
|
@ -14,19 +14,19 @@
|
|||
|
||||
# export system config action constants
|
||||
|
||||
EXPORT_ALL_CONFIG = 'all'
|
||||
EXPORT_TARGET_ALL = 'all'
|
||||
"""Export entire system configuration"""
|
||||
|
||||
EXPORT_BIOS_CONFIG = 'BIOS'
|
||||
EXPORT_TARGET_BIOS = 'BIOS'
|
||||
"""Export BIOS related configuration"""
|
||||
|
||||
EXPORT_IDRAC_CONFIG = 'iDRAC'
|
||||
EXPORT_TARGET_IDRAC = 'iDRAC'
|
||||
"""Export IDRAC related configuration"""
|
||||
|
||||
EXPORT_NIC_CONFIG = 'NIC'
|
||||
EXPORT_TARGET_NIC = 'NIC'
|
||||
"""Export NIC related configuration"""
|
||||
|
||||
EXPORT_RAID_CONFIG = 'RAID'
|
||||
EXPORT_TARGET_RAID = 'RAID'
|
||||
"""Export RAID related configuration"""
|
||||
|
||||
# iDRAC Reset action constants
|
||||
|
|
|
@ -23,7 +23,6 @@ from sushy import utils as sushy_utils
|
|||
|
||||
from sushy_oem_idrac import asynchronous
|
||||
from sushy_oem_idrac import constants
|
||||
from sushy_oem_idrac.resources import common as res_common
|
||||
from sushy_oem_idrac.resources.manager import constants as mgr_cons
|
||||
from sushy_oem_idrac.resources.manager import idrac_card_service
|
||||
from sushy_oem_idrac.resources.manager import job_collection
|
||||
|
@ -41,12 +40,20 @@ _SYSTEM_CONFIG_TAG = "SystemConfiguration"
|
|||
_RESPONSE_OK_CODE = 200
|
||||
|
||||
|
||||
class SharedParameters(base.CompositeField):
|
||||
allowed_target_values = base.Field('Target@Redfish.AllowableValues')
|
||||
|
||||
|
||||
class ExportActionField(common.ActionField):
|
||||
shared_parameters = SharedParameters('ShareParameters')
|
||||
|
||||
|
||||
class DellManagerActionsField(base.CompositeField):
|
||||
import_system_configuration = common.ActionField(
|
||||
lambda key, **kwargs: key.endswith(
|
||||
'#OemManager.ImportSystemConfiguration'))
|
||||
|
||||
export_system_configuration = res_common.ExportActionField(
|
||||
export_system_configuration = ExportActionField(
|
||||
lambda key, **kwargs: key.endswith(
|
||||
'#OemManager.ExportSystemConfiguration'))
|
||||
|
||||
|
@ -245,14 +252,13 @@ VFDD\
|
|||
|
||||
attempts -= 1
|
||||
|
||||
def get_allowed_export_system_config_values(self):
|
||||
"""Get the allowed values of export system configuration.
|
||||
def get_allowed_export_target_values(self):
|
||||
"""Get the allowed targets of export system configuration.
|
||||
|
||||
:returns: A set of allowed values.
|
||||
"""
|
||||
export_action = self._actions.export_system_configuration
|
||||
allowed_values = export_action.allowed_values[
|
||||
'Target@Redfish.AllowableValues']
|
||||
allowed_values = export_action.shared_parameters.allowed_target_values
|
||||
|
||||
return set([mgr_maps.EXPORT_CONFIG_VALUE_MAP[value] for value in
|
||||
set(mgr_maps.EXPORT_CONFIG_VALUE_MAP).
|
||||
|
@ -267,14 +273,14 @@ VFDD\
|
|||
:param target: Component of the system to export the
|
||||
configuration from. Can be the entire system.
|
||||
Valid values can be gotten from
|
||||
`get_allowed_export_system_config_values`.
|
||||
`get_allowed_export_target_values`.
|
||||
:returns: a response object containing configuration details for
|
||||
the specified target.
|
||||
:raises: InvalidParameterValueError on invalid target.
|
||||
:raises: ExtensionError on failure to perform requested
|
||||
operation
|
||||
"""
|
||||
valid_allowed_targets = self.get_allowed_export_system_config_values()
|
||||
valid_allowed_targets = self.get_allowed_export_target_values()
|
||||
if target not in valid_allowed_targets:
|
||||
raise sushy.exceptions.InvalidParameterValueError(
|
||||
parameter='target', value=target,
|
||||
|
@ -316,7 +322,7 @@ VFDD\
|
|||
pxe_port_macs = []
|
||||
# Get NIC configuration
|
||||
nic_settings = self._export_system_configuration(
|
||||
target=mgr_cons.EXPORT_NIC_CONFIG)
|
||||
target=mgr_cons.EXPORT_TARGET_NIC)
|
||||
|
||||
if nic_settings.status_code != _RESPONSE_OK_CODE:
|
||||
error = (('An error occurred when attempting to export '
|
||||
|
|
|
@ -17,11 +17,11 @@ from sushy import utils
|
|||
from sushy_oem_idrac.resources.manager import constants as mgr_cons
|
||||
|
||||
EXPORT_CONFIG_VALUE_MAP = {
|
||||
'ALL': mgr_cons.EXPORT_ALL_CONFIG,
|
||||
'BIOS': mgr_cons.EXPORT_BIOS_CONFIG,
|
||||
'IDRAC': mgr_cons.EXPORT_IDRAC_CONFIG,
|
||||
'NIC': mgr_cons.EXPORT_NIC_CONFIG,
|
||||
'RAID': mgr_cons.EXPORT_RAID_CONFIG
|
||||
'ALL': mgr_cons.EXPORT_TARGET_ALL,
|
||||
'BIOS': mgr_cons.EXPORT_TARGET_BIOS,
|
||||
'IDRAC': mgr_cons.EXPORT_TARGET_IDRAC,
|
||||
'NIC': mgr_cons.EXPORT_TARGET_NIC,
|
||||
'RAID': mgr_cons.EXPORT_TARGET_RAID
|
||||
}
|
||||
|
||||
EXPORT_CONFIG_VALUE_MAP_REV = utils.revert_dictionary(EXPORT_CONFIG_VALUE_MAP)
|
||||
|
|
|
@ -67,14 +67,14 @@ class ManagerTestCase(BaseTestCase):
|
|||
'.ImportSystemConfiguration', data=mock.ANY)
|
||||
|
||||
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
|
||||
def test_get_allowed_export_system_config_values(self):
|
||||
def test_get_allowed_export_target_values(self):
|
||||
oem = self.manager.get_oem_extension('Dell')
|
||||
expected_values = {mgr_cons.EXPORT_IDRAC_CONFIG,
|
||||
mgr_cons.EXPORT_RAID_CONFIG,
|
||||
mgr_cons.EXPORT_ALL_CONFIG,
|
||||
mgr_cons.EXPORT_BIOS_CONFIG,
|
||||
mgr_cons.EXPORT_NIC_CONFIG}
|
||||
allowed_values = oem.get_allowed_export_system_config_values()
|
||||
expected_values = {mgr_cons.EXPORT_TARGET_IDRAC,
|
||||
mgr_cons.EXPORT_TARGET_RAID,
|
||||
mgr_cons.EXPORT_TARGET_ALL,
|
||||
mgr_cons.EXPORT_TARGET_BIOS,
|
||||
mgr_cons.EXPORT_TARGET_NIC}
|
||||
allowed_values = oem.get_allowed_export_target_values()
|
||||
self.assertEqual(expected_values, allowed_values)
|
||||
|
||||
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
|
||||
|
@ -90,7 +90,7 @@ class ManagerTestCase(BaseTestCase):
|
|||
def test__export_system_configuration(self):
|
||||
oem = self.manager.get_oem_extension('Dell')
|
||||
oem._export_system_configuration(
|
||||
target=mgr_cons.EXPORT_ALL_CONFIG)
|
||||
target=mgr_cons.EXPORT_TARGET_ALL)
|
||||
|
||||
self.conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager'
|
||||
|
|
Loading…
Reference in New Issue