Migrate Chassis to enums

Change-Id: Ia2a2a03c9cf998d424ed317178a8aa8031dc8855
This commit is contained in:
Dmitry Tantsur 2021-11-23 16:17:49 +01:00
parent d61ed8218f
commit 69c4b38850
12 changed files with 241 additions and 301 deletions

View File

@ -17,7 +17,7 @@ import logging
from sushy import exceptions
from sushy.resources import base
from sushy.resources.chassis import mappings as cha_maps
from sushy.resources.chassis import constants as cha_cons
from sushy.resources.chassis.power import power
from sushy.resources.chassis.thermal import thermal
from sushy.resources import common
@ -35,7 +35,7 @@ class ActionsField(base.CompositeField):
class PhysicalSecurity(base.CompositeField):
intrusion_sensor = base.MappedField('IntrusionSensor',
cha_maps.CHASSIS_INTRUSION_SENSOR_MAP)
cha_cons.IntrusionSensor)
"""IntrusionSensor
This indicates the known state of the physical security sensor, such as if
it is hardware intrusion detected.
@ -44,9 +44,8 @@ class PhysicalSecurity(base.CompositeField):
intrusion_sensor_number = base.Field('IntrusionSensorNumber')
"""A numerical identifier to represent the physical security sensor"""
intrusion_sensor_re_arm = (
base.MappedField('IntrusionSensorReArm',
cha_maps.CHASSIS_INTRUSION_SENSOR_RE_ARM_MAP))
intrusion_sensor_re_arm = base.MappedField('IntrusionSensorReArm',
cha_cons.IntrusionSensorReArm)
"""This indicates how the Normal state to be restored"""
@ -58,8 +57,7 @@ class Chassis(base.ResourceBase):
such as racks, enclosures, chassis and all other containers.
"""
chassis_type = base.MappedField('ChassisType',
cha_maps.CHASSIS_TYPE_VALUE_MAP,
chassis_type = base.MappedField('ChassisType', cha_cons.ChassisType,
required=True)
"""The type of physical form factor of the chassis"""

View File

@ -10,153 +10,153 @@
# License for the specific language governing permissions and limitations
# under the License.
# Values comes from the Redfish Chassis json-schema 1.8.0:
# http://redfish.dmtf.org/schemas/v1/Chassis.v1_8_0.json#/definitions/Chassis
# Values comes from the Redfish Chassis json-schema:
# https://redfish.dmtf.org/schemas/v1/Chassis.v1_17_0.json
# Chassis Types constants
import enum
CHASSIS_TYPE_RACK = 'rack chassis type'
"""An equipment rack, typically a 19-inch wide freestanding unit"""
CHASSIS_TYPE_BLADE = 'blade chassis type'
"""Blade
class ChassisType(enum.Enum):
"""Chassis Types constants"""
An enclosed or semi-enclosed, typically vertically-oriented, system
chassis which must be plugged into a multi-system chassis to function
normally.
"""
RACK = 'Rack'
"""An equipment rack, typically a 19-inch wide freestanding unit."""
CHASSIS_TYPE_ENCLOSURE = 'enclosure chassis type'
"""A generic term for a chassis that does not fit any other description"""
BLADE = 'Blade'
"""An enclosed or semi-enclosed, typically vertically-oriented, system
chassis that must be plugged into a multi-system chassis to function
normally."""
CHASSIS_TYPE_STAND_ALONE = 'stand alone chassis type'
"""StandAlone
ENCLOSURE = 'Enclosure'
"""A generic term for a chassis that does not fit any other description."""
A single, free-standing system, commonly called a tower or desktop
chassis.
"""
STAND_ALONE = 'StandAlone'
"""A single, free-standing system, commonly called a tower or desktop
chassis."""
CHASSIS_TYPE_RACK_MOUNT = 'rack mount chassis type'
"""RackMount
RACK_MOUNT = 'RackMount'
"""A single-system chassis designed specifically for mounting in an
equipment rack."""
A single system chassis designed specifically for mounting in an
equipment rack.
"""
CARD = 'Card'
"""A loose device or circuit board intended to be installed in a system
or other enclosure."""
CHASSIS_TYPE_CARD = 'card chassis type'
"""Card
CARTRIDGE = 'Cartridge'
"""A small self-contained system intended to be plugged into a multi-
system chassis."""
A loose device or circuit board intended to be installed in a system or
other enclosure.
"""
ROW = 'Row'
"""A collection of equipment racks."""
CHASSIS_TYPE_CARTRIDGE = 'cartridge chassis type'
"""Cartridge
POD = 'Pod'
"""A collection of equipment racks in a large, likely transportable,
container."""
A small self-contained system intended to be plugged into a multi-system
chassis"""
EXPANSION = 'Expansion'
"""A chassis that expands the capabilities or capacity of another
chassis."""
CHASSIS_TYPE_ROW = 'row chassis type'
"""A collection of equipment rack"""
SIDECAR = 'Sidecar'
"""A chassis that mates mechanically with another chassis to expand its
capabilities or capacity."""
CHASSIS_TYPE_POD = 'pod chassis type'
"""Pod
ZONE = 'Zone'
"""A logical division or portion of a physical chassis that contains
multiple devices or systems that cannot be physically separated."""
A collection of equipment racks in a large, likely transportable,
container"""
SLED = 'Sled'
"""An enclosed or semi-enclosed, system chassis that must be plugged
into a multi-system chassis to function normally similar to a blade
type chassis."""
CHASSIS_TYPE_EXPANSION = 'expansion chassis type'
"""A chassis which expands the capabilities or capacity of another chassis"""
SHELF = 'Shelf'
"""An enclosed or semi-enclosed, typically horizontally-oriented, system
chassis that must be plugged into a multi-system chassis to function
normally."""
CHASSIS_TYPE_SIDECAR = 'sidecar chassis type'
"""Sidecar
DRAWER = 'Drawer'
"""An enclosed or semi-enclosed, typically horizontally-oriented, system
chassis that can be slid into a multi-system chassis."""
A chassis that mates mechanically with another chassis to expand its
capabilities or capacity.
"""
MODULE = 'Module'
"""A small, typically removable, chassis or card that contains devices
for a particular subsystem or function."""
CHASSIS_TYPE_ZONE = 'zone chassis type'
"""Zone
COMPONENT = 'Component'
"""A small chassis, card, or device that contains devices for a
particular subsystem or function."""
A logical division or portion of a physical chassis that contains multiple
devices or systems that cannot be physically separated.
"""
IP_BASED_DRIVE = 'IPBasedDrive'
"""A chassis in a drive form factor with IP-based network connections."""
CHASSIS_TYPE_SLED = 'sled chassis type'
"""Sled
RACK_GROUP = 'RackGroup'
"""A group of racks that form a single entity or share infrastructure."""
An enclosed or semi-enclosed, system chassis which must be plugged into a
multi-system chassis to function normally similar to a blade type chassis.
"""
STORAGE_ENCLOSURE = 'StorageEnclosure'
"""A chassis that encloses storage."""
CHASSIS_TYPE_SHELF = 'shelf chassis type'
"""Shelf
OTHER = 'Other'
"""A chassis that does not fit any of these definitions."""
An enclosed or semi-enclosed, typically horizontally-oriented, system chassis
which must be plugged into a multi-system chassis to function
normally.
"""
CHASSIS_TYPE_DRAWER = 'drawer chassis type'
"""Drawer
# Backward compatibility
CHASSIS_TYPE_RACK = ChassisType.RACK
CHASSIS_TYPE_BLADE = ChassisType.BLADE
CHASSIS_TYPE_ENCLOSURE = ChassisType.ENCLOSURE
CHASSIS_TYPE_STAND_ALONE = ChassisType.STAND_ALONE
CHASSIS_TYPE_RACK_MOUNT = ChassisType.RACK_MOUNT
CHASSIS_TYPE_CARD = ChassisType.CARD
CHASSIS_TYPE_CARTRIDGE = ChassisType.CARTRIDGE
CHASSIS_TYPE_ROW = ChassisType.ROW
CHASSIS_TYPE_POD = ChassisType.POD
CHASSIS_TYPE_EXPANSION = ChassisType.EXPANSION
CHASSIS_TYPE_SIDECAR = ChassisType.SIDECAR
CHASSIS_TYPE_ZONE = ChassisType.ZONE
CHASSIS_TYPE_SLED = ChassisType.SLED
CHASSIS_TYPE_SHELF = ChassisType.SHELF
CHASSIS_TYPE_DRAWER = ChassisType.DRAWER
CHASSIS_TYPE_MODULE = ChassisType.MODULE
CHASSIS_TYPE_COMPONENT = ChassisType.COMPONENT
CHASSIS_TYPE_IP_BASED_DRIVE = ChassisType.IP_BASED_DRIVE
CHASSIS_TYPE_RACK_GROUP = ChassisType.RACK_GROUP
CHASSIS_TYPE_STORAGE_ENCLOSURE = ChassisType.STORAGE_ENCLOSURE
CHASSIS_TYPE_OTHER = ChassisType.OTHER
An enclosed or semi-enclosed, typically horizontally-oriented, system
chassis which may be slid into a multi-system chassis.
"""
CHASSIS_TYPE_MODULE = 'module chassis type'
"""Module
class IntrusionSensor(enum.Enum):
"""Chassis IntrusionSensor constants"""
A small, typically removable, chassis or card which contains devices for
a particular subsystem or function.
"""
NORMAL = 'Normal'
"""No abnormal physical security condition is detected at this time."""
CHASSIS_TYPE_COMPONENT = 'component chassis type'
"""Component
HARDWARE_INTRUSION = 'HardwareIntrusion'
"""A door, lock, or other mechanism protecting the internal system
hardware from being accessed is detected to be in an insecure state."""
A small chassis, card, or device which contains devices for a particular
subsystem or function.
"""
TAMPERING_DETECTED = 'TamperingDetected'
"""Physical tampering of the monitored entity is detected."""
CHASSIS_TYPE_IP_BASED_DRIVE = 'IP based drive chassis type'
"""A chassis in a drive form factor with IP-based network connections"""
CHASSIS_TYPE_RACK_GROUP = 'rack group chassis type'
"""A group of racks which form a single entity or share infrastructure"""
# Backward compatibility
CHASSIS_INTRUSION_SENSOR_NORMAL = IntrusionSensor.NORMAL
CHASSIS_INTRUSION_SENSOR_HARDWARE_INTRUSION = \
IntrusionSensor.HARDWARE_INTRUSION
CHASSIS_INTRUSION_SENSOR_TAMPERING_DETECTED = \
IntrusionSensor.TAMPERING_DETECTED
CHASSIS_TYPE_STORAGE_ENCLOSURE = 'storage enclosure chassis type'
"""A chassis which encloses storage"""
CHASSIS_TYPE_OTHER = 'other chassis type'
"""A chassis that does not fit any of these definitions"""
class IntrusionSensorReArm(enum.Enum):
"""Chassis IntrusionSensorReArm constants"""
# Chassis IntrusionSensor constants
MANUAL = 'Manual'
"""A manual re-arm of this sensor restores it to the normal state."""
CHASSIS_INTRUSION_SENSOR_NORMAL = 'normal chassis intrusion sensor'
"""No abnormal physical security conditions are detected at this time"""
AUTOMATIC = 'Automatic'
"""Because no abnormal physical security condition is detected, this
sensor is automatically restored to the normal state."""
CHASSIS_INTRUSION_SENSOR_HARDWARE_INTRUSION = 'hardware intrusion chassis ' \
'intrusion sensor'
"""HardwareIntrusion
A door, lock, or other mechanism protecting the internal system hardware from
being accessed is detected as being in an insecure state.
"""
CHASSIS_INTRUSION_SENSOR_TAMPERING_DETECTED = 'tampering detected chassis ' \
'intrusion sensor'
"""Physical tampering of the monitored entity is detected"""
# Chassis IntrusionSensorReArm constants
CHASSIS_INTRUSION_SENSOR_RE_ARM_MANUAL = 'manual re arm chassis intrusion ' \
'sensor'
"""This sensor would be restored to the Normal state by a manual re-arm"""
CHASSIS_INTRUSION_SENSOR_RE_ARM_AUTOMATIC = 'automatic re arm chassis ' \
'intrusion sensor'
"""Automatic
This sensor would be restored to the Normal state automatically as no abnormal
physical security conditions are detected.
"""
# Backward compatibility
CHASSIS_INTRUSION_SENSOR_RE_ARM_MANUAL = IntrusionSensorReArm.MANUAL
CHASSIS_INTRUSION_SENSOR_RE_ARM_AUTOMATIC = IntrusionSensorReArm.AUTOMATIC

View File

@ -1,48 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sushy.resources.chassis import constants as cha_cons
CHASSIS_TYPE_VALUE_MAP = {
'Rack': cha_cons.CHASSIS_TYPE_RACK,
'Blade': cha_cons.CHASSIS_TYPE_BLADE,
'Enclosure': cha_cons.CHASSIS_TYPE_ENCLOSURE,
'StandAlone': cha_cons.CHASSIS_TYPE_STAND_ALONE,
'RackMount': cha_cons.CHASSIS_TYPE_RACK_MOUNT,
'Card': cha_cons.CHASSIS_TYPE_CARD,
'Cartridge': cha_cons.CHASSIS_TYPE_CARTRIDGE,
'Row': cha_cons.CHASSIS_TYPE_ROW,
'Pod': cha_cons.CHASSIS_TYPE_POD,
'Expansion': cha_cons.CHASSIS_TYPE_EXPANSION,
'Sidecar': cha_cons.CHASSIS_TYPE_SIDECAR,
'Zone': cha_cons.CHASSIS_TYPE_ZONE,
'Sled': cha_cons.CHASSIS_TYPE_SLED,
'Shelf': cha_cons.CHASSIS_TYPE_SHELF,
'Drawer': cha_cons.CHASSIS_TYPE_DRAWER,
'Module': cha_cons.CHASSIS_TYPE_MODULE,
'Component': cha_cons.CHASSIS_TYPE_COMPONENT,
'IPBasedDrive': cha_cons.CHASSIS_TYPE_IP_BASED_DRIVE,
'RackGroup': cha_cons.CHASSIS_TYPE_RACK_GROUP,
'StorageEnclosure': cha_cons.CHASSIS_TYPE_STORAGE_ENCLOSURE,
'Other': cha_cons.CHASSIS_TYPE_OTHER,
}
CHASSIS_INTRUSION_SENSOR_MAP = {
'Normal': cha_cons.CHASSIS_INTRUSION_SENSOR_NORMAL,
'HardwareIntrusion': cha_cons.CHASSIS_INTRUSION_SENSOR_HARDWARE_INTRUSION,
'TamperingDetected': cha_cons.CHASSIS_INTRUSION_SENSOR_TAMPERING_DETECTED,
}
CHASSIS_INTRUSION_SENSOR_RE_ARM_MAP = {
'Manual': cha_cons.CHASSIS_INTRUSION_SENSOR_RE_ARM_MANUAL,
'Automatic': cha_cons.CHASSIS_INTRUSION_SENSOR_RE_ARM_AUTOMATIC,
}

View File

@ -10,60 +10,94 @@
# License for the specific language governing permissions and limitations
# under the License.
# Values comes from the Redfish Chassis json-schema:
# https://redfish.dmtf.org/schemas/v1/Power.v1_7_1.json
# Power Supply Types
POWER_SUPPLY_TYPE_UNKNOWN = 'unknown'
"""The power supply type cannot be determined."""
import enum
POWER_SUPPLY_TYPE_AC = 'ac'
"""Alternating Current (AC) power supply."""
POWER_SUPPLY_TYPE_DC = 'dc'
"""Direct Current (DC) power supply."""
class PowerSupplyType(enum.Enum):
UNKNOWN = 'Unknown'
"""The power supply type cannot be determined."""
POWER_SUPPLY_TYPE_ACDC = 'acdc'
"""Power Supply supports both DC or AC."""
AC = 'AC'
"""Alternating Current (AC) power supply."""
# Line Input Voltage Types
LINE_INPUT_VOLTAGE_TYPE_UNKNOWN = 'unknown'
"""The power supply line input voltage tpye cannot be determined."""
DC = 'DC'
"""Direct Current (DC) power supply."""
LINE_INPUT_VOLTAGE_TYPE_ACLOW = 'aclowline'
"""100-127V AC input."""
AC_OR_DC = 'ACorDC'
"""The power supply supports both DC or AC."""
LINE_INPUT_VOLTAGE_TYPE_ACMID = 'acmidline'
"""200-240V AC input."""
LINE_INPUT_VOLTAGE_TYPE_ACHIGH = 'achighline'
"""277V AC input."""
# Backward compatibility
POWER_SUPPLY_TYPE_UNKNOWN = PowerSupplyType.UNKNOWN
POWER_SUPPLY_TYPE_AC = PowerSupplyType.AC
POWER_SUPPLY_TYPE_DC = PowerSupplyType.DC
POWER_SUPPLY_TYPE_ACDC = PowerSupplyType.AC_OR_DC
LINE_INPUT_VOLTAGE_TYPE_DCNEG48 = 'dcneg48v'
"""-48V DC input."""
LINE_INPUT_VOLTAGE_TYPE_DC380 = 'dc380v'
"""High Voltage DC input (380V)."""
class LineInputVoltageType(enum.Enum):
UNKNOWN = 'Unknown'
"""The power supply line input voltage type cannot be determined."""
LINE_INPUT_VOLTAGE_TYPE_AC120 = 'ac120v'
"""AC 120V nominal input."""
AC_LOW_LINE = 'ACLowLine'
"""100-127V AC input."""
LINE_INPUT_VOLTAGE_TYPE_AC240 = 'ac240v'
"""AC 240V nominal input."""
AC_MID_LINE = 'ACMidLine'
"""200-240V AC input."""
LINE_INPUT_VOLTAGE_TYPE_AC277 = 'ac277v'
"""AC 277V nominal input."""
AC_HIGH_LINE = 'ACHighLine'
"""277V AC input."""
LINE_INPUT_VOLTAGE_TYPE_ACDCWIDE = 'acdcwiderange'
"""Wide range AC or DC input."""
DC_NEG48V = 'DCNeg48V'
"""-48V DC input."""
LINE_INPUT_VOLTAGE_TYPE_ACWIDE = 'acwiderange'
"""Wide range AC input."""
DC_380V = 'DC380V'
"""High Voltage DC input (380V)."""
LINE_INPUT_VOLTAGE_TYPE_DC240 = 'dc240v'
"""DC 240V nominal input."""
AC_120V = 'AC120V'
"""AC 120V nominal input."""
# Input Types
INPUT_TYPE_AC = 'ac'
"""Alternating Current (AC) input range."""
AC_240V = 'AC240V'
"""AC 240V nominal input."""
INPUT_TYPE_DC = 'dc'
"""Direct Current (DC) input range."""
AC_277V = 'AC277V'
"""AC 277V nominal input."""
AC_AND_DC_WIDE_RANGE = 'ACandDCWideRange'
"""Wide range AC or DC input."""
AC_WIDE_RANGE = 'ACWideRange'
"""Wide range AC input."""
DC_240V = 'DC240V'
"""DC 240V nominal input."""
# Backward compatibility
LINE_INPUT_VOLTAGE_TYPE_UNKNOWN = LineInputVoltageType.UNKNOWN
LINE_INPUT_VOLTAGE_TYPE_ACLOW = LineInputVoltageType.AC_LOW_LINE
LINE_INPUT_VOLTAGE_TYPE_ACMID = LineInputVoltageType.AC_MID_LINE
LINE_INPUT_VOLTAGE_TYPE_ACHIGH = LineInputVoltageType.AC_HIGH_LINE
LINE_INPUT_VOLTAGE_TYPE_DCNEG48 = LineInputVoltageType.DC_NEG48V
LINE_INPUT_VOLTAGE_TYPE_DC380V = LineInputVoltageType.DC_380V
LINE_INPUT_VOLTAGE_TYPE_AC120V = LineInputVoltageType.AC_120V
LINE_INPUT_VOLTAGE_TYPE_AC240V = LineInputVoltageType.AC_240V
LINE_INPUT_VOLTAGE_TYPE_AC277V = LineInputVoltageType.AC_277V
LINE_INPUT_VOLTAGE_TYPE_ACDCWIDE = LineInputVoltageType.AC_AND_DC_WIDE_RANGE
LINE_INPUT_VOLTAGE_TYPE_ACWIDE = LineInputVoltageType.AC_WIDE_RANGE
LINE_INPUT_VOLTAGE_TYPE_DC240V = LineInputVoltageType.DC_240V
class PowerInputType(enum.Enum):
AC = 'AC'
"""Alternating Current (AC) input range."""
DC = 'DC'
"""Direct Current (DC) input range."""
# Backward compatibility
INPUT_TYPE_AC = PowerInputType.AC
INPUT_TYPE_DC = PowerInputType.DC

View File

@ -1,40 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sushy.resources.chassis.power import constants as pow_cons
POWER_SUPPLY_TYPE_MAP = {
'Unknown': pow_cons.POWER_SUPPLY_TYPE_UNKNOWN,
'AC': pow_cons.POWER_SUPPLY_TYPE_AC,
'DC': pow_cons.POWER_SUPPLY_TYPE_DC,
'ACorDC': pow_cons.POWER_SUPPLY_TYPE_ACDC,
}
POWER_SUPPLY_INPUT_TYPE_MAP = {
'AC': pow_cons.INPUT_TYPE_AC,
'DC': pow_cons.INPUT_TYPE_DC,
}
LINE_INPUT_VOLTAGE_TYPE_MAP = {
'Unknown': pow_cons.LINE_INPUT_VOLTAGE_TYPE_UNKNOWN,
'ACLowLine': pow_cons.LINE_INPUT_VOLTAGE_TYPE_ACLOW,
'ACMidLine': pow_cons.LINE_INPUT_VOLTAGE_TYPE_ACMID,
'ACHighLine': pow_cons.LINE_INPUT_VOLTAGE_TYPE_ACHIGH,
'DCNeg48V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_DCNEG48,
'DC380V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_DC380,
'AC120V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_AC120,
'AC240V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_AC240,
'AC277V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_AC277,
'ACandDCWideRange': pow_cons.LINE_INPUT_VOLTAGE_TYPE_ACDCWIDE,
'ACWideRange': pow_cons.LINE_INPUT_VOLTAGE_TYPE_ACWIDE,
'DC240V': pow_cons.LINE_INPUT_VOLTAGE_TYPE_DC240,
}

View File

@ -14,7 +14,7 @@
# http://redfish.dmtf.org/schemas/v1/Power.v1_3_0.json
from sushy.resources import base
from sushy.resources.chassis.power import mappings as pow_maps
from sushy.resources.chassis.power import constants as pow_cons
from sushy.resources import common
from sushy.resources import constants as res_cons
from sushy import utils
@ -23,8 +23,7 @@ from sushy import utils
class InputRangeListField(base.ListField):
"""This type describes an input range for a power supply"""
input_type = base.MappedField('InputType',
pow_maps.POWER_SUPPLY_INPUT_TYPE_MAP)
input_type = base.MappedField('InputType', pow_cons.PowerInputType)
"""The Input type (AC or DC)"""
maximum_frequency_hz = base.Field('MaximumFrequencyHz',
@ -73,9 +72,8 @@ class PowerSupplyListField(base.ListField):
adapter=utils.int_or_none)
"""The line input voltage at which the Power Supply is operating"""
line_input_voltage_type = base.MappedField(
'LineInputVoltageType',
pow_maps.LINE_INPUT_VOLTAGE_TYPE_MAP)
line_input_voltage_type = base.MappedField('LineInputVoltageType',
pow_cons.LineInputVoltageType)
"""The line voltage type supported as an input to this Power Supply"""
manufacturer = base.Field('Manufacturer')
@ -95,7 +93,7 @@ class PowerSupplyListField(base.ListField):
"""The maximum capacity of this Power Supply"""
power_supply_type = base.MappedField('PowerSupplyType',
pow_maps.POWER_SUPPLY_TYPE_MAP)
pow_cons.PowerSupplyType)
"""The Power Supply type (AC or DC)"""
serial_number = base.Field('SerialNumber')

