Merge "Migrate constants to enums"

This commit is contained in:
Zuul 2022-01-13 13:43:33 +00:00 committed by Gerrit Code Review
commit 7b75e6ea89
14 changed files with 419 additions and 443 deletions

View File

@ -4,4 +4,4 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
python-dateutil>=2.7.0 # BSD
sushy>=3.11.0 # Apache-2.0
sushy>=4.0.0 # Apache-2.0

View File

@ -12,102 +12,149 @@
# License for the specific language governing permissions and limitations
# under the License.
# export system config action constants
EXPORT_TARGET_ALL = 'all'
"""Export entire system configuration"""
EXPORT_TARGET_BIOS = 'BIOS'
"""Export BIOS related configuration"""
EXPORT_TARGET_IDRAC = 'iDRAC'
"""Export IDRAC related configuration"""
EXPORT_TARGET_NIC = 'NIC'
"""Export NIC related configuration"""
EXPORT_TARGET_RAID = 'RAID'
"""Export RAID related configuration"""
# iDRAC Reset action constants
import enum
RESET_IDRAC_GRACEFUL_RESTART = 'graceful restart'
"""Perform a graceful shutdown followed by a restart of the system"""
class ExportTarget(enum.Enum):
"""Export system config action constants"""
RESET_IDRAC_FORCE_RESTART = 'force restart'
"""Perform an immediate (non-graceful) shutdown, followed by a restart"""
ALL = 'ALL'
"""Export entire system configuration"""
# ImportSystemConfiguration ShutdownType values
IMPORT_SHUTDOWN_GRACEFUL = 'graceful shutdown'
"""Graceful shutdown for Import System Configuration
BIOS = 'BIOS'
"""Export BIOS related configuration"""
Will wait for the host up to 5 minutes to shut down before timing out. The
operating system can potentially deny or ignore the graceful shutdown request.
"""
IDRAC = 'IDRAC'
"""Export iDRAC related configuration"""
IMPORT_SHUTDOWN_FORCED = 'forced shutdown'
"""Forced shutdown for Import System Configuration
NIC = 'NIC'
"""Export NIC related configuration"""
The host server will be powered off immediately. Should be used when it is safe
to power down the host.
"""
RAID = 'RAID'
"""Export RAID related configuration"""
IMPORT_SHUTDOWN_NO_REBOOT = 'no shutdown'
"""No reboot for Import System Configuration
No shutdown performed. Explicit reboot is necessary to apply changes.
"""
# Backward compatibility
EXPORT_TARGET_ALL = ExportTarget.ALL
EXPORT_TARGET_BIOS = ExportTarget.BIOS
EXPORT_TARGET_IDRAC = ExportTarget.IDRAC
EXPORT_TARGET_NIC = ExportTarget.NIC
EXPORT_TARGET_RAID = ExportTarget.RAID
# ExportUse in ExportSystemConfiguration
EXPORT_USE_DEFAULT = 'Default'
"""Default export type
Leaves some attributes commented out and requires user to enable them before
they can be applied during import.
"""
class ResetType(enum.Enum):
"""iDRAC Reset reset type constants"""
EXPORT_USE_CLONE = 'Clone'
"""Clone export type suitable for cloning a 'golden' configuration.
GRACEFUL = 'Graceful'
"""Perform a graceful shutdown followed by a restart of the system"""
Compared to Default export type, more attributes are enabled and
storage settings adjusted to aid in cloning process.
"""
FORCE = 'Force'
"""Perform an immediate (non-graceful) shutdown, followed by a restart"""
EXPORT_USE_REPLACE = 'Replace'
"""Replace export type suited for retiring or replacing complete configuration.
Compared to Clone export type, most attributes are enabled and storage settings
adjusted to aid in the replace process.
"""
# Backward compatibility
RESET_IDRAC_GRACEFUL_RESTART = ResetType.GRACEFUL
RESET_IDRAC_FORCE_RESTART = ResetType.FORCE
# IncludeInExport in ExportSystemConfiguration
INCLUDE_EXPORT_DEFAULT = 'Default'
"""Default for what to include in export.
Does not include read-only attributes, and depending on Export Use, passwords
are marked as ****** (for Default) or are set to default password values (for
Clone and Replace).
"""
class ShutdownType(enum.Enum):
"""ImportSystemConfiguration ShutdownType values"""
INCLUDE_EXPORT_READ_ONLY = 'Include read only attributes'
"""Includes read-only attributes.
GRACEFUL = 'Graceful'
"""Graceful shutdown for Import System Configuration
In addition to values included by Default option, this also includes read-only
attributes that cannot be changed via Import and are provided for informational
purposes only.
"""
Will wait for the host up to 5 minutes to shut down before timing out. The
operating system can potentially deny or ignore the graceful shutdown
request.
"""
INCLUDE_EXPORT_PASSWORD_HASHES = 'Include password hash values'
"""Include password hashes.
FORCED = 'Forced'
"""Forced shutdown for Import System Configuration
When using Clone or Replace, include password hashes, instead of default
password. Can be used to replicate passwords across systems.
"""
The host server will be powered off immediately. Should be used when it is
safe to power down the host.
"""
INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES = ('Include read only attributes and '
'password hash values')
"""Includes both read-only attributes and password hashes.
NO_REBOOT = 'NoReboot'
"""No reboot for Import System Configuration
INCLUDE_EXPORT_READ_ONLY and INCLUDE_EXPORT_PASSWORD_HASHES combined
"""
No shutdown performed. Explicit reboot is necessary to apply changes.
"""
# Backward compatibility
IMPORT_SHUTDOWN_GRACEFUL = ShutdownType.GRACEFUL
IMPORT_SHUTDOWN_FORCED = ShutdownType.FORCED
IMPORT_SHUTDOWN_NO_REBOOT = ShutdownType.NO_REBOOT
class ExportUse(enum.Enum):
"""ExportUse in ExportSystemConfiguration"""
DEFAULT = 'Default'
"""Default export type
Leaves some attributes commented out and requires user to enable them
before they can be applied during import.
"""
CLONE = 'Clone'
"""Clone export type suitable for cloning a 'golden' configuration.
Compared to Default export type, more attributes are enabled and
storage settings adjusted to aid in cloning process.
"""
REPLACE = 'Replace'
"""Replace export type suited for replacing complete configuration.
Compared to Clone export type, most attributes are enabled and storage
settings adjusted to aid in the replace process.
"""
# Backward compatibility
EXPORT_USE_DEFAULT = ExportUse.DEFAULT
EXPORT_USE_CLONE = ExportUse.CLONE
EXPORT_USE_REPLACE = ExportUse.REPLACE
class IncludeInExport(enum.Enum):
"""IncludeInExport in ExportSystemConfiguration"""
DEFAULT = 'Default'
"""Default for what to include in export.
Does not include read-only attributes, and depending on Export Use,
passwords are marked as ****** (for Default) or are set to default password
values (for Clone and Replace).
"""
READ_ONLY = 'IncludeReadOnly'
"""Includes read-only attributes.
In addition to values included by Default option, this also includes
read-only attributes that cannot be changed via Import and are provided for
informational purposes only.
"""
PASSWORD_HASHES = 'IncludePasswordHashValues'
"""Include password hashes.
When using Clone or Replace, include password hashes, instead of default
password. Can be used to replicate passwords across systems.
"""
READ_ONLY_PASSWORD_HASHES = ('IncludeReadOnly,IncludePasswordHashValues')
"""Includes both read-only attributes and password hashes.
INCLUDE_EXPORT_READ_ONLY and INCLUDE_EXPORT_PASSWORD_HASHES combined
"""
# Backward compatibility
INCLUDE_EXPORT_DEFAULT = IncludeInExport.DEFAULT
INCLUDE_EXPORT_READ_ONLY = IncludeInExport.READ_ONLY
INCLUDE_EXPORT_PASSWORD_HASHES = IncludeInExport.PASSWORD_HASHES
INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES =\
IncludeInExport.READ_ONLY_PASSWORD_HASHES

