Migrate common constants to enums
The new enums are generated by a new script that reads the DMTF definitions and produced Python code in stdout. Missing items and docstrings are added because of that. The change migrates everything from sushy.resources.constants except for ProtocolType, which has to be untangled from other protocol-related enums. This change also misses a release note. The intention is to create one final release note before the next release. Change-Id: I863fad54a9703c88aa92993ad0d48d18c50e492a
This commit is contained in:
parent
4b99f93a11
commit
559e3ed4c4
|
@ -105,7 +105,7 @@ Creating and using a sushy system object
|
|||
|
||||
|
||||
# Power the system ON
|
||||
sys_inst.reset_system(sushy.RESET_ON)
|
||||
sys_inst.reset_system(sushy.ResetType.ON)
|
||||
|
||||
# Get a list of allowed reset values
|
||||
print(sys_inst.get_allowed_reset_system_values())
|
||||
|
|
|
@ -22,6 +22,7 @@ from sushy.resources.constants import * # noqa
|
|||
from sushy.resources.eventservice.constants import * # noqa
|
||||
from sushy.resources.fabric.constants import * # noqa
|
||||
from sushy.resources.manager.constants import * # noqa
|
||||
from sushy.resources.registry.constants import * # noqa
|
||||
from sushy.resources.system.constants import * # noqa
|
||||
from sushy.resources.system.storage.constants import * # noqa
|
||||
from sushy.resources.updateservice.constants import * # noqa
|
||||
|
|
|
@ -26,7 +26,7 @@ import zipfile
|
|||
import pkg_resources
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants
|
||||
from sushy.resources import oem
|
||||
from sushy import utils
|
||||
|
||||
|
@ -360,8 +360,7 @@ class MessageListField(ListField):
|
|||
message = Field('Message')
|
||||
"""Human readable message, if provided"""
|
||||
|
||||
severity = MappedField('Severity',
|
||||
res_maps.SEVERITY_VALUE_MAP)
|
||||
severity = MappedField('Severity', constants.Severity)
|
||||
"""Severity of the error"""
|
||||
|
||||
resolution = Field('Resolution')
|
||||
|
|
|
@ -21,8 +21,8 @@ from sushy.resources.chassis import mappings as cha_maps
|
|||
from sushy.resources.chassis.power import power
|
||||
from sushy.resources.chassis.thermal import thermal
|
||||
from sushy.resources import common
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.manager import manager
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy import utils
|
||||
|
||||
|
||||
|
@ -89,8 +89,7 @@ class Chassis(base.ResourceBase):
|
|||
manufacturer.
|
||||
"""
|
||||
|
||||
indicator_led = base.MappedField('IndicatorLED',
|
||||
res_maps.INDICATOR_LED_VALUE_MAP)
|
||||
indicator_led = base.MappedField('IndicatorLED', res_cons.IndicatorLED)
|
||||
"""The state of the indicator LED, used to identify the chassis"""
|
||||
|
||||
manufacturer = base.Field('Manufacturer')
|
||||
|
@ -108,8 +107,7 @@ class Chassis(base.ResourceBase):
|
|||
security.
|
||||
"""
|
||||
|
||||
power_state = base.MappedField('PowerState',
|
||||
res_maps.POWER_STATE_VALUE_MAP)
|
||||
power_state = base.MappedField('PowerState', res_cons.PowerState)
|
||||
"""The current power state of the chassis"""
|
||||
|
||||
serial_number = base.Field('SerialNumber')
|
||||
|
@ -180,11 +178,10 @@ class Chassis(base.ResourceBase):
|
|||
if not reset_action.allowed_values:
|
||||
LOG.warning('Could not figure out the allowed values for the '
|
||||
'reset chassis action for Chassis %s', self.identity)
|
||||
return set(res_maps.RESET_TYPE_VALUE_MAP_REV)
|
||||
return set(res_cons.ResetType)
|
||||
|
||||
return set([res_maps.RESET_TYPE_VALUE_MAP[v] for v in
|
||||
set(res_maps.RESET_TYPE_VALUE_MAP).
|
||||
intersection(reset_action.allowed_values)])
|
||||
return {v for v in res_cons.ResetType
|
||||
if v.value in reset_action.allowed_values}
|
||||
|
||||
def reset_chassis(self, value):
|
||||
"""Reset the chassis.
|
||||
|
@ -198,7 +195,7 @@ class Chassis(base.ResourceBase):
|
|||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='value', value=value, valid_values=valid_resets)
|
||||
|
||||
value = res_maps.RESET_TYPE_VALUE_MAP_REV[value]
|
||||
value = res_cons.ResetType(value).value
|
||||
target_uri = self._get_reset_action_element().target_uri
|
||||
|
||||
LOG.debug('Resetting the Chassis %s ...', self.identity)
|
||||
|
@ -208,19 +205,18 @@ class Chassis(base.ResourceBase):
|
|||
def set_indicator_led(self, state):
|
||||
"""Set IndicatorLED to the given state.
|
||||
|
||||
:param state: Desired LED state, lit (INDICATOR_LED_LIT), blinking
|
||||
(INDICATOR_LED_BLINKING), off (INDICATOR_LED_OFF)
|
||||
:param state: Desired LED state, an IndicatorLED value.
|
||||
:raises: InvalidParameterValueError, if any information passed is
|
||||
invalid.
|
||||
"""
|
||||
if state not in res_maps.INDICATOR_LED_VALUE_MAP_REV:
|
||||
try:
|
||||
state = res_cons.IndicatorLED(state).value
|
||||
except ValueError:
|
||||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='state', value=state,
|
||||
valid_values=list(res_maps.INDICATOR_LED_VALUE_MAP_REV))
|
||||
valid_values=' ,'.join(i.value for i in res_cons.IndicatorLED))
|
||||
|
||||
data = {
|
||||
'IndicatorLED': res_maps.INDICATOR_LED_VALUE_MAP_REV[state]
|
||||
}
|
||||
data = {'IndicatorLED': state}
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
self.invalidate()
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
from sushy.resources import base
|
||||
from sushy.resources.chassis.power import mappings as pow_maps
|
||||
from sushy.resources import common
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
|
@ -59,8 +59,7 @@ class PowerSupplyListField(base.ListField):
|
|||
identity = base.Field('MemberId')
|
||||
"""Identifier of the Power Supply"""
|
||||
|
||||
indicator_led = base.MappedField('IndicatorLed',
|
||||
res_maps.INDICATOR_LED_VALUE_MAP)
|
||||
indicator_led = base.MappedField('IndicatorLed', res_cons.IndicatorLED)
|
||||
"""The state of the indicator LED, used to identify the power supply"""
|
||||
|
||||
input_ranges = InputRangeListField('InputRanges', default=[])
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
from sushy.resources import base
|
||||
from sushy.resources.chassis.thermal import mappings as the_maps
|
||||
from sushy.resources import common
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
|
@ -63,8 +63,7 @@ class Sensor(base.ListField):
|
|||
class FansListField(Sensor):
|
||||
"""The Fan device/s associated with Thermal."""
|
||||
|
||||
indicator_led = base.MappedField('IndicatorLED',
|
||||
res_maps.INDICATOR_LED_VALUE_MAP)
|
||||
indicator_led = base.MappedField('IndicatorLED', res_cons.IndicatorLED)
|
||||
"""The state of the indicator LED, used to identify the fan"""
|
||||
|
||||
manufacturer = base.Field('Manufacturer')
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
from dateutil import parser
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants
|
||||
|
||||
|
||||
class IdRefField(base.CompositeField):
|
||||
|
@ -50,7 +50,7 @@ class OperationApplyTimeSupportField(base.CompositeField):
|
|||
"""
|
||||
|
||||
mapped_supported_values = base.MappedListField(
|
||||
'SupportedValues', res_maps.APPLY_TIME_VALUE_MAP, required=True)
|
||||
'SupportedValues', constants.ApplyTime, required=True)
|
||||
"""The types of apply times that the client is allowed request when
|
||||
performing a create, delete, or action operation returned as a mapped
|
||||
list"""
|
||||
|
@ -76,13 +76,13 @@ class StatusField(base.CompositeField):
|
|||
|
||||
This field shall contain any state or health properties of a resource.
|
||||
"""
|
||||
health = base.MappedField('Health', res_maps.HEALTH_VALUE_MAP)
|
||||
health = base.MappedField('Health', constants.Health)
|
||||
"""Represents health of resource w/o considering its dependent resources"""
|
||||
|
||||
health_rollup = base.MappedField('HealthRollup', res_maps.HEALTH_VALUE_MAP)
|
||||
health_rollup = base.MappedField('HealthRollup', constants.Health)
|
||||
"""Represents health state of resource and its dependent resources"""
|
||||
|
||||
state = base.MappedField('State', res_maps.STATE_VALUE_MAP)
|
||||
state = base.MappedField('State', constants.State)
|
||||
"""Indicates the known state of the resource, such as if it is enabled."""
|
||||
|
||||
|
||||
|
@ -93,5 +93,5 @@ class IdentifiersListField(base.ListField):
|
|||
"""This indicates the world wide, persistent name of the resource."""
|
||||
|
||||
durable_name_format = base.MappedField('DurableNameFormat',
|
||||
res_maps.DUR_NAME_FORMAT_VALUE_MAP)
|
||||
constants.DurableNameFormat)
|
||||
"""This represents the format of the DurableName property."""
|
||||
|
|
|
@ -10,112 +10,226 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Values comes from the Redfish System json-schema 1.0.0:
|
||||
# http://redfish.dmtf.org/schemas/v1/Resource.json or
|
||||
# https://redfish.dmtf.org/schemas/v1/MessageRegistry.v1_1_1.json
|
||||
# Values comes from the Redfish System json-schema:
|
||||
# http://redfish.dmtf.org/schemas/v1/Resource.json and
|
||||
# https://redfish.dmtf.org/schemas/v1/Settings.v1_3_3.json
|
||||
|
||||
# Health related constants.
|
||||
HEALTH_OK = 'ok'
|
||||
HEALTH_WARNING = 'warning'
|
||||
HEALTH_CRITICAL = 'critical'
|
||||
import enum
|
||||
|
||||
# State related constants.
|
||||
STATE_ENABLED = 'enabled'
|
||||
STATE_DISABLED = 'disabled'
|
||||
STATE_STANDBYOFFLINE = 'standby offline'
|
||||
STATE_STANDBYSPARE = 'standby spare'
|
||||
STATE_INTEST = 'in test'
|
||||
STATE_STARTING = 'starting'
|
||||
STATE_ABSENT = 'absent'
|
||||
STATE_UNAVAILABLEOFFLINE = 'unavailable offline'
|
||||
STATE_DEFERRING = 'deferring'
|
||||
STATE_QUIESCED = 'quiesced'
|
||||
STATE_UPDATING = 'updating'
|
||||
from sushy.resources.registry import constants as reg_cons
|
||||
from sushy.resources.taskservice import constants as ts_cons
|
||||
|
||||
# Task state related constants
|
||||
TASK_STATE_NEW = 'new'
|
||||
TASK_STATE_STARTING = 'starting'
|
||||
TASK_STATE_RUNNING = 'running'
|
||||
TASK_STATE_SUSPENDED = 'suspended'
|
||||
TASK_STATE_INTERRUPTED = 'interrupted'
|
||||
TASK_STATE_PENDING = 'pending'
|
||||
TASK_STATE_STOPPING = 'stopping'
|
||||
TASK_STATE_COMPLETED = 'completed'
|
||||
TASK_STATE_KILLED = 'killed'
|
||||
TASK_STATE_EXCEPTION = 'exception'
|
||||
TASK_STATE_SERVICE = 'service'
|
||||
TASK_STATE_CANCELLING = 'cancelling'
|
||||
TASK_STATE_CANCELLED = 'cancelled'
|
||||
|
||||
# Message Registry message parameter type related constants.
|
||||
PARAMTYPE_STRING = 'string'
|
||||
PARAMTYPE_NUMBER = 'number'
|
||||
class Health(enum.Enum):
|
||||
"""Health related constants."""
|
||||
OK = 'OK'
|
||||
"""Normal."""
|
||||
|
||||
# Severity related constants
|
||||
SEVERITY_OK = 'ok'
|
||||
SEVERITY_WARNING = 'warning'
|
||||
SEVERITY_CRITICAL = 'critical'
|
||||
WARNING = 'Warning'
|
||||
"""A condition requires attention."""
|
||||
|
||||
# Indicator LED Constants
|
||||
CRITICAL = 'Critical'
|
||||
"""A critical condition requires immediate attention."""
|
||||
|
||||
INDICATOR_LED_LIT = 'indicator led lit'
|
||||
"""The Indicator LED is lit"""
|
||||
|
||||
INDICATOR_LED_BLINKING = 'indicator led blinking'
|
||||
"""The Indicator LED is blinking"""
|
||||
# Backward compatibility
|
||||
HEALTH_OK = Health.OK
|
||||
HEALTH_WARNING = Health.WARNING
|
||||
HEALTH_CRITICAL = Health.CRITICAL
|
||||
|
||||
INDICATOR_LED_OFF = 'indicator led off'
|
||||
"""The Indicator LED is off"""
|
||||
|
||||
INDICATOR_LED_UNKNOWN = 'indicator led unknown'
|
||||
"""The state of the Indicator LED cannot be determine"""
|
||||
class State(enum.Enum):
|
||||
"""State related constants."""
|
||||
ENABLED = 'Enabled'
|
||||
"""This function or resource is enabled."""
|
||||
|
||||
# System' PowerState constants
|
||||
DISABLED = 'Disabled'
|
||||
"""This function or resource is disabled."""
|
||||
|
||||
POWER_STATE_ON = 'on'
|
||||
"""The resource is powered on"""
|
||||
STANDBY_OFFLINE = 'StandbyOffline'
|
||||
"""This function or resource is enabled but awaits an external action to
|
||||
activate it."""
|
||||
|
||||
POWER_STATE_OFF = 'off'
|
||||
"""The resource is powered off, although some components may continue to
|
||||
have AUX power such as management controller"""
|
||||
STANDBY_SPARE = 'StandbySpare'
|
||||
"""This function or resource is part of a redundancy set and awaits a
|
||||
failover or other external action to activate it."""
|
||||
|
||||
POWER_STATE_POWERING_ON = 'powering on'
|
||||
"""A temporary state between Off and On. This temporary state can
|
||||
be very short"""
|
||||
IN_TEST = 'InTest'
|
||||
"""This function or resource is undergoing testing, or is in the process
|
||||
of capturing information for debugging."""
|
||||
|
||||
POWER_STATE_POWERING_OFF = 'powering off'
|
||||
"""A temporary state between On and Off. The power off action can take
|
||||
time while the OS is in the shutdown process"""
|
||||
STARTING = 'Starting'
|
||||
"""This function or resource is starting."""
|
||||
|
||||
# Reset action constants
|
||||
ABSENT = 'Absent'
|
||||
"""This function or resource is either not present or detected."""
|
||||
|
||||
RESET_TYPE_ON = 'on'
|
||||
"""Turn the unit on"""
|
||||
UNAVAILABLE_OFFLINE = 'UnavailableOffline'
|
||||
"""This function or resource is present but cannot be used."""
|
||||
|
||||
RESET_TYPE_FORCE_ON = 'force on'
|
||||
"""Turn the unit on immediately"""
|
||||
DEFERRING = 'Deferring'
|
||||
"""The element does not process any commands but queues new requests."""
|
||||
|
||||
RESET_TYPE_FORCE_OFF = 'force off'
|
||||
"""Turn the unit off immediately (non-graceful shutdown)"""
|
||||
QUIESCED = 'Quiesced'
|
||||
"""The element is enabled but only processes a restricted set of
|
||||
commands."""
|
||||
|
||||
RESET_TYPE_GRACEFUL_SHUTDOWN = 'graceful shutdown'
|
||||
"""Perform a graceful shutdown and power off"""
|
||||
UPDATING = 'Updating'
|
||||
"""The element is updating and might be unavailable or degraded."""
|
||||
|
||||
RESET_TYPE_GRACEFUL_RESTART = 'graceful restart'
|
||||
"""Perform a graceful shutdown followed by a restart of the system"""
|
||||
QUALIFIED = 'Qualified'
|
||||
"""The element quality is within the acceptable range of operation."""
|
||||
|
||||
RESET_TYPE_FORCE_RESTART = 'force restart'
|
||||
"""Perform an immediate (non-graceful) shutdown, followed by a restart"""
|
||||
|
||||
RESET_TYPE_NMI = 'nmi'
|
||||
"""Generate a Diagnostic Interrupt (usually an NMI on x86 systems) to cease
|
||||
normal operations, perform diagnostic actions and typically halt the system"""
|
||||
# Backward compatibility
|
||||
STATE_ENABLED = State.ENABLED
|
||||
STATE_DISABLED = State.DISABLED
|
||||
STATE_ABSENT = State.ABSENT
|
||||
STATE_STANDBYOFFLINE = State.STANDBY_OFFLINE
|
||||
STATE_STANDBYSPARE = State.STANDBY_SPARE
|
||||
STATE_INTEST = State.IN_TEST
|
||||
STATE_STARTING = State.STARTING
|
||||
STATE_UNAVAILABLEOFFLINE = State.UNAVAILABLE_OFFLINE
|
||||
STATE_DEFERRING = State.DEFERRING
|
||||
STATE_QUIESCED = State.QUIESCED
|
||||
STATE_UPDATING = State.UPDATING
|
||||
|
||||
RESET_TYPE_PUSH_POWER_BUTTON = 'push power button'
|
||||
"""Simulate the pressing of the physical power button on this unit"""
|
||||
|
||||
RESET_TYPE_POWER_CYCLE = 'power cycle'
|
||||
"""Perform a power cycle of the unit"""
|
||||
# Backward compatibility, the type moved to taskservice.constants
|
||||
TASK_STATE_NEW = ts_cons.TaskState.NEW
|
||||
TASK_STATE_STARTING = ts_cons.TaskState.STARTING
|
||||
TASK_STATE_RUNNING = ts_cons.TaskState.RUNNING
|
||||
TASK_STATE_SUSPENDED = ts_cons.TaskState.SUSPENDED
|
||||
TASK_STATE_INTERRUPTED = ts_cons.TaskState.INTERRUPTED
|
||||
TASK_STATE_PENDING = ts_cons.TaskState.PENDING
|
||||
TASK_STATE_STOPPING = ts_cons.TaskState.STOPPING
|
||||
TASK_STATE_COMPLETED = ts_cons.TaskState.COMPLETED
|
||||
TASK_STATE_KILLED = ts_cons.TaskState.KILLED
|
||||
TASK_STATE_EXCEPTION = ts_cons.TaskState.EXCEPTION
|
||||
TASK_STATE_SERVICE = ts_cons.TaskState.SERVICE
|
||||
TASK_STATE_CANCELLING = ts_cons.TaskState.CANCELLING
|
||||
TASK_STATE_CANCELLED = ts_cons.TaskState.CANCELLED
|
||||
|
||||
|
||||
# Backward compatibility, the type moved to registry.constants
|
||||
PARAMTYPE_STRING = reg_cons.MessageParamType.STRING
|
||||
PARAMTYPE_NUMBER = reg_cons.MessageParamType.NUMBER
|
||||
|
||||
|
||||
# Backward compatibility (Severity is an alias of Health after 1.1.0)
|
||||
Severity = Health
|
||||
SEVERITY_OK = Severity.OK
|
||||
SEVERITY_WARNING = Severity.WARNING
|
||||
SEVERITY_CRITICAL = Severity.CRITICAL
|
||||
|
||||
|
||||
class IndicatorLED(enum.Enum):
|
||||
"""Indicator LED Constants"""
|
||||
|
||||
LIT = 'Lit'
|
||||
"""The Indicator LED is lit"""
|
||||
|
||||
BLINKING = 'Blinking'
|
||||
"""The Indicator LED is blinking"""
|
||||
|
||||
OFF = 'Off'
|
||||
"""The Indicator LED is off"""
|
||||
|
||||
UNKNOWN = 'Unknown'
|
||||
"""The state of the Indicator LED cannot be determine"""
|
||||
|
||||
|
||||
# Backward compatibility
|
||||
INDICATOR_LED_LIT = IndicatorLED.LIT
|
||||
INDICATOR_LED_BLINKING = IndicatorLED.BLINKING
|
||||
INDICATOR_LED_OFF = IndicatorLED.OFF
|
||||
INDICATOR_LED_UNKNOWN = IndicatorLED.UNKNOWN
|
||||
|
||||
|
||||
class PowerState(enum.Enum):
|
||||
"""System PowerState constants"""
|
||||
|
||||
ON = 'On'
|
||||
"""The resource is powered on"""
|
||||
|
||||
OFF = 'Off'
|
||||
"""The resource is powered off, although some components may continue to
|
||||
have AUX power such as management controller"""
|
||||
|
||||
POWERING_ON = 'PoweringOn'
|
||||
"""A temporary state between Off and On. This temporary state can
|
||||
be very short"""
|
||||
|
||||
POWERING_OFF = 'PoweringOff'
|
||||
"""A temporary state between On and Off. The power off action can take
|
||||
time while the OS is in the shutdown process"""
|
||||
|
||||
PAUSED = 'Paused'
|
||||
"""The resource is paused."""
|
||||
|
||||
|
||||
# Backward compatibility
|
||||
POWER_STATE_ON = PowerState.ON
|
||||
POWER_STATE_OFF = PowerState.OFF
|
||||
POWER_STATE_POWERING_ON = PowerState.POWERING_ON
|
||||
POWER_STATE_POWERING_OFF = PowerState.POWERING_OFF
|
||||
|
||||
|
||||
class ResetType(enum.Enum):
|
||||
"""Reset action constants"""
|
||||
ON = 'On'
|
||||
"""Turn on the unit."""
|
||||
|
||||
FORCE_OFF = 'ForceOff'
|
||||
"""Turn off the unit immediately (non-graceful shutdown)."""
|
||||
|
||||
GRACEFUL_SHUTDOWN = 'GracefulShutdown'
|
||||
"""Shut down gracefully and power off."""
|
||||
|
||||
GRACEFUL_RESTART = 'GracefulRestart'
|
||||
"""Shut down gracefully and restart the system."""
|
||||
|
||||
FORCE_RESTART = 'ForceRestart'
|
||||
"""Shut down immediately and non-gracefully and restart the system."""
|
||||
|
||||
NMI = 'Nmi'
|
||||
"""Generate a diagnostic interrupt, which is usually an NMI on x86
|
||||
systems, to stop normal operations, complete diagnostic actions, and,
|
||||
typically, halt the system."""
|
||||
|
||||
FORCE_ON = 'ForceOn'
|
||||
"""Turn on the unit immediately."""
|
||||
|
||||
PUSH_POWER_BUTTON = 'PushPowerButton'
|
||||
"""Simulate the pressing of the physical power button on this unit."""
|
||||
|
||||
POWER_CYCLE = 'PowerCycle'
|
||||
"""Power cycle the unit. Behaves like a full power removal, followed by
|
||||
a power restore to the resource."""
|
||||
|
||||
SUSPEND = 'Suspend'
|
||||
"""Write the state of the unit to disk before powering off. This allows
|
||||
for the state to be restored when powered back on."""
|
||||
|
||||
PAUSE = 'Pause'
|
||||
"""Pause execution on the unit but do not remove power. This is
|
||||
typically a feature of virtual machine hypervisors."""
|
||||
|
||||
RESUME = 'Resume'
|
||||
"""Resume execution on the paused unit. This is typically a feature of
|
||||
virtual machine hypervisors."""
|
||||
|
||||
|
||||
# Backward compatibility
|
||||
RESET_TYPE_ON = ResetType.ON
|
||||
RESET_TYPE_FORCE_OFF = ResetType.FORCE_OFF
|
||||
RESET_TYPE_GRACEFUL_SHUTDOWN = ResetType.GRACEFUL_SHUTDOWN
|
||||
RESET_TYPE_GRACEFUL_RESTART = ResetType.GRACEFUL_RESTART
|
||||
RESET_TYPE_FORCE_RESTART = ResetType.FORCE_RESTART
|
||||
RESET_TYPE_NMI = ResetType.NMI
|
||||
RESET_TYPE_FORCE_ON = ResetType.FORCE_ON
|
||||
RESET_TYPE_PUSH_POWER_BUTTON = ResetType.PUSH_POWER_BUTTON
|
||||
RESET_TYPE_POWER_CYCLE = ResetType.POWER_CYCLE
|
||||
|
||||
# Protocol type constants
|
||||
|
||||
|
@ -149,19 +263,63 @@ PROTOCOL_TYPE_USB = 'Universal Serial Bus'
|
|||
PROTOCOL_TYPE_iSCSI = 'Internet SCSI'
|
||||
PROTOCOL_TYPE_iWARP = 'Internet Wide Area Remote Direct Memory Access Protocol'
|
||||
|
||||
# Durable name format constants
|
||||
|
||||
DURABLE_NAME_FORMAT_EUI = 'IEEE-defined 64-bit Extended Unique Identifier'
|
||||
DURABLE_NAME_FORMAT_FC_WWN = 'Fibre Channel World Wide Name'
|
||||
DURABLE_NAME_FORMAT_NAA = 'Name Address Authority Format'
|
||||
DURABLE_NAME_FORMAT_NQN = 'NVMe Qualified Name'
|
||||
DURABLE_NAME_FORMAT_NSID = 'NVM Namespace Identifier'
|
||||
DURABLE_NAME_FORMAT_UUID = 'Universally Unique Identifier'
|
||||
DURABLE_NAME_FORMAT_iQN = 'iSCSI Qualified Name'
|
||||
class DurableNameFormat(enum.Enum):
|
||||
"""Durable name format constants"""
|
||||
NAA = 'NAA'
|
||||
"""The Name Address Authority (NAA) format."""
|
||||
|
||||
# Apply time constants
|
||||
iQN = 'iQN'
|
||||
"""The iSCSI Qualified Name (iQN)."""
|
||||
|
||||
APPLY_TIME_IMMEDIATE = 'immediate'
|
||||
APPLY_TIME_ON_RESET = 'on reset'
|
||||
APPLY_TIME_MAINT_START = 'at maintenance window start'
|
||||
APPLY_TIME_MAINT_RESET = 'in maintenance window on reset'
|
||||
FC_WWN = 'FC_WWN'
|
||||
"""The Fibre Channel (FC) World Wide Name (WWN)."""
|
||||
|
||||
UUID = 'UUID'
|
||||
"""The Universally Unique Identifier (UUID)."""
|
||||
|
||||
EUI = 'EUI'
|
||||
"""The IEEE-defined 64-bit Extended Unique Identifier (EUI)."""
|
||||
|
||||
NQN = 'NQN'
|
||||
"""The NVMe Qualified Name (NQN)."""
|
||||
|
||||
NSID = 'NSID'
|
||||
"""The NVM Namespace Identifier (NSID)."""
|
||||
|
||||
NGUID = 'NGUID'
|
||||
"""The Namespace Globally Unique Identifier (NGUID)."""
|
||||
|
||||
|
||||
# Backward compatibility
|
||||
DURABLE_NAME_FORMAT_NAA = DurableNameFormat.NAA
|
||||
DURABLE_NAME_FORMAT_iQN = DurableNameFormat.iQN
|
||||
DURABLE_NAME_FORMAT_FC_WWN = DurableNameFormat.FC_WWN
|
||||
DURABLE_NAME_FORMAT_UUID = DurableNameFormat.UUID
|
||||
DURABLE_NAME_FORMAT_EUI = DurableNameFormat.EUI
|
||||
DURABLE_NAME_FORMAT_NQN = DurableNameFormat.NQN
|
||||
DURABLE_NAME_FORMAT_NSID = DurableNameFormat.NSID
|
||||
|
||||
|
||||
class ApplyTime(enum.Enum):
|
||||
"""Apply time constants"""
|
||||
|
||||
IMMEDIATE = 'Immediate'
|
||||
"""Apply immediately."""
|
||||
|
||||
ON_RESET = 'OnReset'
|
||||
"""Apply on a reset."""
|
||||
|
||||
AT_MAINTENANCE_WINDOW_START = 'AtMaintenanceWindowStart'
|
||||
"""Apply during a maintenance window as specified by an administrator."""
|
||||
|
||||
IN_MAINTENANCE_WINDOW_ON_RESET = 'InMaintenanceWindowOnReset'
|
||||
"""Apply after a reset but within maintenance window as specified by an
|
||||
administrator."""
|
||||
|
||||
|
||||
# Backward compatibility
|
||||
APPLY_TIME_IMMEDIATE = ApplyTime.IMMEDIATE
|
||||
APPLY_TIME_ON_RESET = ApplyTime.ON_RESET
|
||||
APPLY_TIME_MAINT_START = ApplyTime.AT_MAINTENANCE_WINDOW_START
|
||||
APPLY_TIME_MAINT_RESET = ApplyTime.IN_MAINTENANCE_WINDOW_ON_RESET
|
||||
|
|
|
@ -17,10 +17,10 @@ from sushy.resources import constants as res_cons
|
|||
|
||||
# Manager Reset action constants
|
||||
|
||||
RESET_MANAGER_GRACEFUL_RESTART = res_cons.RESET_TYPE_GRACEFUL_RESTART
|
||||
RESET_MANAGER_GRACEFUL_RESTART = res_cons.ResetType.GRACEFUL_RESTART
|
||||
"""Perform a graceful shutdown followed by a restart of the system"""
|
||||
|
||||
RESET_MANAGER_FORCE_RESTART = res_cons.RESET_TYPE_FORCE_RESTART
|
||||
RESET_MANAGER_FORCE_RESTART = res_cons.ResetType.FORCE_RESTART
|
||||
"""Perform an immediate (non-graceful) shutdown, followed by a restart"""
|
||||
|
||||
# Manager Type constants
|
||||
|
|
|
@ -14,69 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
STATE_VALUE_MAP = {
|
||||
'Enabled': res_cons.STATE_ENABLED,
|
||||
'Disabled': res_cons.STATE_DISABLED,
|
||||
'Absent': res_cons.STATE_ABSENT,
|
||||
}
|
||||
|
||||
STATE_VALUE_MAP_REV = (
|
||||
utils.revert_dictionary(STATE_VALUE_MAP))
|
||||
|
||||
HEALTH_VALUE_MAP = {
|
||||
'OK': res_cons.HEALTH_OK,
|
||||
'Warning': res_cons.HEALTH_WARNING,
|
||||
'Critical': res_cons.HEALTH_CRITICAL
|
||||
}
|
||||
|
||||
HEALTH_VALUE_MAP_REV = (
|
||||
utils.revert_dictionary(HEALTH_VALUE_MAP))
|
||||
|
||||
PARAMTYPE_VALUE_MAP = {
|
||||
'string': res_cons.PARAMTYPE_STRING,
|
||||
'number': res_cons.PARAMTYPE_NUMBER
|
||||
}
|
||||
|
||||
SEVERITY_VALUE_MAP = {
|
||||
'OK': res_cons.SEVERITY_OK,
|
||||
'Warning': res_cons.SEVERITY_WARNING,
|
||||
'Critical': res_cons.SEVERITY_CRITICAL
|
||||
}
|
||||
|
||||
INDICATOR_LED_VALUE_MAP = {
|
||||
'Lit': res_cons.INDICATOR_LED_LIT,
|
||||
'Blinking': res_cons.INDICATOR_LED_BLINKING,
|
||||
'Off': res_cons.INDICATOR_LED_OFF,
|
||||
'Unknown': res_cons.INDICATOR_LED_UNKNOWN,
|
||||
}
|
||||
|
||||
INDICATOR_LED_VALUE_MAP_REV = utils.revert_dictionary(INDICATOR_LED_VALUE_MAP)
|
||||
|
||||
POWER_STATE_VALUE_MAP = {
|
||||
'On': res_cons.POWER_STATE_ON,
|
||||
'Off': res_cons.POWER_STATE_OFF,
|
||||
'PoweringOn': res_cons.POWER_STATE_POWERING_ON,
|
||||
'PoweringOff': res_cons.POWER_STATE_POWERING_OFF,
|
||||
}
|
||||
|
||||
POWER_STATE_MAP_REV = utils.revert_dictionary(POWER_STATE_VALUE_MAP)
|
||||
|
||||
RESET_TYPE_VALUE_MAP = {
|
||||
'On': res_cons.RESET_TYPE_ON,
|
||||
'ForceOff': res_cons.RESET_TYPE_FORCE_OFF,
|
||||
'GracefulShutdown': res_cons.RESET_TYPE_GRACEFUL_SHUTDOWN,
|
||||
'GracefulRestart': res_cons.RESET_TYPE_GRACEFUL_RESTART,
|
||||
'ForceRestart': res_cons.RESET_TYPE_FORCE_RESTART,
|
||||
'Nmi': res_cons.RESET_TYPE_NMI,
|
||||
'ForceOn': res_cons.RESET_TYPE_FORCE_ON,
|
||||
'PushPowerButton': res_cons.RESET_TYPE_PUSH_POWER_BUTTON,
|
||||
'PowerCycle': res_cons.RESET_TYPE_POWER_CYCLE,
|
||||
}
|
||||
|
||||
RESET_TYPE_VALUE_MAP_REV = utils.revert_dictionary(RESET_TYPE_VALUE_MAP)
|
||||
|
||||
PROTOCOL_TYPE_VALUE_MAP = {
|
||||
'AHCI': res_cons.PROTOCOL_TYPE_AHCI,
|
||||
|
@ -105,24 +42,3 @@ PROTOCOL_TYPE_VALUE_MAP = {
|
|||
'iSCSI': res_cons.PROTOCOL_TYPE_iSCSI,
|
||||
'iWARP': res_cons.PROTOCOL_TYPE_iWARP,
|
||||
}
|
||||
|
||||
DUR_NAME_FORMAT_VALUE_MAP = {
|
||||
'EUI': res_cons.DURABLE_NAME_FORMAT_EUI,
|
||||
'FC_WWN': res_cons.DURABLE_NAME_FORMAT_FC_WWN,
|
||||
'NAA': res_cons.DURABLE_NAME_FORMAT_NAA,
|
||||
'NQN': res_cons.DURABLE_NAME_FORMAT_NQN,
|
||||
'NSID': res_cons.DURABLE_NAME_FORMAT_NSID,
|
||||
'UUID': res_cons.DURABLE_NAME_FORMAT_UUID,
|
||||
'iQN': res_cons.DURABLE_NAME_FORMAT_iQN,
|
||||
}
|
||||
|
||||
APPLY_TIME_VALUE_MAP = {
|
||||
'Immediate': res_cons.APPLY_TIME_IMMEDIATE,
|
||||
'OnReset': res_cons.APPLY_TIME_ON_RESET,
|
||||
'AtMaintenanceWindowStart':
|
||||
res_cons.APPLY_TIME_MAINT_START,
|
||||
'InMaintenanceWindowOnReset':
|
||||
res_cons.APPLY_TIME_MAINT_RESET,
|
||||
}
|
||||
|
||||
APPLY_TIME_VALUE_MAP_REV = utils.revert_dictionary(APPLY_TIME_VALUE_MAP)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# 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.
|
||||
|
||||
# Values come from the Redfish schema:
|
||||
# https://redfish.dmtf.org/schemas/v1/MessageRegistry.v1_4_2.json
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
class MessageParamType(enum.Enum):
|
||||
"""Message Registry message parameter type related constants."""
|
||||
STRING = "string"
|
||||
NUMBER = "number"
|
|
@ -17,7 +17,7 @@ import logging
|
|||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources.registry import constants as reg_cons
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -41,7 +41,7 @@ class MessageDictionaryField(base.DictionaryField):
|
|||
|
||||
param_types = base.Field('ParamTypes',
|
||||
adapter=lambda x:
|
||||
[res_maps.PARAMTYPE_VALUE_MAP[v.lower()]
|
||||
[reg_cons.MessageParamType(v.lower())
|
||||
for v in x])
|
||||
"""Mapped MessageArg types, in order, for the message"""
|
||||
|
||||
|
@ -49,9 +49,9 @@ class MessageDictionaryField(base.DictionaryField):
|
|||
"""Suggestions on how to resolve the situation that caused the error"""
|
||||
|
||||
severity = base.MappedField('Severity',
|
||||
res_maps.SEVERITY_VALUE_MAP,
|
||||
res_cons.Severity,
|
||||
required=True,
|
||||
default=res_cons.SEVERITY_WARNING)
|
||||
default=res_cons.Severity.WARNING)
|
||||
"""Mapped severity of the message"""
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ from dateutil import parser
|
|||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources.registry import message_registry
|
||||
|
||||
# Settings update statuses
|
||||
|
@ -127,7 +126,7 @@ class SettingsField(base.CompositeField):
|
|||
|
||||
_supported_apply_times = base.MappedListField(
|
||||
'SupportedApplyTimes',
|
||||
res_maps.APPLY_TIME_VALUE_MAP)
|
||||
res_cons.ApplyTime)
|
||||
"""List of supported apply times"""
|
||||
|
||||
@property
|
||||
|
@ -194,7 +193,7 @@ class SettingsField(base.CompositeField):
|
|||
parsed_msgs.append(
|
||||
message_registry.parse_message(registries, m))
|
||||
any_errors = any(m for m in parsed_msgs
|
||||
if not m.severity == res_cons.SEVERITY_OK)
|
||||
if m.severity != res_cons.Severity.OK)
|
||||
|
||||
if any_errors:
|
||||
status = UPDATE_FAILURE
|
||||
|
|
|
@ -19,7 +19,7 @@ import logging
|
|||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources import settings
|
||||
from sushy import utils
|
||||
|
||||
|
@ -114,10 +114,7 @@ class Bios(base.ResourceBase):
|
|||
:param key: Attribute name
|
||||
:param value: Attribute value
|
||||
:param apply_time: When to update the attribute. Optional.
|
||||
APPLY_TIME_IMMEDIATE - Immediate,
|
||||
APPLY_TIME_ON_RESET - On reset,
|
||||
APPLY_TIME_MAINT_START - During specified maintenance time
|
||||
APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
|
||||
An :py:class:`sushy.ApplyTime` value.
|
||||
:param maint_window_start_time: The start time of a maintenance window,
|
||||
datetime. Required when updating during maintenance window and
|
||||
default maintenance window not set by the system.
|
||||
|
@ -140,10 +137,7 @@ class Bios(base.ResourceBase):
|
|||
|
||||
:param value: Key-value pairs for attribute name and value
|
||||
:param apply_time: When to update the attributes. Optional.
|
||||
APPLY_TIME_IMMEDIATE - Immediate,
|
||||
APPLY_TIME_ON_RESET - On reset,
|
||||
APPLY_TIME_MAINT_START - During specified maintenance time
|
||||
APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
|
||||
An :py:class:`sushy.ApplyTime` value.
|
||||
:param maint_window_start_time: The start time of a maintenance window,
|
||||
datetime. Required when updating during maintenance window and
|
||||
default maintenance window not set by the system.
|
||||
|
@ -161,7 +155,7 @@ class Bios(base.ResourceBase):
|
|||
prop = '@Redfish.SettingsApplyTime'
|
||||
payload[prop] = {
|
||||
'@odata.type': '#Settings.v1_0_0.PreferredApplyTime',
|
||||
'ApplyTime': res_maps.APPLY_TIME_VALUE_MAP_REV[apply_time]
|
||||
'ApplyTime': res_cons.ApplyTime(apply_time).value,
|
||||
}
|
||||
if maint_window_start_time and not maint_window_duration:
|
||||
raise ValueError('"maint_window_duration" missing')
|
||||
|
|
|
@ -20,14 +20,14 @@ from sushy.resources import constants as res_cons
|
|||
|
||||
# Reset action constants
|
||||
|
||||
RESET_ON = res_cons.RESET_TYPE_ON
|
||||
RESET_FORCE_OFF = res_cons.RESET_TYPE_FORCE_OFF
|
||||
RESET_GRACEFUL_SHUTDOWN = res_cons.RESET_TYPE_GRACEFUL_SHUTDOWN
|
||||
RESET_GRACEFUL_RESTART = res_cons.RESET_TYPE_GRACEFUL_RESTART
|
||||
RESET_FORCE_RESTART = res_cons.RESET_TYPE_FORCE_RESTART
|
||||
RESET_NMI = res_cons.RESET_TYPE_NMI
|
||||
RESET_FORCE_ON = res_cons.RESET_TYPE_FORCE_ON
|
||||
RESET_PUSH_POWER_BUTTON = res_cons.RESET_TYPE_PUSH_POWER_BUTTON
|
||||
RESET_ON = res_cons.ResetType.ON
|
||||
RESET_FORCE_OFF = res_cons.ResetType.FORCE_OFF
|
||||
RESET_GRACEFUL_SHUTDOWN = res_cons.ResetType.GRACEFUL_SHUTDOWN
|
||||
RESET_GRACEFUL_RESTART = res_cons.ResetType.GRACEFUL_RESTART
|
||||
RESET_FORCE_RESTART = res_cons.ResetType.FORCE_RESTART
|
||||
RESET_NMI = res_cons.ResetType.NMI
|
||||
RESET_FORCE_ON = res_cons.ResetType.FORCE_ON
|
||||
RESET_PUSH_POWER_BUTTON = res_cons.ResetType.PUSH_POWER_BUTTON
|
||||
|
||||
# System' PowerState constants
|
||||
|
||||
|
@ -46,32 +46,6 @@ SYSTEM_POWER_STATE_POWERING_OFF = res_cons.POWER_STATE_POWERING_OFF
|
|||
"""A temporary state between On and Off. The power off action can take
|
||||
time while the OS is in the shutdown process"""
|
||||
|
||||
# Indicator LED Constants
|
||||
|
||||
SYSTEM_INDICATOR_LED_LIT = res_cons.INDICATOR_LED_LIT
|
||||
"""The Indicator LED is lit
|
||||
|
||||
Deprecated: Use `sushy.resources.constants.INDICATOR_LED_LIT`.
|
||||
"""
|
||||
|
||||
SYSTEM_INDICATOR_LED_BLINKING = res_cons.INDICATOR_LED_BLINKING
|
||||
"""The Indicator LED is blinking
|
||||
|
||||
Deprecated: Use `sushy.resources.constants.INDICATOR_LED_BLINKING`.
|
||||
"""
|
||||
|
||||
SYSTEM_INDICATOR_LED_OFF = res_cons.INDICATOR_LED_OFF
|
||||
"""The Indicator LED is off
|
||||
|
||||
Deprecated: Use `sushy.resources.constants.INDICATOR_LED_OFF`.
|
||||
"""
|
||||
|
||||
SYSTEM_INDICATOR_LED_UNKNOWN = res_cons.INDICATOR_LED_UNKNOWN
|
||||
"""The state of the Indicator LED cannot be determine
|
||||
|
||||
Deprecated: Use `sushy.resources.constants.INDICATOR_LED_UNKNOWN`.
|
||||
"""
|
||||
|
||||
# Boot source target constants
|
||||
|
||||
BOOT_SOURCE_TARGET_NONE = 'none'
|
||||
|
|
|
@ -64,12 +64,12 @@ class EthernetInterfaceCollection(base.ResourceCollectionBase):
|
|||
are returned.
|
||||
|
||||
:returns: dictionary in the format
|
||||
{'aa:bb:cc:dd:ee:ff': sushy.STATE_ENABLED,
|
||||
'aa:bb:aa:aa:aa:aa': sushy.STATE_DISABLED}
|
||||
{'aa:bb:cc:dd:ee:ff': sushy.State.ENABLED,
|
||||
'aa:bb:aa:aa:aa:aa': sushy.State.DISABLED}
|
||||
"""
|
||||
mac_dict = {}
|
||||
for eth in self.get_members():
|
||||
if eth.mac_address is not None and eth.status is not None:
|
||||
if eth.status.health == res_cons.HEALTH_OK:
|
||||
if eth.status.health == res_cons.Health.OK:
|
||||
mac_dict[eth.mac_address] = eth.status.state
|
||||
return mac_dict
|
||||
|
|
|
@ -16,20 +16,6 @@
|
|||
from sushy.resources.system import constants as sys_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
RESET_SYSTEM_VALUE_MAP = {
|
||||
'On': sys_cons.RESET_ON,
|
||||
'ForceOff': sys_cons.RESET_FORCE_OFF,
|
||||
'GracefulShutdown': sys_cons.RESET_GRACEFUL_SHUTDOWN,
|
||||
'GracefulRestart': sys_cons.RESET_GRACEFUL_RESTART,
|
||||
'ForceRestart': sys_cons.RESET_FORCE_RESTART,
|
||||
'Nmi': sys_cons.RESET_NMI,
|
||||
'ForceOn': sys_cons.RESET_FORCE_ON,
|
||||
'PushPowerButton': sys_cons.RESET_PUSH_POWER_BUTTON,
|
||||
}
|
||||
|
||||
RESET_SYSTEM_VALUE_MAP_REV = utils.revert_dictionary(RESET_SYSTEM_VALUE_MAP)
|
||||
|
||||
BOOT_SOURCE_TARGET_MAP = {
|
||||
'None': sys_cons.BOOT_SOURCE_TARGET_NONE,
|
||||
'Pxe': sys_cons.BOOT_SOURCE_TARGET_PXE,
|
||||
|
|
|
@ -73,7 +73,7 @@ class SimpleStorageCollection(base.ResourceCollectionBase):
|
|||
return sorted(device.capacity_bytes
|
||||
for simpl_stor in self.get_members()
|
||||
for device in simpl_stor.devices
|
||||
if (device.status.state == res_cons.STATE_ENABLED
|
||||
if (device.status.state == res_cons.State.ENABLED
|
||||
and device.capacity_bytes is not None))
|
||||
|
||||
@property
|
||||
|
|
|
@ -18,6 +18,7 @@ import logging
|
|||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources.system.storage import volume
|
||||
from sushy import utils
|
||||
|
@ -40,8 +41,7 @@ class Drive(base.ResourceBase):
|
|||
identity = base.Field('Id', required=True)
|
||||
"""The Drive identity string"""
|
||||
|
||||
indicator_led = base.MappedField('IndicatorLED',
|
||||
res_maps.INDICATOR_LED_VALUE_MAP)
|
||||
indicator_led = base.MappedField('IndicatorLED', res_cons.IndicatorLED)
|
||||
"""Whether the indicator LED is lit or off"""
|
||||
|
||||
manufacturer = base.Field('Manufacturer')
|
||||
|
@ -92,19 +92,18 @@ class Drive(base.ResourceBase):
|
|||
def set_indicator_led(self, state):
|
||||
"""Set IndicatorLED to the given state.
|
||||
|
||||
:param state: Desired LED state, lit (INDICATOR_LED_LIT), blinking
|
||||
(INDICATOR_LED_BLINKING), off (INDICATOR_LED_OFF)
|
||||
:param state: Desired LED state, an IndicatorLED value.
|
||||
:raises: InvalidParameterValueError, if any information passed is
|
||||
invalid.
|
||||
"""
|
||||
if state not in res_maps.INDICATOR_LED_VALUE_MAP_REV:
|
||||
try:
|
||||
state = res_cons.IndicatorLED(state).value
|
||||
except ValueError:
|
||||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='state', value=state,
|
||||
valid_values=list(res_maps.INDICATOR_LED_VALUE_MAP_REV))
|
||||
valid_values=' ,'.join(i.value for i in res_cons.IndicatorLED))
|
||||
|
||||
data = {
|
||||
'IndicatorLED': res_maps.INDICATOR_LED_VALUE_MAP_REV[state]
|
||||
}
|
||||
data = {'IndicatorLED': state}
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
self.invalidate()
|
||||
|
|
|
@ -19,7 +19,6 @@ from sushy import exceptions
|
|||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources.system.storage import constants as store_cons
|
||||
from sushy.resources.system.storage import mappings as store_maps
|
||||
from sushy.taskmonitor import TaskMonitor
|
||||
|
@ -27,6 +26,8 @@ from sushy import utils
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_OAT_PROP = '@Redfish.OperationApplyTime'
|
||||
|
||||
|
||||
class ActionsField(base.CompositeField):
|
||||
initialize = common.InitializeActionField('#Volume.Initialize')
|
||||
|
@ -99,11 +100,10 @@ class Volume(base.ResourceBase):
|
|||
value = store_maps.VOLUME_INIT_TYPE_MAP_REV[value]
|
||||
payload = {'InitializeType': value}
|
||||
blocking = False
|
||||
oat_prop = '@Redfish.OperationApplyTime'
|
||||
if apply_time:
|
||||
payload[oat_prop] = res_maps.APPLY_TIME_VALUE_MAP_REV[apply_time]
|
||||
if (payload and payload.get(oat_prop) == res_maps.
|
||||
APPLY_TIME_VALUE_MAP_REV[res_cons.APPLY_TIME_IMMEDIATE]):
|
||||
payload[_OAT_PROP] = res_cons.ApplyTime(apply_time).value
|
||||
if (payload and payload.get(_OAT_PROP)
|
||||
== res_cons.ApplyTime.IMMEDIATE.value):
|
||||
blocking = True
|
||||
target_uri = self._get_initialize_action_element().target_uri
|
||||
r = self._conn.post(target_uri, data=payload, blocking=blocking,
|
||||
|
@ -116,10 +116,7 @@ class Volume(base.ResourceBase):
|
|||
|
||||
:param value: The InitializeType value.
|
||||
:param apply_time: When to update the attributes. Optional.
|
||||
APPLY_TIME_IMMEDIATE - Immediate,
|
||||
APPLY_TIME_ON_RESET - On reset,
|
||||
APPLY_TIME_MAINT_START - During specified maintenance time
|
||||
APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
|
||||
An :py:class:`sushy.ApplyTime` value.
|
||||
:param timeout: Max time in seconds to wait for blocking async call.
|
||||
:raises: InvalidParameterValueError, if the target value is not
|
||||
allowed.
|
||||
|
@ -135,13 +132,12 @@ class Volume(base.ResourceBase):
|
|||
|
||||
def _delete(self, payload=None, apply_time=None, timeout=500):
|
||||
blocking = False
|
||||
oat_prop = '@Redfish.OperationApplyTime'
|
||||
if apply_time:
|
||||
if payload is None:
|
||||
payload = {}
|
||||
payload[oat_prop] = res_maps.APPLY_TIME_VALUE_MAP_REV[apply_time]
|
||||
if (payload and payload.get(oat_prop) == res_maps.
|
||||
APPLY_TIME_VALUE_MAP_REV[res_cons.APPLY_TIME_IMMEDIATE]):
|
||||
payload[_OAT_PROP] = res_cons.ApplyTime(apply_time).value
|
||||
if (payload and payload.get(_OAT_PROP)
|
||||
== res_cons.ApplyTime.IMMEDIATE.value):
|
||||
blocking = True
|
||||
r = self._conn.delete(self._path, data=payload, blocking=blocking,
|
||||
timeout=timeout)
|
||||
|
@ -152,10 +148,7 @@ class Volume(base.ResourceBase):
|
|||
|
||||
:param payload: May contain @Redfish.OperationApplyTime property
|
||||
:param apply_time: When to update the attributes. Optional.
|
||||
APPLY_TIME_IMMEDIATE - Immediate,
|
||||
APPLY_TIME_ON_RESET - On reset,
|
||||
APPLY_TIME_MAINT_START - During specified maintenance time
|
||||
APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
|
||||
An :py:class:`sushy.ApplyTime` value.
|
||||
:param timeout: Max time in seconds to wait for blocking async call.
|
||||
:raises: ConnectionError
|
||||
:raises: HTTPError
|
||||
|
@ -203,13 +196,12 @@ class VolumeCollection(base.ResourceCollectionBase):
|
|||
|
||||
def _create(self, payload, apply_time=None, timeout=500):
|
||||
blocking = False
|
||||
oat_prop = '@Redfish.OperationApplyTime'
|
||||
if apply_time:
|
||||
if payload is None:
|
||||
payload = {}
|
||||
payload[oat_prop] = res_maps.APPLY_TIME_VALUE_MAP_REV[apply_time]
|
||||
if (payload and payload.get(oat_prop) == res_maps.
|
||||
APPLY_TIME_VALUE_MAP_REV[res_cons.APPLY_TIME_IMMEDIATE]):
|
||||
payload[_OAT_PROP] = res_cons.ApplyTime(apply_time).value
|
||||
if (payload and payload.get(_OAT_PROP)
|
||||
== res_cons.ApplyTime.IMMEDIATE.value):
|
||||
blocking = True
|
||||
r = self._conn.post(self._path, data=payload, blocking=blocking,
|
||||
timeout=timeout)
|
||||
|
@ -221,10 +213,7 @@ class VolumeCollection(base.ResourceCollectionBase):
|
|||
|
||||
:param payload: The payload representing the new volume to create.
|
||||
:param apply_time: When to update the attributes. Optional.
|
||||
APPLY_TIME_IMMEDIATE - Immediate,
|
||||
APPLY_TIME_ON_RESET - On reset,
|
||||
APPLY_TIME_MAINT_START - During specified maintenance time
|
||||
APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
|
||||
An :py:class:`sushy.ApplyTime` value.
|
||||
:param timeout: Max time in seconds to wait for blocking async call.
|
||||
:raises: ConnectionError
|
||||
:raises: HTTPError
|
||||
|
|
|
@ -23,8 +23,8 @@ from sushy import exceptions
|
|||
from sushy.resources import base
|
||||
from sushy.resources.chassis import chassis
|
||||
from sushy.resources import common
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.manager import manager
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import settings
|
||||
from sushy.resources.system import bios
|
||||
from sushy.resources.system import constants as sys_cons
|
||||
|
@ -94,8 +94,7 @@ class System(base.ResourceBase):
|
|||
identity = base.Field('Id', required=True)
|
||||
"""The system identity string"""
|
||||
|
||||
indicator_led = base.MappedField('IndicatorLED',
|
||||
res_maps.INDICATOR_LED_VALUE_MAP)
|
||||
indicator_led = base.MappedField('IndicatorLED', res_cons.IndicatorLED)
|
||||
"""Whether the indicator LED is lit or off"""
|
||||
|
||||
manufacturer = base.Field('Manufacturer')
|
||||
|
@ -107,8 +106,7 @@ class System(base.ResourceBase):
|
|||
part_number = base.Field('PartNumber')
|
||||
"""The system part number"""
|
||||
|
||||
power_state = base.MappedField('PowerState',
|
||||
res_maps.POWER_STATE_VALUE_MAP)
|
||||
power_state = base.MappedField('PowerState', res_cons.PowerState)
|
||||
"""The system power state"""
|
||||
|
||||
serial_number = base.Field('SerialNumber')
|
||||
|
@ -173,11 +171,10 @@ class System(base.ResourceBase):
|
|||
if not reset_action.allowed_values:
|
||||
LOG.warning('Could not figure out the allowed values for the '
|
||||
'reset system action for System %s', self.identity)
|
||||
return set(sys_maps.RESET_SYSTEM_VALUE_MAP_REV)
|
||||
return set(res_cons.ResetType)
|
||||
|
||||
return set([sys_maps.RESET_SYSTEM_VALUE_MAP[v] for v in
|
||||
set(sys_maps.RESET_SYSTEM_VALUE_MAP).
|
||||
intersection(reset_action.allowed_values)])
|
||||
return {v for v in res_cons.ResetType
|
||||
if v.value in reset_action.allowed_values}
|
||||
|
||||
def reset_system(self, value):
|
||||
"""Reset the system.
|
||||
|
@ -191,7 +188,7 @@ class System(base.ResourceBase):
|
|||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='value', value=value, valid_values=valid_resets)
|
||||
|
||||
value = sys_maps.RESET_SYSTEM_VALUE_MAP_REV[value]
|
||||
value = res_cons.ResetType(value).value
|
||||
target_uri = self._get_reset_action_element().target_uri
|
||||
|
||||
# TODO(lucasagomes): Check the return code and response body ?
|
||||
|
@ -293,19 +290,18 @@ class System(base.ResourceBase):
|
|||
def set_indicator_led(self, state):
|
||||
"""Set IndicatorLED to the given state.
|
||||
|
||||
:param state: Desired LED state, lit (INDICATOR_LED_LIT), blinking
|
||||
(INDICATOR_LED_BLINKING), off (INDICATOR_LED_OFF)
|
||||
:param state: Desired LED state, an IndicatorLED value.
|
||||
:raises: InvalidParameterValueError, if any information passed is
|
||||
invalid.
|
||||
"""
|
||||
if state not in res_maps.INDICATOR_LED_VALUE_MAP_REV:
|
||||
try:
|
||||
state = res_cons.IndicatorLED(state).value
|
||||
except ValueError:
|
||||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='state', value=state,
|
||||
valid_values=list(res_maps.INDICATOR_LED_VALUE_MAP_REV))
|
||||
valid_values=' ,'.join(i.value for i in res_cons.IndicatorLED))
|
||||
|
||||
data = {
|
||||
'IndicatorLED': res_maps.INDICATOR_LED_VALUE_MAP_REV[state]
|
||||
}
|
||||
data = {'IndicatorLED': state}
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
self.invalidate()
|
||||
|
|
|
@ -13,6 +13,28 @@
|
|||
# Values come from the Redfish UpdateService json-schema.
|
||||
# https://redfish.dmtf.org/schemas/v1/TaskService.v1_1_5.json#/definitions/OverWritePolicy
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
class TaskState(enum.Enum):
|
||||
"""Task state related constants."""
|
||||
CANCELLED = 'Cancelled'
|
||||
CANCELLING = 'Cancelling'
|
||||
COMPLETED = 'Completed'
|
||||
EXCEPTION = 'Exception'
|
||||
INTERRUPTED = 'Interrupted'
|
||||
NEW = 'New'
|
||||
PENDING = 'Pending'
|
||||
RUNNING = 'Running'
|
||||
SERVICE = 'Service'
|
||||
STARTING = 'Starting'
|
||||
STOPPING = 'Stopping'
|
||||
SUSPENDED = 'Suspended'
|
||||
|
||||
# Deprecated in 1.2.0
|
||||
KILLED = 'Killed'
|
||||
|
||||
|
||||
# Overwrite Policy constants
|
||||
|
||||
OVERWRITE_POLICY_OLDEST = 'oldest completed'
|
||||
|
|
|
@ -13,27 +13,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.taskservice import constants as ts_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
TASK_STATE_VALUE_MAP = {
|
||||
'New': res_cons.TASK_STATE_NEW,
|
||||
'Starting': res_cons.TASK_STATE_STARTING,
|
||||
'Running': res_cons.TASK_STATE_RUNNING,
|
||||
'Suspended': res_cons.TASK_STATE_SUSPENDED,
|
||||
'Interrupted': res_cons.TASK_STATE_INTERRUPTED,
|
||||
'Pending': res_cons.TASK_STATE_PENDING,
|
||||
'Stopping': res_cons.TASK_STATE_STOPPING,
|
||||
'Completed': res_cons.TASK_STATE_COMPLETED,
|
||||
'Killed': res_cons.TASK_STATE_KILLED,
|
||||
'Exception': res_cons.TASK_STATE_EXCEPTION,
|
||||
'Service': res_cons.TASK_STATE_SERVICE,
|
||||
'Cancelling': res_cons.TASK_STATE_CANCELLING,
|
||||
'Cancelled': res_cons.TASK_STATE_CANCELLED
|
||||
}
|
||||
|
||||
OVERWRITE_POLICY_VALUE_MAP = {
|
||||
'Oldest': ts_cons.OVERWRITE_POLICY_OLDEST,
|
||||
'Manual': ts_cons.OVERWRITE_POLICY_MANUAL,
|
||||
|
|
|
@ -20,9 +20,9 @@ from http import client as http_client
|
|||
import logging
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import mappings as res_maps
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.registry import message_registry
|
||||
from sushy.resources.taskservice import mappings as task_maps
|
||||
from sushy.resources.taskservice import constants as ts_cons
|
||||
from sushy import utils
|
||||
|
||||
|
||||
|
@ -53,10 +53,10 @@ class Task(base.ResourceBase):
|
|||
percent_complete = base.Field('PercentComplete', adapter=utils.int_or_none)
|
||||
"""Percentage complete of the Task"""
|
||||
|
||||
task_state = base.MappedField('TaskState', task_maps.TASK_STATE_VALUE_MAP)
|
||||
task_state = base.MappedField('TaskState', ts_cons.TaskState)
|
||||
"""The Task state"""
|
||||
|
||||
task_status = base.MappedField('TaskStatus', res_maps.HEALTH_VALUE_MAP)
|
||||
task_status = base.MappedField('TaskStatus', res_cons.Health)
|
||||
"""The Task status"""
|
||||
|
||||
messages = base.MessageListField("Messages")
|
||||
|
@ -102,8 +102,8 @@ class TaskCollection(base.ResourceCollectionBase):
|
|||
"""Summary of task ids and corresponding state
|
||||
|
||||
:returns: dictionary in the format
|
||||
{'jid_123456789': sushy.TASK_STATE_NEW,
|
||||
'jid_123454321': sushy.TASK_STATE_RUNNING}
|
||||
{'jid_123456789': sushy.TaskState.NEW,
|
||||
'jid_123454321': sushy.TaskState.RUNNING}
|
||||
"""
|
||||
task_dict = {}
|
||||
for task in self.get_members():
|
||||
|
|
|
@ -55,16 +55,16 @@ class ChassisTestCase(base.TestCase):
|
|||
self.assertEqual('166480-S23', self.chassis.part_number)
|
||||
self.assertEqual('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF',
|
||||
self.chassis.uuid)
|
||||
self.assertEqual(sushy.INDICATOR_LED_OFF,
|
||||
self.assertEqual(sushy.IndicatorLED.OFF,
|
||||
self.chassis.indicator_led)
|
||||
self.assertEqual(sushy.POWER_STATE_ON,
|
||||
self.chassis.power_state)
|
||||
self.assertEqual(sushy.STATE_ENABLED, self.chassis.status.state)
|
||||
self.assertEqual(sushy.State.ENABLED, self.chassis.status.state)
|
||||
self.assertEqual(44.45, self.chassis.height_mm)
|
||||
self.assertEqual(431.8, self.chassis.width_mm)
|
||||
self.assertEqual(711, self.chassis.depth_mm)
|
||||
self.assertEqual(15.31, self.chassis.weight_kg)
|
||||
self.assertEqual(sushy.HEALTH_OK, self.chassis.status.health)
|
||||
self.assertEqual(sushy.Health.OK, self.chassis.status.health)
|
||||
self.assertEqual(sushy.CHASSIS_INTRUSION_SENSOR_NORMAL,
|
||||
self.chassis.physical_security.intrusion_sensor)
|
||||
self.assertEqual(123,
|
||||
|
@ -79,7 +79,7 @@ class ChassisTestCase(base.TestCase):
|
|||
|
||||
# Test that various types are returned correctly
|
||||
self.assertEqual('Blade', attributes.get('name'))
|
||||
self.assertEqual(sushy.INDICATOR_LED_OFF,
|
||||
self.assertEqual(sushy.IndicatorLED.OFF,
|
||||
attributes.get('indicator_led'))
|
||||
self.assertEqual(sushy.POWER_STATE_ON, attributes.get('power_state'))
|
||||
self.assertEqual({'intrusion_sensor':
|
||||
|
@ -92,13 +92,13 @@ class ChassisTestCase(base.TestCase):
|
|||
|
||||
def test_get_allowed_reset_chasis_values(self):
|
||||
# | GIVEN |
|
||||
expected = {sushy.RESET_TYPE_POWER_CYCLE,
|
||||
sushy.RESET_TYPE_PUSH_POWER_BUTTON,
|
||||
sushy.RESET_TYPE_FORCE_ON, sushy.RESET_TYPE_NMI,
|
||||
sushy.RESET_TYPE_FORCE_RESTART,
|
||||
sushy.RESET_TYPE_GRACEFUL_RESTART, sushy.RESET_TYPE_ON,
|
||||
sushy.RESET_TYPE_FORCE_OFF,
|
||||
sushy.RESET_TYPE_GRACEFUL_SHUTDOWN}
|
||||
expected = {sushy.ResetType.POWER_CYCLE,
|
||||
sushy.ResetType.PUSH_POWER_BUTTON,
|
||||
sushy.ResetType.FORCE_ON, sushy.ResetType.NMI,
|
||||
sushy.ResetType.FORCE_RESTART,
|
||||
sushy.ResetType.GRACEFUL_RESTART, sushy.ResetType.ON,
|
||||
sushy.ResetType.FORCE_OFF,
|
||||
sushy.ResetType.GRACEFUL_SHUTDOWN}
|
||||
# | WHEN |
|
||||
values = self.chassis.get_allowed_reset_chassis_values()
|
||||
# | THEN |
|
||||
|
@ -108,13 +108,16 @@ class ChassisTestCase(base.TestCase):
|
|||
def test_get_allowed_reset_chassis_values_for_no_values_set(self):
|
||||
# | GIVEN |
|
||||
self.chassis._actions.reset.allowed_values = []
|
||||
expected = {sushy.RESET_TYPE_POWER_CYCLE,
|
||||
sushy.RESET_TYPE_PUSH_POWER_BUTTON,
|
||||
sushy.RESET_TYPE_FORCE_ON, sushy.RESET_TYPE_NMI,
|
||||
sushy.RESET_TYPE_FORCE_RESTART,
|
||||
sushy.RESET_TYPE_GRACEFUL_RESTART, sushy.RESET_TYPE_ON,
|
||||
sushy.RESET_TYPE_FORCE_OFF,
|
||||
sushy.RESET_TYPE_GRACEFUL_SHUTDOWN}
|
||||
expected = {sushy.ResetType.POWER_CYCLE,
|
||||
sushy.ResetType.PUSH_POWER_BUTTON,
|
||||
sushy.ResetType.FORCE_ON, sushy.ResetType.NMI,
|
||||
sushy.ResetType.FORCE_RESTART,
|
||||
sushy.ResetType.GRACEFUL_RESTART, sushy.ResetType.ON,
|
||||
sushy.ResetType.FORCE_OFF,
|
||||
sushy.ResetType.GRACEFUL_SHUTDOWN,
|
||||
sushy.ResetType.SUSPEND,
|
||||
sushy.ResetType.RESUME,
|
||||
sushy.ResetType.PAUSE}
|
||||
# | WHEN |
|
||||
values = self.chassis.get_allowed_reset_chassis_values()
|
||||
# | THEN |
|
||||
|
@ -129,7 +132,7 @@ class ChassisTestCase(base.TestCase):
|
|||
exceptions.MissingActionError, 'action #Chassis.Reset')
|
||||
|
||||
def test_reset_chassis(self):
|
||||
self.chassis.reset_chassis(sushy.RESET_TYPE_GRACEFUL_RESTART)
|
||||
self.chassis.reset_chassis(sushy.ResetType.GRACEFUL_RESTART)
|
||||
self.chassis._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Chassis/Blade1/Actions/Chassis.Reset',
|
||||
data={'ResetType': 'GracefulRestart'})
|
||||
|
@ -141,7 +144,7 @@ class ChassisTestCase(base.TestCase):
|
|||
def test_set_indicator_led(self):
|
||||
with mock.patch.object(
|
||||
self.chassis, 'invalidate', autospec=True) as invalidate_mock:
|
||||
self.chassis.set_indicator_led(sushy.INDICATOR_LED_BLINKING)
|
||||
self.chassis.set_indicator_led(sushy.IndicatorLED.BLINKING)
|
||||
self.chassis._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Chassis/Blade1',
|
||||
data={'IndicatorLED': 'Blinking'})
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
|
||||
from sushy.resources.chassis.power import power
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.tests.unit import base
|
||||
|
||||
|
||||
|
@ -42,8 +42,10 @@ class PowerTestCase(base.TestCase):
|
|||
|
||||
self.assertEqual('0', self.power.power_supplies[0].identity)
|
||||
self.assertEqual('Power Supply 0', self.power.power_supplies[0].name)
|
||||
self.assertEqual('enabled', self.power.power_supplies[0].status.state)
|
||||
self.assertEqual('ok', self.power.power_supplies[0].status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.power.power_supplies[0].status.state)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.power.power_supplies[0].status.health)
|
||||
self.assertEqual('ac', self.power.power_supplies[0].power_supply_type)
|
||||
self.assertEqual('ac240v',
|
||||
self.power.power_supplies[0].line_input_voltage_type)
|
||||
|
@ -90,8 +92,10 @@ class PowerTestCase(base.TestCase):
|
|||
|
||||
self.assertEqual('1', self.power.power_supplies[1].identity)
|
||||
self.assertEqual('Power Supply 1', self.power.power_supplies[1].name)
|
||||
self.assertEqual('enabled', self.power.power_supplies[1].status.state)
|
||||
self.assertEqual('ok', self.power.power_supplies[1].status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.power.power_supplies[1].status.state)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.power.power_supplies[1].status.health)
|
||||
self.assertEqual('ac', self.power.power_supplies[1].power_supply_type)
|
||||
self.assertEqual('ac240v',
|
||||
self.power.power_supplies[1].line_input_voltage_type)
|
||||
|
@ -162,8 +166,9 @@ class PowerTestCase(base.TestCase):
|
|||
'power_supply_type': 'ac',
|
||||
'serial_number': '1S0000523',
|
||||
'spare_part_number': '425-591-654',
|
||||
'status': {'health': 'ok', 'health_rollup': None,
|
||||
'state': 'enabled'}},
|
||||
'status': {'health': res_cons.Health.OK,
|
||||
'health_rollup': None,
|
||||
'state': res_cons.State.ENABLED}},
|
||||
{'firmware_version': '2.20',
|
||||
'identity': '1',
|
||||
'indicator_led': None,
|
||||
|
@ -185,6 +190,7 @@ class PowerTestCase(base.TestCase):
|
|||
'power_supply_type': 'ac',
|
||||
'serial_number': '1S0000524',
|
||||
'spare_part_number': '425-591-654',
|
||||
'status': {'health': 'ok', 'health_rollup': None,
|
||||
'state': 'enabled'}}],
|
||||
'status': {'health': res_cons.Health.OK,
|
||||
'health_rollup': None,
|
||||
'state': res_cons.State.ENABLED}}],
|
||||
attributes.get('power_supplies'))
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
|
||||
from sushy.resources.chassis.thermal import thermal
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.tests.unit import base
|
||||
|
||||
|
||||
|
@ -43,8 +43,10 @@ class ThermalTestCase(base.TestCase):
|
|||
self.assertEqual('0', self.thermal.fans[0].identity)
|
||||
self.assertEqual('CPU Fan', self.thermal.fans[0].name)
|
||||
self.assertEqual('CPU', self.thermal.fans[0].physical_context)
|
||||
self.assertEqual('enabled', self.thermal.fans[0].status.state)
|
||||
self.assertEqual('ok', self.thermal.fans[0].status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.thermal.fans[0].status.state)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.thermal.fans[0].status.health)
|
||||
self.assertEqual(6000, self.thermal.fans[0].reading)
|
||||
self.assertEqual('RPM', self.thermal.fans[0].reading_units)
|
||||
self.assertEqual(2000, self.thermal.fans[0].lower_threshold_fatal)
|
||||
|
@ -53,8 +55,10 @@ class ThermalTestCase(base.TestCase):
|
|||
|
||||
self.assertEqual('0', self.thermal.temperatures[0].identity)
|
||||
self.assertEqual('CPU Temp', self.thermal.temperatures[0].name)
|
||||
self.assertEqual('enabled', self.thermal.temperatures[0].status.state)
|
||||
self.assertEqual('ok', self.thermal.temperatures[0].status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.thermal.temperatures[0].status.state)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.thermal.temperatures[0].status.health)
|
||||
self.assertEqual(62, self.thermal.temperatures[0].reading_celsius)
|
||||
self.assertEqual(
|
||||
75,
|
||||
|
@ -94,8 +98,9 @@ class ThermalTestCase(base.TestCase):
|
|||
'reading_units': 'RPM',
|
||||
'serial_number': None,
|
||||
'status':
|
||||
{'health': 'ok', 'health_rollup': None,
|
||||
'state': 'enabled'},
|
||||
{'health': res_cons.Health.OK,
|
||||
'health_rollup': None,
|
||||
'state': res_cons.State.ENABLED},
|
||||
'upper_threshold_critical': None,
|
||||
'upper_threshold_fatal': None,
|
||||
'upper_threshold_non_critical': None}],
|
||||
|
@ -112,8 +117,9 @@ class ThermalTestCase(base.TestCase):
|
|||
'physical_context': 'CPU',
|
||||
'reading_celsius': 62,
|
||||
'sensor_number': None,
|
||||
'status': {'health': 'ok', 'health_rollup': None,
|
||||
'state': 'enabled'},
|
||||
'status': {'health': res_cons.Health.OK,
|
||||
'health_rollup': None,
|
||||
'state': res_cons.State.ENABLED},
|
||||
'upper_threshold_critical': 90,
|
||||
'upper_threshold_fatal': 95,
|
||||
'upper_threshold_non_critical': 75}],
|
||||
|
|
|
@ -48,8 +48,8 @@ class CompositionServiceTestCase(base.TestCase):
|
|||
self.assertEqual(
|
||||
'Composition Service',
|
||||
self.comp_ser.name)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.comp_ser.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.comp_ser.status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.comp_ser.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.comp_ser.status.health)
|
||||
self.assertTrue(self.comp_ser.service_enabled)
|
||||
|
||||
@mock.patch.object(resourceblock, 'ResourceBlockCollection', autospec=True)
|
||||
|
|
|
@ -54,9 +54,9 @@ class ResourceBlockTestCase(base.TestCase):
|
|||
res_block_cons.RESOURCE_BLOCK_TYPE_STORAGE,
|
||||
self.res_block.resource_block_type)
|
||||
self.assertEqual(
|
||||
res_cons.STATE_ENABLED,
|
||||
res_cons.State.ENABLED,
|
||||
self.res_block.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.res_block.status.health)
|
||||
self.assertEqual(res_cons.Health.OK, self.res_block.status.health)
|
||||
exp_path = '/redfish/v1/CompositionService/ResourceBlocks/DriveBlock3'
|
||||
self.assertEqual(exp_path, self.res_block.path)
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ class ResourceZoneTestCase(base.TestCase):
|
|||
self.assertEqual('1', self.res_zone.identity)
|
||||
self.assertEqual('Resource Zone 1', self.res_zone.name)
|
||||
self.assertEqual(
|
||||
res_cons.STATE_ENABLED,
|
||||
res_cons.State.ENABLED,
|
||||
self.res_zone.status.state)
|
||||
self.assertEqual(
|
||||
res_cons.HEALTH_OK,
|
||||
res_cons.Health.OK,
|
||||
self.res_zone.status.health)
|
||||
exp_path = '/redfish/v1/CompositionService/ResourceZones/1'
|
||||
self.assertEqual(exp_path, self.res_zone.path)
|
||||
|
|
|
@ -15,6 +15,7 @@ from unittest import mock
|
|||
|
||||
import sushy
|
||||
from sushy import exceptions
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.eventservice import eventservice
|
||||
from sushy.tests.unit import base
|
||||
|
||||
|
@ -41,9 +42,11 @@ class EventServiceTestCase(base.TestCase):
|
|||
self.assertEqual(self.eventservice.delivery_retry_attempts, 3)
|
||||
self.assertEqual(self.eventservice.delivery_retry_interval, 30)
|
||||
self.assertEqual(self.eventservice.service_enabled, True)
|
||||
self.assertEqual(self.eventservice.status.health, 'ok')
|
||||
self.assertEqual(self.eventservice.status.health_rollup, 'ok')
|
||||
self.assertEqual(self.eventservice.status.state, 'enabled')
|
||||
self.assertEqual(self.eventservice.status.health, res_cons.Health.OK)
|
||||
self.assertEqual(self.eventservice.status.health_rollup,
|
||||
res_cons.Health.OK)
|
||||
self.assertEqual(self.eventservice.status.state,
|
||||
res_cons.State.ENABLED)
|
||||
self.assertEqual(self.eventservice.subscriptions._path,
|
||||
'/redfish/v1/EventService/Subscriptions/')
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ class FabricTestCase(base.TestCase):
|
|||
self.fabric.description)
|
||||
self.assertEqual(sushy.PROTOCOL_TYPE_SAS,
|
||||
self.fabric.fabric_type)
|
||||
self.assertEqual(sushy.STATE_ENABLED, self.fabric.status.state)
|
||||
self.assertEqual(sushy.HEALTH_OK, self.fabric.status.health)
|
||||
self.assertEqual(sushy.State.ENABLED, self.fabric.status.state)
|
||||
self.assertEqual(sushy.Health.OK, self.fabric.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# | GIVEN |
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base as sushy_base
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.registry import attribute_registry
|
||||
from sushy.resources.registry import constants as reg_cons
|
||||
from sushy.resources.registry import message_registry
|
||||
from sushy.tests.unit import base
|
||||
|
||||
|
@ -53,18 +54,18 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
self.registry.messages['Success'].description)
|
||||
self.assertEqual('Everything done successfully.',
|
||||
self.registry.messages['Success'].message)
|
||||
self.assertEqual(res_cons.SEVERITY_OK,
|
||||
self.assertEqual(res_cons.Severity.OK,
|
||||
self.registry.messages['Success'].severity)
|
||||
self.assertEqual(0, self.registry.messages['Success'].number_of_args)
|
||||
self.assertEqual(2, len(self.registry.messages['TooBig'].param_types))
|
||||
self.assertEqual(res_cons.PARAMTYPE_STRING,
|
||||
self.assertEqual(reg_cons.MessageParamType.STRING,
|
||||
self.registry.messages['TooBig'].param_types[0])
|
||||
self.assertEqual(res_cons.PARAMTYPE_NUMBER,
|
||||
self.assertEqual(reg_cons.MessageParamType.NUMBER,
|
||||
self.registry.messages['TooBig'].param_types[1])
|
||||
self.assertEqual('Panic', self.registry.messages['Failed'].resolution)
|
||||
self.assertEqual(
|
||||
2, len(self.registry.messages['MissingThings'].param_types))
|
||||
self.assertEqual(res_cons.SEVERITY_WARNING,
|
||||
self.assertEqual(res_cons.Severity.WARNING,
|
||||
self.registry.messages['MissingThings'].severity)
|
||||
self.assertEqual(
|
||||
res_cons.PARAMTYPE_STRING,
|
||||
|
@ -82,30 +83,33 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
{'description': 'Nothing is OK',
|
||||
'message': 'The property %1 broke everything.',
|
||||
'number_of_args': 1,
|
||||
'param_types': ['string'],
|
||||
'param_types': [reg_cons.MessageParamType.STRING],
|
||||
'resolution': 'Panic',
|
||||
'severity': 'critical'},
|
||||
'severity': res_cons.Severity.CRITICAL},
|
||||
'MissingThings':
|
||||
{'description': '',
|
||||
'message':
|
||||
"Property's %1 value cannot be less than %2.",
|
||||
'number_of_args': 2,
|
||||
'param_types': ['string', 'number'],
|
||||
'param_types': [reg_cons.MessageParamType.STRING,
|
||||
reg_cons.MessageParamType.NUMBER],
|
||||
'resolution': 'Try Later',
|
||||
'severity': 'warning'},
|
||||
'severity': res_cons.Severity.WARNING},
|
||||
'Success':
|
||||
{'description': 'Everything OK',
|
||||
'message': 'Everything done successfully.',
|
||||
'number_of_args': 0, 'param_types': None,
|
||||
'resolution': 'None', 'severity': 'ok'},
|
||||
'resolution': 'None',
|
||||
'severity': res_cons.Severity.OK},
|
||||
'TooBig':
|
||||
{'description': 'Value too big',
|
||||
'message':
|
||||
"Property's %1 value cannot be greater than %2.",
|
||||
'number_of_args': 2,
|
||||
'param_types': ['string', 'number'],
|
||||
'param_types': [reg_cons.MessageParamType.STRING,
|
||||
reg_cons.MessageParamType.NUMBER],
|
||||
'resolution': 'Try again',
|
||||
'severity': 'warning'}},
|
||||
'severity': res_cons.Severity.WARNING}},
|
||||
attributes.get('messages'))
|
||||
|
||||
def test__parse_attributes_missing_msg_desc(self):
|
||||
|
@ -116,12 +120,13 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
def test__parse_attributes_missing_msg_severity(self):
|
||||
self.json_doc['Messages']['Success'].pop('Severity')
|
||||
self.registry._parse_attributes(self.json_doc)
|
||||
self.assertEqual('warning', self.registry.messages['Success'].severity)
|
||||
self.assertEqual(res_cons.Severity.WARNING,
|
||||
self.registry.messages['Success'].severity)
|
||||
|
||||
def test__parse_attributes_unknown_param_type(self):
|
||||
self.registry.json['Messages']['Failed']['ParamTypes'] = \
|
||||
['unknown_type']
|
||||
self.assertRaisesRegex(KeyError,
|
||||
self.assertRaisesRegex(exceptions.MalformedAttributeError,
|
||||
'unknown_type',
|
||||
self.registry._parse_attributes, self.json_doc)
|
||||
|
||||
|
@ -142,7 +147,7 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Try again', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_WARNING, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.WARNING, parsed_msg.severity)
|
||||
self.assertEqual('Property\'s arg1 value cannot be greater than 10.',
|
||||
parsed_msg.message)
|
||||
|
||||
|
@ -156,13 +161,13 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
registries = {'Test.1.0.0': registry}
|
||||
message_field = sushy_base.MessageListField('Foo')
|
||||
message_field.message_id = 'Test.1.0.0.Success'
|
||||
message_field.severity = res_cons.SEVERITY_OK
|
||||
message_field.severity = res_cons.Severity.OK
|
||||
message_field.resolution = 'Do nothing'
|
||||
|
||||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Do nothing', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_OK, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.OK, parsed_msg.severity)
|
||||
self.assertEqual('Everything done successfully.',
|
||||
parsed_msg.message)
|
||||
|
||||
|
@ -225,13 +230,13 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
registries = {'Messages': registry}
|
||||
message_field = sushy_base.MessageListField('Foo')
|
||||
message_field.message_id = 'Success'
|
||||
message_field.severity = res_cons.SEVERITY_OK
|
||||
message_field.severity = res_cons.Severity.OK
|
||||
message_field.resolution = 'Do nothing'
|
||||
|
||||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Do nothing', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_OK, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.OK, parsed_msg.severity)
|
||||
self.assertEqual('Everything done successfully.',
|
||||
parsed_msg.message)
|
||||
|
||||
|
@ -245,13 +250,13 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
registries = {'BaseMessages': registry}
|
||||
message_field = sushy_base.MessageListField('Foo')
|
||||
message_field.message_id = 'Success'
|
||||
message_field.severity = res_cons.SEVERITY_OK
|
||||
message_field.severity = res_cons.Severity.OK
|
||||
message_field.resolution = 'Do nothing'
|
||||
|
||||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Do nothing', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_OK, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.OK, parsed_msg.severity)
|
||||
self.assertEqual('Everything done successfully.',
|
||||
parsed_msg.message)
|
||||
|
||||
|
@ -289,7 +294,7 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Try again', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_WARNING, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.WARNING, parsed_msg.severity)
|
||||
self.assertEqual('Property\'s arg1 value cannot be greater than '
|
||||
'unknown.', parsed_msg.message)
|
||||
|
||||
|
@ -314,6 +319,6 @@ class MessageRegistryTestCase(base.TestCase):
|
|||
parsed_msg = message_registry.parse_message(registries, message_field)
|
||||
|
||||
self.assertEqual('Try again', parsed_msg.resolution)
|
||||
self.assertEqual(res_cons.SEVERITY_WARNING, parsed_msg.severity)
|
||||
self.assertEqual(res_cons.Severity.WARNING, parsed_msg.severity)
|
||||
self.assertEqual('Property\'s arg1 value cannot be greater than 10.',
|
||||
parsed_msg.message)
|
||||
|
|
|
@ -56,8 +56,8 @@ class DriveTestCase(base.TestCase):
|
|||
self.assertEqual(sushy.PROTOCOL_TYPE_SAS, self.stor_drive.protocol)
|
||||
self.assertEqual('1234570', self.stor_drive.serial_number)
|
||||
self.assertEqual('100A', self.stor_drive.revision)
|
||||
self.assertEqual(sushy.STATE_ENABLED, self.stor_drive.status.state)
|
||||
self.assertEqual(sushy.HEALTH_OK, self.stor_drive.status.health)
|
||||
self.assertEqual(sushy.State.ENABLED, self.stor_drive.status.state)
|
||||
self.assertEqual(sushy.Health.OK, self.stor_drive.status.health)
|
||||
|
||||
def test_volumes(self):
|
||||
with open('sushy/tests/unit/json_samples/drive3.json') as f:
|
||||
|
@ -86,7 +86,7 @@ class DriveTestCase(base.TestCase):
|
|||
with mock.patch.object(
|
||||
self.stor_drive, 'invalidate',
|
||||
autospec=True) as invalidate_mock:
|
||||
self.stor_drive.set_indicator_led(sushy.INDICATOR_LED_BLINKING)
|
||||
self.stor_drive.set_indicator_led(sushy.IndicatorLED.BLINKING)
|
||||
self.stor_drive._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138/Storage/1/Drives/'
|
||||
'32ADF365C6C1B7BD', data={'IndicatorLED': 'Blinking'})
|
||||
|
|
|
@ -15,6 +15,7 @@ from unittest import mock
|
|||
|
||||
|
||||
import sushy
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.system.storage import drive
|
||||
from sushy.resources.system.storage import storage
|
||||
from sushy.resources.system.storage import volume
|
||||
|
@ -54,9 +55,9 @@ class StorageTestCase(base.TestCase):
|
|||
self.assertEqual('1.0.2', self.storage.redfish_version)
|
||||
self.assertEqual('1', self.storage.identity)
|
||||
self.assertEqual('Local Storage Controller', self.storage.name)
|
||||
self.assertEqual('ok', self.storage.status.health)
|
||||
self.assertEqual('ok', self.storage.status.health_rollup)
|
||||
self.assertEqual('enabled', self.storage.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.storage.status.health)
|
||||
self.assertEqual(res_cons.Health.OK, self.storage.status.health_rollup)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.storage.status.state)
|
||||
self.assertEqual(
|
||||
('/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/35D38F11ACEF7BD3', # noqa
|
||||
'/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/3F5A8C54207B7233', # noqa
|
||||
|
@ -118,8 +119,8 @@ class StorageTestCase(base.TestCase):
|
|||
controller = controllers[0]
|
||||
self.assertEqual('0', controller.member_id)
|
||||
self.assertEqual('Contoso Integrated RAID', controller.name)
|
||||
self.assertEqual('ok', controller.status.health)
|
||||
self.assertEqual('enabled', controller.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, controller.status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED, controller.status.state)
|
||||
identifiers = controller.identifiers
|
||||
self.assertIsInstance(identifiers, list)
|
||||
self.assertEqual(1, len(identifiers))
|
||||
|
|
|
@ -61,7 +61,7 @@ class VolumeTestCase(base.TestCase):
|
|||
'Volumes/1/Actions/Volume.Initialize'
|
||||
self.stor_volume.initialize(
|
||||
store_cons.VOLUME_INIT_TYPE_FAST,
|
||||
apply_time=res_cons.APPLY_TIME_IMMEDIATE)
|
||||
apply_time=res_cons.ApplyTime.IMMEDIATE)
|
||||
self.stor_volume._conn.post.assert_called_once_with(
|
||||
target_uri, data={'InitializeType': 'Fast',
|
||||
'@Redfish.OperationApplyTime': 'Immediate'},
|
||||
|
@ -72,7 +72,7 @@ class VolumeTestCase(base.TestCase):
|
|||
'Volumes/1/Actions/Volume.Initialize'
|
||||
self.stor_volume.initialize(
|
||||
store_cons.VOLUME_INIT_TYPE_FAST,
|
||||
apply_time=res_cons.APPLY_TIME_ON_RESET)
|
||||
apply_time=res_cons.ApplyTime.ON_RESET)
|
||||
self.stor_volume._conn.post.assert_called_once_with(
|
||||
target_uri, data={'InitializeType': 'Fast',
|
||||
'@Redfish.OperationApplyTime': 'OnReset'},
|
||||
|
@ -82,7 +82,7 @@ class VolumeTestCase(base.TestCase):
|
|||
payload = {}
|
||||
self.conn.delete.return_value.status_code = 200
|
||||
resource = self.stor_volume.delete(
|
||||
payload=payload, apply_time=res_cons.APPLY_TIME_IMMEDIATE)
|
||||
payload=payload, apply_time=res_cons.ApplyTime.IMMEDIATE)
|
||||
self.stor_volume._conn.delete.assert_called_once_with(
|
||||
self.stor_volume._path, data=payload, blocking=True, timeout=500)
|
||||
self.assertIsNone(resource)
|
||||
|
@ -97,7 +97,7 @@ class VolumeTestCase(base.TestCase):
|
|||
self.conn.delete.return_value.json.return_value = {'Id': 3,
|
||||
'Name': 'Test'}
|
||||
task_mon = self.stor_volume.delete(
|
||||
payload=payload, apply_time=res_cons.APPLY_TIME_ON_RESET,
|
||||
payload=payload, apply_time=res_cons.ApplyTime.ON_RESET,
|
||||
timeout=250)
|
||||
self.stor_volume._conn.delete.assert_called_once_with(
|
||||
self.stor_volume._path, data=payload, blocking=False, timeout=250)
|
||||
|
@ -141,9 +141,9 @@ class VolumeCollectionTestCase(base.TestCase):
|
|||
support._maintenance_window_resource.resource_uri)
|
||||
self.assertEqual(['Immediate', 'OnReset', 'AtMaintenanceWindowStart'],
|
||||
support.supported_values)
|
||||
self.assertEqual([res_cons.APPLY_TIME_IMMEDIATE,
|
||||
res_cons.APPLY_TIME_ON_RESET,
|
||||
res_cons.APPLY_TIME_MAINT_START],
|
||||
self.assertEqual([res_cons.ApplyTime.IMMEDIATE,
|
||||
res_cons.ApplyTime.ON_RESET,
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START],
|
||||
support.mapped_supported_values)
|
||||
|
||||
@mock.patch.object(volume, 'Volume', autospec=True)
|
||||
|
@ -227,7 +227,7 @@ class VolumeCollectionTestCase(base.TestCase):
|
|||
'Location': '/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/4'
|
||||
}
|
||||
new_vol = self.stor_vol_col.create(
|
||||
payload, apply_time=res_cons.APPLY_TIME_IMMEDIATE)
|
||||
payload, apply_time=res_cons.ApplyTime.IMMEDIATE)
|
||||
self.stor_vol_col._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes',
|
||||
data=expected_payload, blocking=True, timeout=500)
|
||||
|
@ -258,7 +258,7 @@ class VolumeCollectionTestCase(base.TestCase):
|
|||
'Retry-After': '120'
|
||||
}
|
||||
task_mon = self.stor_vol_col.create(
|
||||
payload, apply_time=res_cons.APPLY_TIME_ON_RESET)
|
||||
payload, apply_time=res_cons.ApplyTime.ON_RESET)
|
||||
self.stor_vol_col._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes',
|
||||
data=expected_payload, blocking=False, timeout=500)
|
||||
|
|
|
@ -79,8 +79,8 @@ class BiosTestCase(base.TestCase):
|
|||
self.assertEqual('', self.sys_bios.attributes['AdminPhone'])
|
||||
self.assertEqual('Uefi', self.sys_bios.attributes['BootMode'])
|
||||
self.assertEqual(0, self.sys_bios.attributes['ProcCoreDisable'])
|
||||
self.assertEqual([res_cons.APPLY_TIME_ON_RESET,
|
||||
res_cons.APPLY_TIME_MAINT_RESET],
|
||||
self.assertEqual([res_cons.ApplyTime.ON_RESET,
|
||||
res_cons.ApplyTime.IN_MAINTENANCE_WINDOW_ON_RESET],
|
||||
self.sys_bios.supported_apply_times)
|
||||
self.assertEqual(600, self.sys_bios.maintenance_window
|
||||
.maintenance_window_duration_in_seconds)
|
||||
|
@ -126,7 +126,7 @@ class BiosTestCase(base.TestCase):
|
|||
|
||||
def test_set_attribute_apply_time(self):
|
||||
self.sys_bios.set_attribute('ProcTurboMode', 'Disabled',
|
||||
res_cons.APPLY_TIME_ON_RESET)
|
||||
res_cons.ApplyTime.ON_RESET)
|
||||
self.sys_bios._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/BIOS/Settings',
|
||||
data={'Attributes': {'ProcTurboMode': 'Disabled'},
|
||||
|
@ -135,10 +135,11 @@ class BiosTestCase(base.TestCase):
|
|||
'ApplyTime': 'OnReset'}})
|
||||
|
||||
def test_set_attribute_apply_time_with_maintenance_window(self):
|
||||
self.sys_bios.set_attribute('ProcTurboMode', 'Disabled',
|
||||
res_cons.APPLY_TIME_MAINT_RESET,
|
||||
datetime.datetime(2020, 9, 1, 4, 30, 0),
|
||||
600)
|
||||
self.sys_bios.set_attribute(
|
||||
'ProcTurboMode', 'Disabled',
|
||||
res_cons.ApplyTime.IN_MAINTENANCE_WINDOW_ON_RESET,
|
||||
datetime.datetime(2020, 9, 1, 4, 30, 0),
|
||||
600)
|
||||
self.sys_bios._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/BIOS/Settings',
|
||||
data={'Attributes': {'ProcTurboMode': 'Disabled'},
|
||||
|
@ -175,7 +176,7 @@ class BiosTestCase(base.TestCase):
|
|||
def test_set_attributes_apply_time(self):
|
||||
self.sys_bios.set_attributes({'ProcTurboMode': 'Disabled',
|
||||
'UsbControl': 'UsbDisabled'},
|
||||
res_cons.APPLY_TIME_IMMEDIATE)
|
||||
res_cons.ApplyTime.IMMEDIATE)
|
||||
self.sys_bios._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/BIOS/Settings',
|
||||
data={'Attributes': {'ProcTurboMode': 'Disabled',
|
||||
|
@ -185,11 +186,11 @@ class BiosTestCase(base.TestCase):
|
|||
'ApplyTime': 'Immediate'}})
|
||||
|
||||
def test_set_attributes_apply_time_with_maintenance_window(self):
|
||||
self.sys_bios.set_attributes({'ProcTurboMode': 'Disabled',
|
||||
'UsbControl': 'UsbDisabled'},
|
||||
res_cons.APPLY_TIME_MAINT_START,
|
||||
datetime.datetime(2020, 9, 1, 4, 30, 0),
|
||||
600)
|
||||
self.sys_bios.set_attributes(
|
||||
{'ProcTurboMode': 'Disabled', 'UsbControl': 'UsbDisabled'},
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START,
|
||||
datetime.datetime(2020, 9, 1, 4, 30, 0),
|
||||
600)
|
||||
self.sys_bios._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/BIOS/Settings',
|
||||
data={'Attributes': {'ProcTurboMode': 'Disabled',
|
||||
|
@ -213,7 +214,7 @@ class BiosTestCase(base.TestCase):
|
|||
self.sys_bios.set_attributes,
|
||||
{'ProcTurboMode': 'Disabled',
|
||||
'UsbControl': 'UsbDisabled'},
|
||||
res_cons.APPLY_TIME_MAINT_START,
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START,
|
||||
maint_window_duration=600)
|
||||
|
||||
def test_set_attributes_maint_window_duration_missing(self):
|
||||
|
@ -221,7 +222,7 @@ class BiosTestCase(base.TestCase):
|
|||
self.sys_bios.set_attributes,
|
||||
{'ProcTurboMode': 'Disabled',
|
||||
'UsbControl': 'UsbDisabled'},
|
||||
res_cons.APPLY_TIME_MAINT_START,
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START,
|
||||
datetime.datetime.now())
|
||||
|
||||
def test_set_attributes_on_refresh(self):
|
||||
|
|
|
@ -44,8 +44,8 @@ class EthernetInterfaceTestCase(base.TestCase):
|
|||
self.assertEqual(
|
||||
'12:44:6A:3B:04:11', self.sys_eth.permanent_mac_address)
|
||||
self.assertEqual('12:44:6A:3B:04:11', self.sys_eth.mac_address)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.sys_eth.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.sys_eth.status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.sys_eth.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.sys_eth.status.health)
|
||||
self.assertEqual(1000, self.sys_eth.speed_mbps)
|
||||
|
||||
|
||||
|
@ -105,6 +105,6 @@ class EthernetInterfaceCollectionTestCase(base.TestCase):
|
|||
with open('sushy/tests/unit/json_samples/'
|
||||
'ethernet_interfaces.json') as f:
|
||||
self.conn.get.return_value.json.return_value = json.load(f)
|
||||
expected_summary = {'12:44:6A:3B:04:11': res_cons.STATE_ENABLED}
|
||||
expected_summary = {'12:44:6A:3B:04:11': res_cons.State.ENABLED}
|
||||
actual_summary = self.sys_eth_col.summary
|
||||
self.assertEqual(expected_summary, actual_summary)
|
||||
|
|
|
@ -71,10 +71,10 @@ class ProcessorTestCase(base.TestCase):
|
|||
self.assertEqual(3700, self.sys_processor.max_speed_mhz)
|
||||
self.assertEqual(8, self.sys_processor.total_cores)
|
||||
self.assertEqual(16, self.sys_processor.total_threads)
|
||||
self.assertEqual(res_cons.STATE_ENABLED,
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.sys_processor.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.sys_processor.status.health)
|
||||
self.assertEqual(res_cons.HEALTH_OK,
|
||||
self.assertEqual(res_cons.Health.OK, self.sys_processor.status.health)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.sys_processor.status.health_rollup)
|
||||
|
||||
def test_sub_processors(self):
|
||||
|
|
|
@ -43,11 +43,11 @@ class SimpleStorageTestCase(base.TestCase):
|
|||
self.simpl_stor.devices[0].capacity_bytes)
|
||||
self.assertEqual(4000000000000,
|
||||
self.simpl_stor.devices[1].capacity_bytes)
|
||||
self.assertEqual(res_cons.STATE_ENABLED,
|
||||
self.assertEqual(res_cons.State.ENABLED,
|
||||
self.simpl_stor.devices[0].status.state)
|
||||
self.assertEqual(res_cons.STATE_ABSENT,
|
||||
self.assertEqual(res_cons.State.ABSENT,
|
||||
self.simpl_stor.devices[2].status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK,
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.simpl_stor.devices[0].status.health)
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class SystemTestCase(base.TestCase):
|
|||
self.assertEqual('Web Front End node', self.sys_inst.description)
|
||||
self.assertEqual('web483', self.sys_inst.hostname)
|
||||
self.assertEqual('437XR1138R2', self.sys_inst.identity)
|
||||
self.assertEqual(sushy.INDICATOR_LED_OFF,
|
||||
self.assertEqual(sushy.IndicatorLED.OFF,
|
||||
self.sys_inst.indicator_led)
|
||||
self.assertEqual('Contoso', self.sys_inst.manufacturer)
|
||||
self.assertEqual('WebFrontEnd483', self.sys_inst.name)
|
||||
|
@ -66,9 +66,9 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst.system_type)
|
||||
self.assertEqual('38947555-7742-3448-3784-823347823834',
|
||||
self.sys_inst.uuid)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.sys_inst.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.sys_inst.status.health)
|
||||
self.assertEqual(res_cons.HEALTH_OK,
|
||||
self.assertEqual(res_cons.State.ENABLED, self.sys_inst.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.sys_inst.status.health)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.sys_inst.status.health_rollup)
|
||||
self.assertEqual(sushy.SYSTEM_POWER_STATE_ON,
|
||||
self.sys_inst.power_state)
|
||||
|
@ -88,36 +88,37 @@ class SystemTestCase(base.TestCase):
|
|||
|
||||
# Test that various types are returned correctly
|
||||
self.assertEqual('Chicago-45Z-2381', attributes.get('asset_tag'))
|
||||
self.assertEqual(sushy.INDICATOR_LED_OFF,
|
||||
self.assertEqual(sushy.IndicatorLED.OFF,
|
||||
attributes.get('indicator_led'))
|
||||
self.assertEqual({'health': res_cons.HEALTH_OK,
|
||||
'health_rollup': res_cons.HEALTH_OK,
|
||||
'state': res_cons.STATE_ENABLED},
|
||||
self.assertEqual({'health': res_cons.Health.OK,
|
||||
'health_rollup': res_cons.Health.OK,
|
||||
'state': res_cons.State.ENABLED},
|
||||
attributes.get('status'))
|
||||
self.assertEqual({'maintenance_window_duration_in_seconds': 1,
|
||||
'maintenance_window_start_time':
|
||||
parser.parse('2016-03-07T14:44:30-05:05')},
|
||||
attributes.get('maintenance_window'))
|
||||
self.assertEqual({'reset': {'allowed_values':
|
||||
['On', 'ForceOff', 'GracefulShutdown',
|
||||
'GracefulRestart', 'ForceRestart', 'Nmi',
|
||||
'ForceOn', 'PushPowerButton'],
|
||||
'operation_apply_time_support':
|
||||
{'_maintenance_window_resource':
|
||||
{'resource_uri':
|
||||
'/redfish/v1/Systems/437XR1138R2'},
|
||||
'maintenance_window_duration_in_seconds': 600,
|
||||
'maintenance_window_start_time':
|
||||
parser.parse('2017-05-03T23:12:37-05:00'),
|
||||
'supported_values':
|
||||
['Immediate', 'AtMaintenanceWindowStart'],
|
||||
'mapped_supported_values':
|
||||
[res_cons.APPLY_TIME_IMMEDIATE,
|
||||
res_cons.APPLY_TIME_MAINT_START]},
|
||||
'target_uri':
|
||||
'/redfish/v1/Systems/437XR1138R2/Actions/'
|
||||
'ComputerSystem.Reset'}},
|
||||
attributes.get('_actions'))
|
||||
self.assertEqual(
|
||||
{'reset': {'allowed_values':
|
||||
['On', 'ForceOff', 'GracefulShutdown',
|
||||
'GracefulRestart', 'ForceRestart', 'Nmi',
|
||||
'ForceOn', 'PushPowerButton'],
|
||||
'operation_apply_time_support':
|
||||
{'_maintenance_window_resource':
|
||||
{'resource_uri':
|
||||
'/redfish/v1/Systems/437XR1138R2'},
|
||||
'maintenance_window_duration_in_seconds': 600,
|
||||
'maintenance_window_start_time':
|
||||
parser.parse('2017-05-03T23:12:37-05:00'),
|
||||
'supported_values':
|
||||
['Immediate', 'AtMaintenanceWindowStart'],
|
||||
'mapped_supported_values':
|
||||
[res_cons.ApplyTime.IMMEDIATE,
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START]},
|
||||
'target_uri':
|
||||
'/redfish/v1/Systems/437XR1138R2/Actions/'
|
||||
'ComputerSystem.Reset'}},
|
||||
attributes.get('_actions'))
|
||||
|
||||
def test__parse_attributes_missing_actions(self):
|
||||
self.sys_inst.json.pop('Actions')
|
||||
|
@ -176,14 +177,14 @@ class SystemTestCase(base.TestCase):
|
|||
|
||||
def test_get_allowed_reset_system_values(self):
|
||||
values = self.sys_inst.get_allowed_reset_system_values()
|
||||
expected = set([sushy.RESET_GRACEFUL_SHUTDOWN,
|
||||
sushy.RESET_GRACEFUL_RESTART,
|
||||
sushy.RESET_FORCE_RESTART,
|
||||
sushy.RESET_FORCE_OFF,
|
||||
sushy.RESET_FORCE_ON,
|
||||
sushy.RESET_ON,
|
||||
sushy.RESET_NMI,
|
||||
sushy.RESET_PUSH_POWER_BUTTON])
|
||||
expected = set([sushy.ResetType.GRACEFUL_SHUTDOWN,
|
||||
sushy.ResetType.GRACEFUL_RESTART,
|
||||
sushy.ResetType.FORCE_RESTART,
|
||||
sushy.ResetType.FORCE_OFF,
|
||||
sushy.ResetType.FORCE_ON,
|
||||
sushy.ResetType.ON,
|
||||
sushy.ResetType.NMI,
|
||||
sushy.ResetType.PUSH_POWER_BUTTON])
|
||||
self.assertEqual(expected, values)
|
||||
self.assertIsInstance(values, set)
|
||||
|
||||
|
@ -193,14 +194,18 @@ class SystemTestCase(base.TestCase):
|
|||
self.sys_inst._actions.reset.allowed_values = {}
|
||||
values = self.sys_inst.get_allowed_reset_system_values()
|
||||
# Assert it returns all values if it can't get the specific ones
|
||||
expected = set([sushy.RESET_GRACEFUL_SHUTDOWN,
|
||||
sushy.RESET_GRACEFUL_RESTART,
|
||||
sushy.RESET_FORCE_RESTART,
|
||||
sushy.RESET_FORCE_OFF,
|
||||
sushy.RESET_FORCE_ON,
|
||||
sushy.RESET_ON,
|
||||
sushy.RESET_NMI,
|
||||
sushy.RESET_PUSH_POWER_BUTTON])
|
||||
expected = set([sushy.ResetType.GRACEFUL_SHUTDOWN,
|
||||
sushy.ResetType.GRACEFUL_RESTART,
|
||||
sushy.ResetType.FORCE_RESTART,
|
||||
sushy.ResetType.FORCE_OFF,
|
||||
sushy.ResetType.FORCE_ON,
|
||||
sushy.ResetType.ON,
|
||||
sushy.ResetType.NMI,
|
||||
sushy.ResetType.PUSH_POWER_BUTTON,
|
||||
sushy.ResetType.POWER_CYCLE,
|
||||
sushy.ResetType.SUSPEND,
|
||||
sushy.ResetType.RESUME,
|
||||
sushy.ResetType.PAUSE])
|
||||
self.assertEqual(expected, values)
|
||||
self.assertIsInstance(values, set)
|
||||
self.assertEqual(1, mock_log.call_count)
|
||||
|
@ -210,8 +215,8 @@ class SystemTestCase(base.TestCase):
|
|||
self.assertIsNotNone(support)
|
||||
self.assertEqual(['Immediate', 'AtMaintenanceWindowStart'],
|
||||
support.supported_values)
|
||||
self.assertEqual([res_cons.APPLY_TIME_IMMEDIATE,
|
||||
res_cons.APPLY_TIME_MAINT_START],
|
||||
self.assertEqual([res_cons.ApplyTime.IMMEDIATE,
|
||||
res_cons.ApplyTime.AT_MAINTENANCE_WINDOW_START],
|
||||
support.mapped_supported_values)
|
||||
self.assertEqual(parser.parse('2017-05-03T23:12:37-05:00'),
|
||||
support.maintenance_window_start_time)
|
||||
|
@ -220,7 +225,7 @@ class SystemTestCase(base.TestCase):
|
|||
support._maintenance_window_resource.resource_uri)
|
||||
|
||||
def test_reset_system(self):
|
||||
self.sys_inst.reset_system(sushy.RESET_FORCE_OFF)
|
||||
self.sys_inst.reset_system(sushy.ResetType.FORCE_OFF)
|
||||
self.sys_inst._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/Actions/ComputerSystem.Reset',
|
||||
data={'ResetType': 'ForceOff'})
|
||||
|
@ -363,7 +368,7 @@ class SystemTestCase(base.TestCase):
|
|||
def test_set_indicator_led(self):
|
||||
with mock.patch.object(
|
||||
self.sys_inst, 'invalidate', autospec=True) as invalidate_mock:
|
||||
self.sys_inst.set_indicator_led(sushy.INDICATOR_LED_BLINKING)
|
||||
self.sys_inst.set_indicator_led(sushy.IndicatorLED.BLINKING)
|
||||
self.sys_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2',
|
||||
data={'IndicatorLED': 'Blinking'})
|
||||
|
@ -513,7 +518,7 @@ class SystemTestCase(base.TestCase):
|
|||
|
||||
actual_macs = self.sys_inst.ethernet_interfaces.summary
|
||||
expected_macs = (
|
||||
{'12:44:6A:3B:04:11': res_cons.STATE_ENABLED})
|
||||
{'12:44:6A:3B:04:11': res_cons.State.ENABLED})
|
||||
self.assertEqual(expected_macs, actual_macs)
|
||||
|
||||
def test_bios(self):
|
||||
|
|
|
@ -16,6 +16,7 @@ import json
|
|||
from unittest import mock
|
||||
|
||||
from sushy.resources import constants as res_cons
|
||||
from sushy.resources.taskservice import constants as ts_cons
|
||||
from sushy.resources.taskservice import task
|
||||
from sushy.tests.unit import base
|
||||
|
||||
|
@ -50,14 +51,14 @@ class TaskTestCase(base.TestCase):
|
|||
self.assertEqual('2012-03-07T14:44+06:00', self.task.start_time)
|
||||
self.assertEqual('2012-03-07T14:45+06:00', self.task.end_time)
|
||||
self.assertEqual(100, self.task.percent_complete)
|
||||
self.assertEqual(res_cons.TASK_STATE_COMPLETED, self.task.task_state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.task.task_status)
|
||||
self.assertEqual(ts_cons.TaskState.COMPLETED, self.task.task_state)
|
||||
self.assertEqual(res_cons.Health.OK, self.task.task_status)
|
||||
self.assertEqual(1, len(self.task.messages))
|
||||
self.assertEqual('Base.1.0.PropertyNotWriteable',
|
||||
self.task.messages[0].message_id)
|
||||
self.assertEqual('Property %1 is read only.',
|
||||
self.task.messages[0].message)
|
||||
self.assertEqual(res_cons.SEVERITY_WARNING,
|
||||
self.assertEqual(res_cons.Severity.WARNING,
|
||||
self.task.messages[0].severity)
|
||||
|
||||
def test_is_processing_true(self):
|
||||
|
@ -143,7 +144,8 @@ class TaskCollectionTestCase(base.TestCase):
|
|||
# | WHEN |
|
||||
actual_summary = self.task_col.summary
|
||||
# | THEN |
|
||||
self.assertEqual({'545': 'completed', '546': 'pending'},
|
||||
self.assertEqual({'545': ts_cons.TaskState.COMPLETED,
|
||||
'546': ts_cons.TaskState.PENDING},
|
||||
actual_summary)
|
||||
|
||||
# reset mock
|
||||
|
@ -159,7 +161,8 @@ class TaskCollectionTestCase(base.TestCase):
|
|||
# | GIVEN |
|
||||
self._setUp_task_summary()
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual({'545': 'completed', '546': 'pending'},
|
||||
self.assertEqual({'545': ts_cons.TaskState.COMPLETED,
|
||||
'546': ts_cons.TaskState.PENDING},
|
||||
self.task_col.summary)
|
||||
|
||||
self.conn.get.return_value.json.side_effect = None
|
||||
|
@ -173,5 +176,6 @@ class TaskCollectionTestCase(base.TestCase):
|
|||
# | GIVEN |
|
||||
self._setUp_task_summary()
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual({'545': 'completed', '546': 'pending'},
|
||||
self.assertEqual({'545': ts_cons.TaskState.COMPLETED,
|
||||
'546': ts_cons.TaskState.PENDING},
|
||||
self.task_col.summary)
|
||||
|
|
|
@ -40,8 +40,8 @@ class TaskServiceTestCase(base.TestCase):
|
|||
self.assertEqual('TaskService', self.tsk_serv.identity)
|
||||
self.assertTrue(self.tsk_serv.service_enabled)
|
||||
self.assertTrue(self.tsk_serv.event_on_task_state_change)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.tsk_serv.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.tsk_serv.status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.tsk_serv.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.tsk_serv.status.health)
|
||||
self.assertEqual(self.tsk_serv.overwrite_policy,
|
||||
ts_cons.OVERWRITE_POLICY_MANUAL)
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class SettingsFieldTestCase(base.TestCase):
|
|||
instance.messages[0].message_id)
|
||||
self.assertEqual('Settings %1 update failed due to invalid value',
|
||||
instance.messages[0].message)
|
||||
self.assertEqual(res_cons.SEVERITY_CRITICAL,
|
||||
self.assertEqual(res_cons.Severity.CRITICAL,
|
||||
instance.messages[0].severity)
|
||||
self.assertEqual('Fix the value and try again',
|
||||
instance.messages[0].resolution)
|
||||
|
@ -63,8 +63,8 @@ class SettingsFieldTestCase(base.TestCase):
|
|||
instance.messages[0]._related_properties[0])
|
||||
self.assertEqual('/redfish/v1/Systems/437XR1138R2/BIOS/Settings',
|
||||
instance._settings_object_idref.resource_uri)
|
||||
self.assertEqual([res_cons.APPLY_TIME_ON_RESET,
|
||||
res_cons.APPLY_TIME_MAINT_RESET],
|
||||
self.assertEqual([res_cons.ApplyTime.ON_RESET,
|
||||
res_cons.ApplyTime.IN_MAINTENANCE_WINDOW_ON_RESET],
|
||||
instance._supported_apply_times)
|
||||
self.assertIsNone(instance.maintenance_window)
|
||||
mock_LOG.warning.assert_called_once()
|
||||
|
@ -87,18 +87,18 @@ class SettingsFieldTestCase(base.TestCase):
|
|||
self.assertEqual(status.status,
|
||||
settings.UPDATE_FAILURE)
|
||||
self.assertEqual(status.messages[0].severity,
|
||||
res_cons.SEVERITY_CRITICAL)
|
||||
res_cons.Severity.CRITICAL)
|
||||
self.assertEqual(status.messages[0].message,
|
||||
'The property arg1 broke everything.')
|
||||
|
||||
def test_get_status_success(self):
|
||||
instance = self.settings._load(self.json, mock.Mock())
|
||||
instance.messages[0].message_id = 'Test.1.0.Success'
|
||||
instance.messages[0].severity = res_cons.SEVERITY_OK
|
||||
instance.messages[0].severity = res_cons.Severity.OK
|
||||
status = instance.get_status(self.registries)
|
||||
self.assertEqual(status.status,
|
||||
settings.UPDATE_SUCCESS)
|
||||
self.assertEqual(status.messages[0].severity, res_cons.SEVERITY_OK)
|
||||
self.assertEqual(status.messages[0].severity, res_cons.Severity.OK)
|
||||
self.assertEqual(status.messages[0].message,
|
||||
'Everything done successfully.')
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ class SoftwareInventoryTestCase(base.TestCase):
|
|||
self.assertEqual('Contoso BMC Firmware', self.soft_inv.name)
|
||||
self.assertEqual('2017-08-22T12:00:00', self.soft_inv.release_date)
|
||||
self.assertEqual(
|
||||
res_cons.STATE_ENABLED,
|
||||
res_cons.State.ENABLED,
|
||||
self.soft_inv.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.soft_inv.status.health)
|
||||
self.assertEqual(res_cons.Health.OK, self.soft_inv.status.health)
|
||||
self.assertEqual(
|
||||
'1624A9DF-5E13-47FC-874A-DF3AFF143089',
|
||||
self.soft_inv.software_id)
|
||||
|
@ -60,9 +60,9 @@ class SoftwareInventoryTestCase(base.TestCase):
|
|||
|
||||
# Test that various types are returned correctly
|
||||
self.assertEqual('BMC', attributes.get('identity'))
|
||||
self.assertEqual({'health': res_cons.HEALTH_OK,
|
||||
self.assertEqual({'health': res_cons.Health.OK,
|
||||
'health_rollup': None,
|
||||
'state': res_cons.STATE_ENABLED},
|
||||
'state': res_cons.State.ENABLED},
|
||||
attributes.get('status'))
|
||||
self.assertEqual(True, attributes.get('updateable'))
|
||||
|
||||
|
|
|
@ -45,10 +45,10 @@ class UpdateServiceTestCase(base.TestCase):
|
|||
self.assertFalse(self.upd_serv.http_push_uri_targets_busy)
|
||||
self.assertEqual('Update service', self.upd_serv.name)
|
||||
self.assertTrue(self.upd_serv.service_enabled)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.upd_serv.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.upd_serv.status.health)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.upd_serv.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.upd_serv.status.health)
|
||||
self.assertEqual(
|
||||
res_cons.HEALTH_OK,
|
||||
res_cons.Health.OK,
|
||||
self.upd_serv.status.health_rollup)
|
||||
|
||||
def test__parse_attributes_missing_actions(self):
|
||||
|
|
Loading…
Reference in New Issue