View File

@ -10,9 +10,22 @@
# License for the specific language governing permissions and limitations
# under the License.
FAN_READING_UNIT_PERCENTAGE = 'Percentage'
"""Indicates that the fan reading and thresholds are measured in percentage"""
# Values comes from the Redfish Chassis json-schema:
# https://redfish.dmtf.org/schemas/v1/Thermal.v1_7_1.json
FAN_READING_UNIT_RPM = 'RPM'
"""Indicates that the fan reading and thresholds
are measured in rotations per minute."""
import enum
class FanReadingUnit(enum.Enum):
RPM = 'RPM'
"""The fan reading and thresholds are measured in revolutions per
minute."""
PERCENT = 'Percent'
"""The fan reading and thresholds are measured as a percentage."""
# Backward compatibility
FAN_READING_UNIT_PERCENTAGE = FanReadingUnit.PERCENT
FAN_READING_UNIT_RPM = FanReadingUnit.RPM

View File

@ -1,18 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sushy.resources.chassis.thermal import constants as the_cons
FAN_READING_UNITS_MAP = {
'Percentage': the_cons.FAN_READING_UNIT_PERCENTAGE,
'RPM': the_cons.FAN_READING_UNIT_RPM,
}

View File

@ -14,7 +14,7 @@
# http://redfish.dmtf.org/schemas/v1/Thermal.v1_3_0.json
from sushy.resources import base
from sushy.resources.chassis.thermal import mappings as the_maps
from sushy.resources.chassis.thermal import constants as the_cons
from sushy.resources import common
from sushy.resources import constants as res_cons
from sushy import utils
@ -86,8 +86,7 @@ class FansListField(Sensor):
reading = base.Field('Reading', adapter=utils.int_or_none)
"""Current Fan Speed"""
reading_units = base.MappedField('ReadingUnits',
the_maps.FAN_READING_UNITS_MAP)
reading_units = base.MappedField('ReadingUnits', the_cons.FanReadingUnit)
"""Units in which the reading and thresholds are measured"""
serial_number = base.Field('SerialNumber')