View File

@ -18,7 +18,6 @@ from sushy import exceptions
from sushy.resources import base
from sushy_oem_idrac.resources.manager import constants as mgr_cons
from sushy_oem_idrac.resources.manager import mappings as mgr_maps
LOG = logging.getLogger(__name__)
@ -62,24 +61,22 @@ class DelliDRACCardService(base.ResourceBase):
if not reset_action.allowed_values:
LOG.warning('Could not figure out the allowed values for the '
'reset idrac action for %s', self.identity)
return set(mgr_maps.RESET_IDRAC_VALUE_MAP_REV)
return set(mgr_cons.ResetType)
return set([mgr_maps.RESET_IDRAC_VALUE_MAP[value] for value in
set(mgr_maps.RESET_IDRAC_VALUE_MAP).
intersection(reset_action.allowed_values)])
return {v for v in mgr_cons.ResetType
if v.value in reset_action.allowed_values}
def reset_idrac(self):
"""Reset the iDRAC.
"""
reset_type = mgr_cons.RESET_IDRAC_GRACEFUL_RESTART
reset_type = mgr_cons.ResetType.GRACEFUL
valid_resets = self.get_allowed_reset_idrac_values()
if reset_type not in valid_resets:
raise exceptions.InvalidParameterValueError(
parameter='value', value=reset_type, valid_values=valid_resets)
reset_type = mgr_maps.RESET_IDRAC_VALUE_MAP_REV[reset_type]
target_uri = self._actions.reset_idrac.target_uri
payload = {"Force": reset_type}
payload = {"Force": reset_type.value}
LOG.debug('Resetting the iDRAC %s ...', self.identity)
self._conn.post(target_uri, data=payload)
LOG.info('The iDRAC %s is being reset', self.identity)

View File

@ -32,7 +32,6 @@ from sushy_oem_idrac.resources.manager import idrac_card_service
from sushy_oem_idrac.resources.manager import job_collection
from sushy_oem_idrac.resources.manager import job_service
from sushy_oem_idrac.resources.manager import lifecycle_service
from sushy_oem_idrac.resources.manager import mappings as mgr_maps
from sushy_oem_idrac import utils
LOG = logging.getLogger(__name__)
@ -289,11 +288,9 @@ VFDD\
LOG.warning('Could not figure out the allowed values for the '
'target of export system configuration at %s',
self.path)
return set(mgr_maps.EXPORT_CONFIG_VALUE_MAP_REV)
return set(mgr_cons.ExportTarget)
return set([mgr_maps.EXPORT_CONFIG_VALUE_MAP[value] for value in
set(mgr_maps.EXPORT_CONFIG_VALUE_MAP).
intersection(allowed_values)])
return {v for v in mgr_cons.ExportTarget if v.value in allowed_values}
def get_allowed_export_use_values(self):
"""Get allowed export use values of export system configuration.
@ -307,11 +304,9 @@ VFDD\
LOG.warning('Could not figure out the allowed values for the '
'export use of export system configuration at %s',
self.path)
return set(mgr_maps.EXPORT_USE_VALUE_MAP_REV)
return set(mgr_cons.ExportUse)
return set([mgr_maps.EXPORT_USE_VALUE_MAP[value] for value in
set(mgr_maps.EXPORT_USE_VALUE_MAP).
intersection(allowed_values)])
return {v for v in mgr_cons.ExportUse if v.value in allowed_values}
def get_allowed_include_in_export_values(self):
"""Get allowed include in export values of export system configuration.
@ -325,15 +320,14 @@ VFDD\
LOG.warning('Could not figure out the allowed values for the '
'include in export of export system configuration at '
'%s', self.path)
return set(mgr_maps.INCLUDE_EXPORT_VALUE_MAP_REV)
return set(mgr_cons.IncludeInExport)
return set([mgr_maps.INCLUDE_EXPORT_VALUE_MAP[value] for value
in set(mgr_maps.INCLUDE_EXPORT_VALUE_MAP).
intersection(allowed_values)])
return {v for v in mgr_cons.IncludeInExport
if v.value in allowed_values}
def _export_system_configuration(
self, target, export_use=mgr_cons.EXPORT_USE_DEFAULT,
include_in_export=mgr_cons.INCLUDE_EXPORT_DEFAULT):
self, target, export_use=mgr_cons.ExportUse.DEFAULT,
include_in_export=mgr_cons.IncludeInExport.DEFAULT):
"""Export system configuration.
It exports system configuration for specified target like NIC, BIOS,
@ -371,26 +365,25 @@ VFDD\
# Older iDRACs used to include comma separated option in
# AllowableValues but got removed in newer versions violating
# AllowableValues validation logic.
include_in_export_rev =\
mgr_maps.INCLUDE_EXPORT_VALUE_MAP_REV.get(include_in_export)
all_items_valid = False
if include_in_export_rev is not None:
items = include_in_export_rev.split(',')
all_items_valid = True
all_items_valid = True
if not isinstance(include_in_export, mgr_cons.IncludeInExport):
all_items_valid = False
else:
items = include_in_export.value.split(',')
for item in items:
if (mgr_maps.INCLUDE_EXPORT_VALUE_MAP[item]
if (mgr_cons.IncludeInExport(item)
not in allowed_include_in_export):
all_items_valid = False
break
if not all_items_valid:
raise sushy.exceptions.InvalidParameterValueError(
parameter='include_in_export', value=include_in_export,
valid_values=allowed_include_in_export)
target = mgr_maps.EXPORT_CONFIG_VALUE_MAP_REV[target]
export_use = mgr_maps.EXPORT_USE_VALUE_MAP_REV[export_use]
include_in_export =\
mgr_maps.INCLUDE_EXPORT_VALUE_MAP_REV[include_in_export]
target = mgr_cons.ExportTarget(target).value
export_use = mgr_cons.ExportUse(export_use).value
include_in_export = mgr_cons.IncludeInExport(include_in_export).value
action_data = {
'ShareParameters': {
@ -433,11 +426,11 @@ VFDD\
:raises: ExtensionError on failure to perform requested
operation
"""
include_in_export = mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
include_in_export = mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES
response = self._export_system_configuration(
mgr_cons.EXPORT_TARGET_ALL,
export_use=mgr_cons.EXPORT_USE_CLONE,
mgr_cons.ExportTarget.ALL,
export_use=mgr_cons.ExportUse.CLONE,
include_in_export=include_in_export)
if (response.status_code == _RESPONSE_OK_CODE
@ -466,7 +459,7 @@ VFDD\
pxe_port_macs = []
# Get NIC configuration
nic_settings = self._export_system_configuration(
target=mgr_cons.EXPORT_TARGET_NIC)
target=mgr_cons.ExportTarget.NIC)
if nic_settings.status_code != _RESPONSE_OK_CODE:
error = (('An error occurred when attempting to export '
@ -506,11 +499,10 @@ VFDD\
LOG.warning('Could not figure out the allowed values for the '
'shutdown type of import system configuration at %s',
self.path)
return set(mgr_maps.IMPORT_SHUTDOWN_VALUE_MAP_REV)
return set(mgr_cons.ShutdownType)
return set([mgr_maps.IMPORT_SHUTDOWN_VALUE_MAP[value] for value in
set(mgr_maps.IMPORT_SHUTDOWN_VALUE_MAP).
intersection(allowed_values)])
return {v for v in mgr_cons.ShutdownType
if v.value in allowed_values}
def import_system_configuration(self, import_buffer):
"""Imports system configuration.
@ -523,7 +515,7 @@ VFDD\
action_data = dict(self.ACTION_DATA, ImportBuffer=import_buffer)
# Caller needs to handle system reboot separately to preserve
# one-time boot settings.
shutdown_type = mgr_cons.IMPORT_SHUTDOWN_NO_REBOOT
shutdown_type = mgr_cons.ShutdownType.NO_REBOOT
allowed_shutdown_types = self.get_allowed_import_shutdown_type_values()
if shutdown_type not in allowed_shutdown_types:
@ -531,8 +523,7 @@ VFDD\
parameter='shutdown_type', value=shutdown_type,
valid_values=allowed_shutdown_types)
action_data['ShutdownType'] =\
mgr_maps.IMPORT_SHUTDOWN_VALUE_MAP_REV[shutdown_type]
action_data['ShutdownType'] = shutdown_type.value
response = self._conn.post(self.import_system_configuration_uri,
data=action_data)

View File

@ -1,63 +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 import utils
from sushy_oem_idrac.resources.manager import constants as mgr_cons
EXPORT_CONFIG_VALUE_MAP = {
'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)
RESET_IDRAC_VALUE_MAP = {
'Graceful': mgr_cons.RESET_IDRAC_GRACEFUL_RESTART,
'Force': mgr_cons.RESET_IDRAC_FORCE_RESTART,
}
RESET_IDRAC_VALUE_MAP_REV = utils.revert_dictionary(RESET_IDRAC_VALUE_MAP)
IMPORT_SHUTDOWN_VALUE_MAP = {
'Graceful': mgr_cons.IMPORT_SHUTDOWN_GRACEFUL,
'Forced': mgr_cons.IMPORT_SHUTDOWN_FORCED,
'NoReboot': mgr_cons.IMPORT_SHUTDOWN_NO_REBOOT
}
IMPORT_SHUTDOWN_VALUE_MAP_REV =\
utils.revert_dictionary(IMPORT_SHUTDOWN_VALUE_MAP)
EXPORT_USE_VALUE_MAP = {
'Default': mgr_cons.EXPORT_USE_DEFAULT,
'Clone': mgr_cons.EXPORT_USE_CLONE,
'Replace': mgr_cons.EXPORT_USE_REPLACE
}
EXPORT_USE_VALUE_MAP_REV = utils.revert_dictionary(EXPORT_USE_VALUE_MAP)
INCLUDE_EXPORT_VALUE_MAP = {
'Default': mgr_cons.INCLUDE_EXPORT_DEFAULT,
'IncludeReadOnly': mgr_cons.INCLUDE_EXPORT_READ_ONLY,
'IncludePasswordHashValues':
mgr_cons.INCLUDE_EXPORT_PASSWORD_HASHES,
'IncludeReadOnly,IncludePasswordHashValues':
mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
}
INCLUDE_EXPORT_VALUE_MAP_REV =\
utils.revert_dictionary(INCLUDE_EXPORT_VALUE_MAP)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
# Copyright (c) 2021-2022 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
@ -12,8 +12,19 @@
# License for the specific language governing permissions and limitations
# under the License.
PHYSICAL_DISK_STATE_MODE_RAID = 'RAID'
"""RAID mode"""
import enum
PHYSICAL_DISK_STATE_MODE_NONRAID = 'Non-RAID'
"""Non-RAID mode"""
class PhysicalDiskStateMode(enum.Enum):
"""Physical disk state mode constants"""
RAID = 'RAID'
"""RAID physical disk state mode"""
NONRAID = 'Non-RAID'
"""Non-RAID physical disk state mode"""
# For backward compatibility
PHYSICAL_DISK_STATE_MODE_RAID = PhysicalDiskStateMode.RAID
PHYSICAL_DISK_STATE_MODE_NONRAID = PhysicalDiskStateMode.NONRAID

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
# Copyright (c) 2021-2022 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
@ -25,8 +25,7 @@ def _filter_disks_not_in_mode(controller_to_disks, mode):
"""Filters disks that are not in requested mode
:param controller_to_disks: dictionary of controllers and their drives
:param mode: constants.PHYSICAL_DISK_STATE_MODE_RAID or
constants.PHYSICAL_DISK_STATE_MODE_NONRAID
:param mode: constants.PhysicalDiskStateMode
:returns: dictionary of controllers and their drives that need mode changed
"""
sushy_raw_device = sushy.VOLUME_TYPE_RAW_DEVICE
@ -45,9 +44,9 @@ def _filter_disks_not_in_mode(controller_to_disks, mode):
or volumes[0].raid_type is None)):
is_raw_device = True
if (mode == sys_cons.PHYSICAL_DISK_STATE_MODE_RAID
if (mode == sys_cons.PhysicalDiskStateMode.RAID
and is_raw_device
or mode == sys_cons.PHYSICAL_DISK_STATE_MODE_NONRAID
or mode == sys_cons.PhysicalDiskStateMode.NONRAID
and not is_raw_device):
toprocess_drives.append(drive)
controller_to_disks[controller] = toprocess_drives
@ -74,8 +73,7 @@ class DellSystemExtension(oem_base.OEMResourceBase):
Converts only those disks that are not already in requested mode.
:param mode: constants.PHYSICAL_DISK_STATE_MODE_RAID or
constants.PHYSICAL_DISK_STATE_MODE_NONRAID
:param mode: constants.PhysicalDiskStateMode
:param controller_to_disks: dictionary of controllers and their drives.
Optional, if not provided, processes all RAID, except BOSS,
controller drives.
@ -99,10 +97,10 @@ class DellSystemExtension(oem_base.OEMResourceBase):
for controller, drives in controller_to_disks.items():
if drives:
drive_fqdds = [d.identity for d in drives]
if mode == sys_cons.PHYSICAL_DISK_STATE_MODE_RAID:
if mode == sys_cons.PhysicalDiskStateMode.RAID:
task_monitors.append(
self.raid_service.convert_to_raid(drive_fqdds))
elif mode == sys_cons.PHYSICAL_DISK_STATE_MODE_NONRAID:
elif mode == sys_cons.PhysicalDiskStateMode.NONRAID:
task_monitors.append(
self.raid_service.convert_to_nonraid(drive_fqdds))

View File

@ -12,166 +12,234 @@
# License for the specific language governing permissions and limitations
# under the License.
# Job state constants
JOB_STATE_COMPLETED = "Completed"
"""A job is in completed state"""
import enum
JOB_STATE_COMPLETED_ERRORS = "Completed with errors"
"""A job is in completed state with errors"""
JOB_STATE_DOWNLOADED = "Downloaded"
"""A job is in downloaded state"""
class JobState(enum.Enum):
"""Job state constants"""
JOB_STATE_DOWNLOADING = "Downloading"
"""A job is in downloading state"""
COMPLETED = "Completed"
"""A job is in completed state"""
JOB_STATE_FAILED = "Failed"
"""A job is in failed state"""
COMPLETED_ERRORS = "CompletedWithErrors"
"""A job is in completed state with errors"""
JOB_STATE_NEW = "New"
"""A job is in newly created state"""
DOWNLOADED = "Downloaded"
"""A job is in downloaded state"""
JOB_STATE_PAUSED = "Paused"
"""A job is in paused state"""
DOWNLOADING = "Downloading"
"""A job is in downloading state"""
JOB_STATE_PENDING_ACTIVATION = "Pending activation"
"""A job is in pending activation state"""
FAILED = "Failed"
"""A job is in failed state"""
JOB_STATE_READY_EXECUTION = "Ready for execution"
"""A job is in ready for execution state"""
NEW = "New"
"""A job is in newly created state"""
JOB_STATE_REBOOT_COMPLETED = "Reboot completed"
"""A job is in reboot completed state"""
PAUSED = "Paused"
"""A job is in paused state"""
JOB_STATE_REBOOT_FAILED = "Reboot failed"
"""A job is in reboot failed state"""
PENDING_ACTIVATION = "PendingActivation"
"""A job is in pending activation state"""
JOB_STATE_REBOOT_PENDING = "Reboot pending"
"""A job is in pending state for reboot"""
READY_EXECUTION = "ReadyForExecution"
"""A job is in ready for execution state"""
JOB_STATE_RUNNING = "Running"
"""A job is in running state"""
REBOOT_COMPLETED = "RebootCompleted"
"""A job is in reboot completed state"""
JOB_STATE_SCHEDULED = "Scheduled"
"""A job is in scheduled state"""
REBOOT_FAILED = "RebootFailed"
"""A job is in reboot failed state"""
JOB_STATE_SCHEDULING = "Scheduling"
"""A job is in scheduling state"""
REBOOT_PENDING = "RebootPending"
"""A job is in pending state for reboot"""
JOB_STATE_UNKNOWN = "Unknown"
"""A job is in unknown state"""
RUNNING = "Running"
"""A job is in running state"""
JOB_STATE_WAITING = "Waiting"
"""A job is in waiting state"""
SCHEDULED = "Scheduled"
"""A job is in scheduled state"""
# Job type constants
JOB_TYPE_BIOS_CONF = "BIOS configuration"
"""A BIOS configuration job"""
SCHEDULING = "Scheduling"
"""A job is in scheduling state"""
JOB_TYPE_EXPORT_CONF = "Export configuration"
"""A server configuration profile export job"""
UNKNOWN = "Unknown"
"""A job is in unknown state"""
JOB_TYPE_FC_CONF = "Fibre Channel configuration"
"""A Fibre Channel configuration job"""
WAITING = "Waiting"
"""A job is in waiting state"""
JOB_TYPE_FACTORY_CONF_EXPORT = "Factory configuration export"
"""A factory configuration export job"""
JOB_TYPE_FIRMWARE_ROLLBACK = "Firmware rollback"
"""A firmware rollback job"""
# Backward compatibility
JOB_STATE_COMPLETED = JobState.COMPLETED
JOB_STATE_COMPLETED_ERRORS = JobState.COMPLETED_ERRORS
JOB_STATE_DOWNLOADED = JobState.DOWNLOADED
JOB_STATE_DOWNLOADING = JobState.DOWNLOADING
JOB_STATE_FAILED = JobState.FAILED
JOB_STATE_NEW = JobState.NEW
JOB_STATE_PAUSED = JobState.PAUSED
JOB_STATE_PENDING_ACTIVATION = JobState.PENDING_ACTIVATION
JOB_STATE_READY_EXECUTION = JobState.READY_EXECUTION
JOB_STATE_REBOOT_COMPLETED = JobState.REBOOT_COMPLETED
JOB_STATE_REBOOT_FAILED = JobState.REBOOT_FAILED
JOB_STATE_REBOOT_PENDING = JobState.REBOOT_PENDING
JOB_STATE_RUNNING = JobState.RUNNING
JOB_STATE_SCHEDULED = JobState.SCHEDULED
JOB_STATE_SCHEDULING = JobState.SCHEDULING
JOB_STATE_UNKNOWN = JobState.UNKNOWN
JOB_STATE_WAITING = JobState.WAITING
JOB_TYPE_FIRMWARE_UPDATE = "Firmware update"
"""A firmware update job"""
JOB_TYPE_HW_INVENTORY_EXPORT = "Hardware inventory export"
"""A hardware inventory export job"""
class JobType(enum.Enum):
"""Job type constants"""
JOB_TYPE_IMPORT_CONF = "Import configuration"
"""A server configuration profile import job"""
BIOS_CONF = "BIOSConfiguration"
"""A BIOS configuration job"""
JOB_TYPE_INBAND_BIOS_CONF = "Inband BIOS configuration"
"""An inband BIOS configuration job"""
EXPORT_CONF = "ExportConfiguration"
"""A server configuration profile export job"""
JOB_TYPE_LC_CONF = "LC configuration"
"""A lifecycle controller attribute configuration job"""
FC_CONF = "FCConfiguration"
"""A Fibre Channel configuration job"""
JOB_TYPE_LC_EXPORT = "LC export"
"""A lifecycle controller export job"""
FACTORY_CONF_EXPORT = "FactoryConfigurationExport"
"""A factory configuration export job"""
JOB_TYPE_LC_LOG_EXPORT = "LC log export"
"""A lifecycle controller log export job"""
FIRMWARE_ROLLBACK = "FirmwareRollback"
"""A firmware rollback job"""
JOB_TYPE_LICENSE_EXPORT = "License export"
"""A license export job"""
FIRMWARE_UPDATE = "FirmwareUpdate"
"""A firmware update job"""
JOB_TYPE_LICENSE_IMPORT = "License import"
"""A license import job"""
HW_INVENTORY_EXPORT = "HardwareInventoryExport"
"""A hardware inventory export job"""
JOB_TYPE_MSG_REG_EXPORT = "Message registry export"
"""Export message registry report job"""
IMPORT_CONF = "ImportConfiguration"
"""A server configuration profile import job"""
JOB_TYPE_NIC_CONF = "NIC configuration"
"""A NIC configuration job"""
INBAND_BIOS_CONF = "InbandBIOSConfiguration"
"""An inband BIOS configuration job"""
JOB_TYPE_OS_DEPLOY = "OS deploy"
"""Operating System deploy job"""
LC_CONF = "LCConfig"
"""A lifecycle controller attribute configuration job"""
JOB_TYPE_RAID_CONF = "RAID configuration"
"""A RAID configuration job"""
LC_EXPORT = "LCExport"
"""A lifecycle controller export job"""
JOB_TYPE_RT_NO_REBOOT_CONF = "Real-time no reboot configuration"
"""A real time configuration job without reboot"""
LC_LOG_EXPORT = "LCLogExport"
"""A lifecycle controller log export job"""
JOB_TYPE_REBOOT_FORCE = "Reboot force"
"""A reboot job with forced shutdown"""
LICENSE_EXPORT = "LicenseExport"
"""A license export job"""
JOB_TYPE_REBOOT_NO_FORCE = "Reboot no force"
"""A graceful reboot job without forced shutdown"""
LICENSE_IMPORT = "LicenseImport"
"""A license import job"""
JOB_TYPE_REBOOT_POWER_CYCLE = "Reboot power cycle"
"""A power cycle job"""
MSG_REG_EXPORT = "MessageRegistryExport"
"""Export message registry report job"""
JOB_TYPE_REMOTE_DIAG = "Remote diagnostics"
"""A remote diagnostics job"""
NIC_CONF = "NICConfiguration"
"""A NIC configuration job"""
JOB_TYPE_REPO_UPDATE = "Repository update"
"""An update job from a repository"""
OS_DEPLOY = "OSDeploy"
"""Operating System deploy job"""
JOB_TYPE_SA_COL_EXP_HEALTH_DATA = "SA collect and export health data"
"""Support Assist collect and export health data job"""
RAID_CONF = "RAIDConfiguration"
"""A RAID configuration job"""
JOB_TYPE_SA_COL_HEALTH_DATA = "SA collect health data"
"""Support Assist collect health data job"""
RT_NO_REBOOT_CONF = "RealTimeNoRebootConfiguration"
"""A real time configuration job without reboot"""
JOB_TYPE_SA_EXP_HEALTH_DATA = "SA export health data"
"""Support Assist export health data job"""
REBOOT_FORCE = "RebootForce"
"""A reboot job with forced shutdown"""
JOB_TYPE_SA_ISM = "SA expose iSM"
"""Support Assist expose iDRAC Service Module installer package to host job"""
REBOOT_NO_FORCE = "RebootNoForce"
"""A graceful reboot job without forced shutdown"""
JOB_TYPE_SA_REG = "SA registration"
"""Support Assist register iDRAC to Dell backend server job"""
REBOOT_POWER_CYCLE = "RebootPowerCycle"
"""A power cycle job"""
JOB_TYPE_SEKM_REKEY = "SEKM rekey"
"""A Secure Enterprise Key Manager rekey job"""
REMOTE_DIAG = "RemoteDiagnostics"
"""A remote diagnostics job"""
JOB_TYPE_SEKM_STATUS_SET = "SEKM status set"
"""A Secure Enterprise Key Manager status set job"""
REPO_UPDATE = "RepositoryUpdate"
"""An update job from a repository"""
JOB_TYPE_SHUTDOWN = "Shutdown"
"""A shutdown job"""
SA_COL_EXP_HEALTH_DATA = "SACollectExportHealthData"
"""Support Assist collect and export health data job"""
JOB_TYPE_SYS_ERASE = "System erase"
"""A selective system erase job"""
SA_COL_HEALTH_DATA = "SACollectHealthData"
"""Support Assist collect health data job"""
JOB_TYPE_SYS_INFO_CONF = "System info configuration"
"""A system info configuration job"""
SA_EXP_HEALTH_DATA = "SAExportHealthData"
"""Support Assist export health data job"""
JOB_TYPE_THERMAL_HIST_EXP = "Thermal history export"
"""A thermal history export job"""
SA_ISM = "SAExposeISM"
"""Support Assist expose ISM installer package to host job"""
JOB_TYPE_UNKNOWN = "Unknown"
"""An unknown job"""
SA_REG = "SARegistration"
"""Support Assist register iDRAC to Dell backend server job"""
JOB_TYPE_IDRAC_CONF = "iDRAC configuration"
"""An iDRAC configuration job"""
SEKM_REKEY = "SEKMRekey"
"""A Secure Enterprise Key Manager rekey job"""
SEKM_STATUS_SET = "SEKMStatusSet"
"""A Secure Enterprise Key Manager status set job"""
SHUTDOWN = "Shutdown"
"""A shutdown job"""
SYS_ERASE = "SystemErase"
"""A selective system erase job"""
SYS_INFO_CONF = "SystemInfoConfiguration"
"""A system info configuration job"""
THERMAL_HIST_EXP = "ThermalHistoryExport"
"""A thermal history export job"""
UNKNOWN = "Unknown"
"""An unknown job"""
IDRAC_CONF = "iDRACConfiguration"
"""An iDRAC configuration job"""
# Backward compatibility
JOB_TYPE_BIOS_CONF = JobType.BIOS_CONF
JOB_TYPE_EXPORT_CONF = JobType.EXPORT_CONF
JOB_TYPE_FC_CONF = JobType.FC_CONF
JOB_TYPE_FACTORY_CONF_EXPORT = JobType.FACTORY_CONF_EXPORT
JOB_TYPE_FIRMWARE_ROLLBACK = JobType.FIRMWARE_ROLLBACK
JOB_TYPE_FIRMWARE_UPDATE = JobType.FIRMWARE_UPDATE
JOB_TYPE_HW_INVENTORY_EXPORT = JobType.HW_INVENTORY_EXPORT
JOB_TYPE_IMPORT_CONF = JobType.IMPORT_CONF
JOB_TYPE_INBAND_BIOS_CONF = JobType.INBAND_BIOS_CONF
JOB_TYPE_LC_CONF = JobType.LC_CONF
JOB_TYPE_LC_EXPORT = JobType.LC_EXPORT
JOB_TYPE_LC_LOG_EXPORT = JobType.LC_LOG_EXPORT
JOB_TYPE_LICENSE_EXPORT = JobType.LICENSE_EXPORT
JOB_TYPE_LICENSE_IMPORT = JobType.LICENSE_IMPORT
JOB_TYPE_MSG_REG_EXPORT = JobType.MSG_REG_EXPORT
JOB_TYPE_NIC_CONF = JobType.NIC_CONF
JOB_TYPE_OS_DEPLOY = JobType.OS_DEPLOY
JOB_TYPE_RAID_CONF = JobType.RAID_CONF
JOB_TYPE_RT_NO_REBOOT_CONF = JobType.RT_NO_REBOOT_CONF
JOB_TYPE_REBOOT_FORCE = JobType.REBOOT_FORCE
JOB_TYPE_REBOOT_NO_FORCE = JobType.REBOOT_NO_FORCE
JOB_TYPE_REBOOT_POWER_CYCLE = JobType.REBOOT_POWER_CYCLE
JOB_TYPE_REMOTE_DIAG = JobType.REMOTE_DIAG
JOB_TYPE_REPO_UPDATE = JobType.REPO_UPDATE
JOB_TYPE_SA_COL_EXP_HEALTH_DATA = JobType.SA_COL_EXP_HEALTH_DATA
JOB_TYPE_SA_COL_HEALTH_DATA = JobType.SA_COL_HEALTH_DATA
JOB_TYPE_SA_EXP_HEALTH_DATA = JobType.SA_EXP_HEALTH_DATA
JOB_TYPE_SA_ISM = JobType.SA_ISM
JOB_TYPE_SA_REG = JobType.SA_REG
JOB_TYPE_SEKM_REKEY = JobType.SEKM_REKEY
JOB_TYPE_SEKM_STATUS_SET = JobType.SEKM_STATUS_SET
JOB_TYPE_SHUTDOWN = JobType.SHUTDOWN
JOB_TYPE_SYS_ERASE = JobType.SYS_ERASE
JOB_TYPE_SYS_INFO_CONF = JobType.SYS_INFO_CONF
JOB_TYPE_THERMAL_HIST_EXP = JobType.THERMAL_HIST_EXP
JOB_TYPE_UNKNOWN = JobType.UNKNOWN
JOB_TYPE_IDRAC_CONF = JobType.IDRAC_CONF

View File

@ -1,81 +0,0 @@
# Copyright (c) 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 import utils
from sushy_oem_idrac.resources.taskservice import constants as ts_cons
JOB_STATE_VALUE_MAP = {
"New": ts_cons.JOB_STATE_NEW,
"Scheduled": ts_cons.JOB_STATE_SCHEDULED,
"Running": ts_cons.JOB_STATE_RUNNING,
"Completed": ts_cons.JOB_STATE_COMPLETED,
"Downloading": ts_cons.JOB_STATE_DOWNLOADING,
"Downloaded": ts_cons.JOB_STATE_DOWNLOADED,
"Scheduling": ts_cons.JOB_STATE_SCHEDULING,
"ReadyForExecution": ts_cons.JOB_STATE_READY_EXECUTION,
"Waiting": ts_cons.JOB_STATE_WAITING,
"Paused": ts_cons.JOB_STATE_PAUSED,
"Failed": ts_cons.JOB_STATE_FAILED,
"CompletedWithErrors": ts_cons.JOB_STATE_COMPLETED_ERRORS,
"RebootPending": ts_cons.JOB_STATE_REBOOT_PENDING,
"RebootFailed": ts_cons.JOB_STATE_REBOOT_FAILED,
"RebootCompleted": ts_cons.JOB_STATE_REBOOT_COMPLETED,
"PendingActivation": ts_cons.JOB_STATE_PENDING_ACTIVATION,
"Unknown": ts_cons.JOB_STATE_UNKNOWN
}
JOB_STATE_VALUE_MAP_REV = utils.revert_dictionary(JOB_STATE_VALUE_MAP)
JOB_TYPE_VALUE_MAP = {
"FirmwareUpdate": ts_cons.JOB_TYPE_FIRMWARE_UPDATE,
"FirmwareRollback": ts_cons.JOB_TYPE_FIRMWARE_ROLLBACK,
"RepositoryUpdate": ts_cons.JOB_TYPE_REPO_UPDATE,
"RebootPowerCycle": ts_cons.JOB_TYPE_REBOOT_POWER_CYCLE,
"RebootForce": ts_cons.JOB_TYPE_REBOOT_FORCE,
"RebootNoForce": ts_cons.JOB_TYPE_REBOOT_NO_FORCE,
"Shutdown": ts_cons.JOB_TYPE_SHUTDOWN,
"RAIDConfiguration": ts_cons.JOB_TYPE_RAID_CONF,
"BIOSConfiguration": ts_cons.JOB_TYPE_BIOS_CONF,
"NICConfiguration": ts_cons.JOB_TYPE_NIC_CONF,
"FCConfiguration": ts_cons.JOB_TYPE_FC_CONF,
"iDRACConfiguration": ts_cons.JOB_TYPE_IDRAC_CONF,
"SystemInfoConfiguration": ts_cons.JOB_TYPE_SYS_INFO_CONF,
"InbandBIOSConfiguration": ts_cons.JOB_TYPE_INBAND_BIOS_CONF,
"ExportConfiguration": ts_cons.JOB_TYPE_EXPORT_CONF,
"ImportConfiguration": ts_cons.JOB_TYPE_IMPORT_CONF,
"RemoteDiagnostics": ts_cons.JOB_TYPE_REMOTE_DIAG,
"RealTimeNoRebootConfiguration": ts_cons.JOB_TYPE_RT_NO_REBOOT_CONF,
"LCLogExport": ts_cons.JOB_TYPE_LC_LOG_EXPORT,
"HardwareInventoryExport": ts_cons.JOB_TYPE_HW_INVENTORY_EXPORT,
"FactoryConfigurationExport": ts_cons.JOB_TYPE_FACTORY_CONF_EXPORT,
"LicenseImport": ts_cons.JOB_TYPE_LICENSE_IMPORT,
"LicenseExport": ts_cons.JOB_TYPE_LICENSE_EXPORT,
"ThermalHistoryExport": ts_cons.JOB_TYPE_THERMAL_HIST_EXP,
"LCConfig": ts_cons.JOB_TYPE_LC_CONF,
"LCExport": ts_cons.JOB_TYPE_LC_EXPORT,
"SACollectHealthData": ts_cons.JOB_TYPE_SA_COL_HEALTH_DATA,
"SAExportHealthData": ts_cons.JOB_TYPE_SA_EXP_HEALTH_DATA,
"SACollectExportHealthData": ts_cons.JOB_TYPE_SA_COL_EXP_HEALTH_DATA,
"SAExposeISM": ts_cons.JOB_TYPE_SA_ISM,
"SARegistration": ts_cons.JOB_TYPE_SA_REG,
"SystemErase": ts_cons.JOB_TYPE_SYS_ERASE,
"MessageRegistryExport": ts_cons.JOB_TYPE_MSG_REG_EXPORT,
"OSDeploy": ts_cons.JOB_TYPE_OS_DEPLOY,
"SEKMRekey": ts_cons.JOB_TYPE_SEKM_REKEY,
"SEKMStatusSet": ts_cons.JOB_TYPE_SEKM_STATUS_SET,
"Unknown": ts_cons.JOB_TYPE_UNKNOWN
}
JOB_TYPE_VALUE_MAP_REV = utils.revert_dictionary(JOB_TYPE_VALUE_MAP)

View File

@ -17,7 +17,7 @@ import logging
from sushy.resources import base
from sushy.resources.oem import base as oem_base
from sushy_oem_idrac.resources.taskservice import mappings as ts_maps
from sushy_oem_idrac.resources.taskservice import constants as ts_cons
LOG = logging.getLogger(__name__)
@ -42,10 +42,10 @@ class DellTaskExtension(oem_base.OEMResourceBase):
applicable.
"""
job_state = base.MappedField('JobState', ts_maps.JOB_STATE_VALUE_MAP)
job_state = base.MappedField('JobState', ts_cons.JobState)
"""Job state"""
job_type = base.MappedField('JobType', ts_maps.JOB_TYPE_VALUE_MAP)
job_type = base.MappedField('JobType', ts_cons.JobType)
"""Job type"""
message = base.Field('Message')

View File

@ -47,8 +47,8 @@ class DelliDRACCardServiceTestCase(BaseTestCase):
data={'Force': 'Graceful'})
def test_get_allowed_reset_idrac_values(self):
expected_values = {mgr_cons.RESET_IDRAC_GRACEFUL_RESTART,
mgr_cons.RESET_IDRAC_FORCE_RESTART}
expected_values = {mgr_cons.ResetType.GRACEFUL,
mgr_cons.ResetType.FORCE}
allowed_values = \
self.idrac_card_service.get_allowed_reset_idrac_values()
self.assertEqual(expected_values, allowed_values)
@ -58,8 +58,8 @@ class DelliDRACCardServiceTestCase(BaseTestCase):
base_property = '#DelliDRACCardService.iDRACReset'
remove_property = 'Force@Redfish.AllowableValues'
idrac_service_json['Actions'][base_property].pop(remove_property)
expected_values = {mgr_cons.RESET_IDRAC_GRACEFUL_RESTART,
mgr_cons.RESET_IDRAC_FORCE_RESTART}
expected_values = {mgr_cons.ResetType.GRACEFUL,
mgr_cons.ResetType.FORCE}
allowed_values = \
self.idrac_card_service.get_allowed_reset_idrac_values()
self.assertEqual(expected_values, allowed_values)

View File

@ -97,11 +97,11 @@ class ManagerTestCase(BaseTestCase):
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
def test_get_allowed_export_target_values(self):
oem = self.manager.get_oem_extension('Dell')
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}
expected_values = {mgr_cons.ExportTarget.IDRAC,
mgr_cons.ExportTarget.RAID,
mgr_cons.ExportTarget.ALL,
mgr_cons.ExportTarget.BIOS,
mgr_cons.ExportTarget.NIC}
allowed_values = oem.get_allowed_export_target_values()
self.assertEqual(expected_values, allowed_values)
@ -114,11 +114,11 @@ class ManagerTestCase(BaseTestCase):
'Target@Redfish.AllowableValues')
oem.refresh()
oem = self.manager.get_oem_extension('Dell')
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}
expected_values = {mgr_cons.ExportTarget.IDRAC,
mgr_cons.ExportTarget.RAID,
mgr_cons.ExportTarget.ALL,
mgr_cons.ExportTarget.BIOS,
mgr_cons.ExportTarget.NIC}
allowed_values = oem.get_allowed_export_target_values()
self.assertEqual(expected_values, allowed_values)
@ -135,7 +135,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_TARGET_ALL)
target=mgr_cons.ExportTarget.ALL)
self.conn.post.assert_called_once_with(
'/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager'
@ -148,10 +148,10 @@ class ManagerTestCase(BaseTestCase):
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
def test__export_system_configuration_nondefault(self):
oem = self.manager.get_oem_extension('Dell')
include_in_export = mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
include_in_export = mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES
oem._export_system_configuration(
target=mgr_cons.EXPORT_TARGET_RAID,
export_use=mgr_cons.EXPORT_USE_CLONE,
target=mgr_cons.ExportTarget.RAID,
export_use=mgr_cons.ExportUse.CLONE,
include_in_export=include_in_export)
self.conn.post.assert_called_once_with(
@ -174,13 +174,15 @@ class ManagerTestCase(BaseTestCase):
def test__export_system_configuration_invalid_export_use(self):
oem = self.manager.get_oem_extension('Dell')
self.assertRaises(sushy.exceptions.InvalidParameterValueError,
oem._export_system_configuration, "RAID",
oem._export_system_configuration,
mgr_cons.ExportTarget.RAID,
export_use="ABC")
def test__export_system_configuration_invalid_include_in_export(self):
oem = self.manager.get_oem_extension('Dell')
self.assertRaises(sushy.exceptions.InvalidParameterValueError,
oem._export_system_configuration, "RAID",
oem._export_system_configuration,
mgr_cons.ExportTarget.RAID,
include_in_export="ABC")
def test__export_system_configuration_invalid_include_in_export_part(self):
@ -193,9 +195,10 @@ class ManagerTestCase(BaseTestCase):
['Default', 'IncludeReadOnly']
oem.refresh()
oem = self.manager.get_oem_extension('Dell')
include_in_export = mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
include_in_export = mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES
self.assertRaises(sushy.exceptions.InvalidParameterValueError,
oem._export_system_configuration, "RAID",
oem._export_system_configuration,
mgr_cons.ExportTarget.RAID,
include_in_export=include_in_export)
def test__export_system_configuration_include_in_export_legacy(
@ -210,10 +213,10 @@ class ManagerTestCase(BaseTestCase):
'IncludeReadOnly,IncludePasswordHashValues']
oem.refresh()
include_in_export = mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
include_in_export = mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES
oem._export_system_configuration(
target=mgr_cons.EXPORT_TARGET_RAID,
export_use=mgr_cons.EXPORT_USE_CLONE,
target=mgr_cons.ExportTarget.RAID,
export_use=mgr_cons.ExportUse.CLONE,
include_in_export=include_in_export)
self.conn.post.assert_called_once_with(
@ -229,9 +232,9 @@ class ManagerTestCase(BaseTestCase):
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
def test_get_allowed_export_use_values(self):
oem = self.manager.get_oem_extension('Dell')
expected_values = {mgr_cons.EXPORT_USE_DEFAULT,
mgr_cons.EXPORT_USE_CLONE,
mgr_cons.EXPORT_USE_REPLACE}
expected_values = {mgr_cons.ExportUse.DEFAULT,
mgr_cons.ExportUse.CLONE,
mgr_cons.ExportUse.REPLACE}
allowed_values = oem.get_allowed_export_use_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)
@ -244,9 +247,9 @@ class ManagerTestCase(BaseTestCase):
oem.json['Actions']['Oem'][export_action].pop(
'ExportUse@Redfish.AllowableValues')
oem.refresh()
expected_values = {mgr_cons.EXPORT_USE_DEFAULT,
mgr_cons.EXPORT_USE_CLONE,
mgr_cons.EXPORT_USE_REPLACE}
expected_values = {mgr_cons.ExportUse.DEFAULT,
mgr_cons.ExportUse.CLONE,
mgr_cons.ExportUse.REPLACE}
allowed_values = oem.get_allowed_export_use_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)
@ -255,9 +258,9 @@ class ManagerTestCase(BaseTestCase):
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
def test_get_allowed_include_in_export_values(self):
oem = self.manager.get_oem_extension('Dell')
expected_values = {mgr_cons.INCLUDE_EXPORT_DEFAULT,
mgr_cons.INCLUDE_EXPORT_READ_ONLY,
mgr_cons.INCLUDE_EXPORT_PASSWORD_HASHES}
expected_values = {mgr_cons.IncludeInExport.DEFAULT,
mgr_cons.IncludeInExport.READ_ONLY,
mgr_cons.IncludeInExport.PASSWORD_HASHES}
allowed_values = oem.get_allowed_include_in_export_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)
@ -270,10 +273,10 @@ class ManagerTestCase(BaseTestCase):
oem.json['Actions']['Oem'][export_action].pop(
'IncludeInExport@Redfish.AllowableValues')
oem.refresh()
expected_values = {mgr_cons.INCLUDE_EXPORT_DEFAULT,
mgr_cons.INCLUDE_EXPORT_READ_ONLY,
mgr_cons.INCLUDE_EXPORT_PASSWORD_HASHES,
mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES}
expected_values = {mgr_cons.IncludeInExport.DEFAULT,
mgr_cons.IncludeInExport.READ_ONLY,
mgr_cons.IncludeInExport.PASSWORD_HASHES,
mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES}
allowed_values = oem.get_allowed_include_in_export_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)
@ -289,10 +292,10 @@ class ManagerTestCase(BaseTestCase):
response = oem.export_system_configuration()
self.assertEqual(mock_response, response)
include_in_export = mgr_cons.INCLUDE_EXPORT_READ_ONLY_PASSWORD_HASHES
include_in_export = mgr_cons.IncludeInExport.READ_ONLY_PASSWORD_HASHES
oem._export_system_configuration.assert_called_once_with(
mgr_cons.EXPORT_TARGET_ALL,
export_use=mgr_cons.EXPORT_USE_CLONE,
mgr_cons.ExportTarget.ALL,
export_use=mgr_cons.ExportUse.CLONE,
include_in_export=include_in_export)
@mock.patch('sushy.resources.oem.common._global_extn_mgrs_by_resource', {})
@ -431,9 +434,9 @@ class ManagerTestCase(BaseTestCase):
def test_get_allowed_import_shutdown_type_values(self):
oem = self.manager.get_oem_extension('Dell')
expected_values = {mgr_cons.IMPORT_SHUTDOWN_GRACEFUL,
mgr_cons.IMPORT_SHUTDOWN_FORCED,
mgr_cons.IMPORT_SHUTDOWN_NO_REBOOT}
expected_values = {mgr_cons.ShutdownType.GRACEFUL,
mgr_cons.ShutdownType.FORCED,
mgr_cons.ShutdownType.NO_REBOOT}
allowed_values = oem.get_allowed_import_shutdown_type_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)
@ -446,9 +449,9 @@ class ManagerTestCase(BaseTestCase):
oem.json['Actions']['Oem'][import_action].pop(
'ShutdownType@Redfish.AllowableValues')
oem.refresh()
expected_values = {mgr_cons.IMPORT_SHUTDOWN_GRACEFUL,
mgr_cons.IMPORT_SHUTDOWN_FORCED,
mgr_cons.IMPORT_SHUTDOWN_NO_REBOOT}
expected_values = {mgr_cons.ShutdownType.GRACEFUL,
mgr_cons.ShutdownType.FORCED,
mgr_cons.ShutdownType.NO_REBOOT}
allowed_values = oem.get_allowed_import_shutdown_type_values()
self.assertIsInstance(allowed_values, set)
self.assertEqual(expected_values, allowed_values)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Dell Inc. or its subsidiaries.
# Copyright (c) 2021-2022 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
@ -88,7 +88,7 @@ class SystemTestCase(BaseTestCase):
self.oem_system.raid_service.convert_to_nonraid = mock_nonraid
task_mons = self.oem_system.change_physical_disk_state(
sys_cons.PHYSICAL_DISK_STATE_MODE_RAID)
sys_cons.PhysicalDiskStateMode.RAID)
self.assertEqual([mock_taskmon], task_mons)
mock_raid.assert_called_once_with(
@ -104,7 +104,7 @@ class SystemTestCase(BaseTestCase):
self.oem_system.raid_service.convert_to_nonraid = mock_nonraid
task_mons = self.oem_system.change_physical_disk_state(
sys_cons.PHYSICAL_DISK_STATE_MODE_NONRAID)
sys_cons.PhysicalDiskStateMode.NONRAID)
self.assertEqual([mock_taskmon], task_mons)
mock_raid.assert_not_called()

View File

@ -49,6 +49,11 @@ class TaskTestCase(BaseTestCase):
self.assertEqual('Job Instance', self.oem_task.description)
self.assertIsNone(self.oem_task.completion_time)
self.assertEqual('TIME_NA', self.oem_task.end_time)
self.assertEqual(ts_cons.JobState.SCHEDULED,
self.oem_task.job_state)
self.assertEqual(ts_cons.JobType.RAID_CONF,
self.oem_task.job_type)
# For backward compability
self.assertEqual(ts_cons.JOB_STATE_SCHEDULED,
self.oem_task.job_state)
self.assertEqual(ts_cons.JOB_TYPE_RAID_CONF,