View File

@ -47,8 +47,7 @@ class ChassisTestCase(base.TestCase):
self.assertEqual('Blade', self.chassis.name)
self.assertEqual('Test description', self.chassis.description)
self.assertEqual('45Z-2381', self.chassis.asset_tag)
self.assertEqual(sushy.CHASSIS_TYPE_BLADE,
self.chassis.chassis_type)
self.assertEqual(sushy.ChassisType.BLADE, self.chassis.chassis_type)
self.assertEqual('Contoso', self.chassis.manufacturer)
self.assertEqual('SX1000', self.chassis.model)
self.assertEqual('529QB9450R6', self.chassis.serial_number)
@ -66,12 +65,12 @@ class ChassisTestCase(base.TestCase):
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.CHASSIS_INTRUSION_SENSOR_NORMAL,
self.assertEqual(sushy.IntrusionSensor.NORMAL,
self.chassis.physical_security.intrusion_sensor)
self.assertEqual(123,
self.chassis.physical_security.intrusion_sensor_number
)
self.assertEqual(sushy.CHASSIS_INTRUSION_SENSOR_RE_ARM_MANUAL,
self.assertEqual(sushy.IntrusionSensorReArm.MANUAL,
self.chassis.physical_security.intrusion_sensor_re_arm
)
@ -83,12 +82,10 @@ class ChassisTestCase(base.TestCase):
self.assertEqual(sushy.IndicatorLED.OFF,
attributes.get('indicator_led'))
self.assertEqual(sushy.POWER_STATE_ON, attributes.get('power_state'))
self.assertEqual({'intrusion_sensor':
sushy.CHASSIS_INTRUSION_SENSOR_NORMAL,
'intrusion_sensor_number':
123,
self.assertEqual({'intrusion_sensor': sushy.IntrusionSensor.NORMAL,
'intrusion_sensor_number': 123,
'intrusion_sensor_re_arm':
'manual re arm chassis intrusion sensor'},
sushy.IntrusionSensorReArm.MANUAL},
attributes.get('physical_security'))
def test_get_allowed_reset_chasis_values(self):

View File

@ -15,6 +15,7 @@
import json
from unittest import mock
from sushy.resources.chassis.power import constants as pow_cons
from sushy.resources.chassis.power import power
from sushy.resources import constants as res_cons
from sushy.tests.unit import base
@ -46,14 +47,15 @@ class PowerTestCase(base.TestCase):
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.assertEqual(pow_cons.PowerSupplyType.AC,
self.power.power_supplies[0].power_supply_type)
self.assertEqual(pow_cons.LineInputVoltageType.AC_240V,
self.power.power_supplies[0].line_input_voltage_type)
self.assertEqual(220, self.power.power_supplies[0].line_input_voltage)
self.assertEqual(1450,
self.power.power_supplies[0].power_capacity_watts)
self.assertEqual(
'ac',
pow_cons.PowerInputType.AC,
self.power.power_supplies[0].input_ranges[0].input_type
)
self.assertEqual(
@ -96,14 +98,15 @@ class PowerTestCase(base.TestCase):
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.assertEqual(pow_cons.PowerSupplyType.AC,
self.power.power_supplies[1].power_supply_type)
self.assertEqual(pow_cons.LineInputVoltageType.AC_240V,
self.power.power_supplies[1].line_input_voltage_type)
self.assertEqual(222, self.power.power_supplies[1].line_input_voltage)
self.assertEqual(1450,
self.power.power_supplies[1].power_capacity_watts)
self.assertEqual(
'ac',
pow_cons.PowerInputType.AC,
self.power.power_supplies[1].input_ranges[0].input_type
)
self.assertEqual(
@ -149,7 +152,7 @@ class PowerTestCase(base.TestCase):
'identity': '0',
'indicator_led': None,
'input_ranges':
[{'input_type': 'ac',
[{'input_type': pow_cons.PowerInputType.AC,
'maximum_frequency_hz': 63,
'maximum_voltage': 250,
'minimum_frequency_hz': 47,
@ -157,13 +160,14 @@ class PowerTestCase(base.TestCase):
'output_wattage': 1450}],
'last_power_output_watts': 650,
'line_input_voltage': 220,
'line_input_voltage_type': 'ac240v',
'line_input_voltage_type':
pow_cons.LineInputVoltageType.AC_240V,
'manufacturer': 'Cyberdyne',
'model': '325457-A06',
'name': 'Power Supply 0',
'part_number': '425-591-654',
'power_capacity_watts': 1450,
'power_supply_type': 'ac',
'power_supply_type': pow_cons.PowerSupplyType.AC,
'serial_number': '1S0000523',
'spare_part_number': '425-591-654',
'status': {'health': res_cons.Health.OK,
@ -173,7 +177,7 @@ class PowerTestCase(base.TestCase):
'identity': '1',
'indicator_led': None,
'input_ranges':
[{'input_type': 'ac',
[{'input_type': pow_cons.PowerInputType.AC,
'maximum_frequency_hz': 63,
'maximum_voltage': 250,
'minimum_frequency_hz': 47,
@ -181,13 +185,14 @@ class PowerTestCase(base.TestCase):
'output_wattage': 1450}],
'last_power_output_watts': 635,
'line_input_voltage': 222,
'line_input_voltage_type': 'ac240v',
'line_input_voltage_type':
pow_cons.LineInputVoltageType.AC_240V,
'manufacturer': 'Cyberdyne',
'model': '325457-A06',
'name': 'Power Supply 1',
'part_number': '425-591-654',
'power_capacity_watts': 1450,
'power_supply_type': 'ac',
'power_supply_type': pow_cons.PowerSupplyType.AC,
'serial_number': '1S0000524',
'spare_part_number': '425-591-654',
'status': {'health': res_cons.Health.OK,

View File

@ -15,6 +15,7 @@
import json
from unittest import mock
from sushy.resources.chassis.thermal import constants as the_cons
from sushy.resources.chassis.thermal import thermal
from sushy.resources import constants as res_cons
from sushy.tests.unit import base
@ -48,7 +49,8 @@ class ThermalTestCase(base.TestCase):
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(the_cons.FanReadingUnit.RPM,
self.thermal.fans[0].reading_units)
self.assertEqual(2000, self.thermal.fans[0].lower_threshold_fatal)
self.assertEqual(0, self.thermal.fans[0].min_reading_range)
self.assertEqual(10000, self.thermal.fans[0].max_reading_range)
@ -95,7 +97,7 @@ class ThermalTestCase(base.TestCase):
'part_number': None,
'physical_context': 'CPU',
'reading': 6000,
'reading_units': 'RPM',
'reading_units': the_cons.FanReadingUnit.RPM,
'serial_number': None,
'status':
{'health': res_cons.Health.OK,