Add more attributes in RSD 2.1 chassis resource

Change-Id: I6df96c4800d9dcd5249181c15c87c211da72a6a2
This commit is contained in:
Lin Yang 2018-12-14 14:28:40 -08:00
parent 2568b89225
commit d9b65a4433
4 changed files with 160 additions and 57 deletions

View File

@ -14,6 +14,9 @@
# under the License. # under the License.
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib import utils as rsd_lib_utils
class StatusField(base.CompositeField): class StatusField(base.CompositeField):
@ -22,6 +25,60 @@ class StatusField(base.CompositeField):
health_rollup = base.Field('HealthRollup') health_rollup = base.Field('HealthRollup')
class LinksField(base.CompositeField):
contains = base.Field('Contains', adapter=utils.get_members_identities)
"""Any other chassis that this chassis has in it"""
contained_by = base.Field('ContainedBy',
adapter=rsd_lib_utils.get_resource_identity)
"""The resource that represents the chassis that contains this chassis
and shall be of type Chassis
"""
computer_systems = base.Field('ComputerSystems',
adapter=utils.get_members_identities)
"""The computer systems contained in this chassis"""
managed_by = base.Field('ManagedBy', adapter=utils.get_members_identities)
"""The managers contained in this chassis"""
managers_in_chassis = base.Field('ManagersInChassis',
adapter=utils.get_members_identities)
"""The managers located in this chassis"""
switches = base.Field(['Oem', 'Intel_RackScale', 'Switches'],
adapter=utils.get_members_identities)
"""The Ethernet switches contained in this chassis"""
class LocationField(base.CompositeField):
identity = base.Field('Id')
"""The location ID of the chassis"""
parent_id = base.Field('ParentId')
"""The location ID of parent chassis"""
class OemField(base.CompositeField):
location = LocationField('Location')
"""Property that shows this chassis ID and its parent"""
rmm_present = base.Field('RMMPresent', adapter=bool)
"""RMM presence in a rack"""
rack_supports_disaggregated_power_cooling = base.Field(
'RackSupportsDisaggregatedPowerCooling', adapter=bool)
"""Indicates if Rack support is disaggregated (shared) power and cooling
capabilities
"""
uuid = base.Field('UUID')
"""Chassis unique ID"""
geo_tag = base.Field('GeoTag')
"""Provides info about the geographical location of this chassis"""
class Chassis(base.ResourceBase): class Chassis(base.ResourceBase):
identity = base.Field('Id', required=True) identity = base.Field('Id', required=True)
"""The chassis identity string""" """The chassis identity string"""
@ -38,6 +95,12 @@ class Chassis(base.ResourceBase):
name = base.Field('Name') name = base.Field('Name')
"""The chassis name""" """The chassis name"""
model = base.Field('Model')
"""The chassis Model"""
indicator_led = base.Field('IndicatorLED')
"""The state of the indicator LED, used to identify the chassis"""
part_number = base.Field('PartNumber') part_number = base.Field('PartNumber')
"""The chassis part number""" """The chassis part number"""
@ -53,8 +116,11 @@ class Chassis(base.ResourceBase):
chassis_type = base.Field('ChassisType') chassis_type = base.Field('ChassisType')
"""The chassis type""" """The chassis type"""
oem = base.Field('Oem') oem = OemField(['Oem', 'Intel_RackScale'])
"""The chassis oem options values (dict)""" """The chassis oem object"""
links = LinksField('Links')
"""The link section of chassis"""
def __init__(self, connector, identity, redfish_version=None): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a Chassis """A class representing a Chassis

View File

@ -1,13 +1,55 @@
{ {
"@odata.context": "/redfish/v1/$metadata#Chassis/Members/$entity", "@odata.context": "/redfish/v1/$metadata#Chassis/Members/$entity",
"@odata.id": "/redfish/v1/Chassis/Chassis1", "@odata.id": "/redfish/v1/Chassis/1",
"@odata.type": "#Chassis.1.0.0.Chassis", "@odata.type": "#Chassis.v1_3_0.Chassis",
"Id": "1",
"ChassisType": "RackMount",
"Name": "name-as-string",
"Description": "description-as-string",
"Manufacturer": "Intel Corporation",
"Model": "model-as-string",
"SKU": "sku-as-string",
"SerialNumber": "serial-number-as-string",
"PartNumber": "part-number-as-string",
"AssetTag": "FlexChassis1", "AssetTag": "FlexChassis1",
"ChassisType": "Drawer", "IndicatorLED": "Unknown",
"Description": "this is a chassis", "Status": {
"Id": "Chassis1", "State": "Enabled",
"IndicatorLED": "On", "Health": "OK"
},
"Oem": {
"Intel_RackScale": {
"@odata.type": "#Intel.Oem.RackChassis",
"Location": {
"Id": "Rack1",
"ParentId": "Pod1"
},
"RMMPresent": true,
"RackSupportsDisaggregatedPowerCooling": true,
"UUID": "Unique ID",
"GeoTag": "54.348103, 18.645172"
}
},
"ThermalZones": {
"@odata.id": "/redfish/v1/Chassis/Rack1/ThermalZones"
},
"PowerZones": {
"@odata.id": "/redfish/v1/Chassis/Rack1/PowerZones"
},
"Thermal": {
"@odata.id": "/redfish/v1/Chassis/Rack1/Thermal"
},
"Power": {
"@odata.id": "/redfish/v1/Chassis/Rack1/Power"
},
"Links": { "Links": {
"@odata.type": "#Chassis.v1_2_0.Links",
"Contains": [
{
"@odata.id": "/redfish/v1/Chassis/Drawer1"
}
],
"ContainedBy": null,
"ComputerSystems": [ "ComputerSystems": [
{ {
"@odata.id": "/redfish/v1/Systems/system1" "@odata.id": "/redfish/v1/Systems/system1"
@ -22,52 +64,21 @@
"@odata.id": "/redfish/v1/Systems/system4" "@odata.id": "/redfish/v1/Systems/system4"
} }
], ],
"ContainedBy": {
"@odata.id": "/redfish/v1/Chassis/Rack1"
},
"Contains": [
{
"@odata.id": "/redfish/v1/Chassis/Chassis1"
}
],
"ManagedBy": [ "ManagedBy": [
{ {
"@odata.id": "/redfish/v1/Managers/manager1" "@odata.id": "/redfish/v1/Managers/RMM"
} }
], ],
"ManagersIn": [ "ManagersInChassis": [
{ {
"@odata.id": "/redfish/v1/Managers/manager1" "@odata.id": "/redfish/v1/Managers/RMM"
} }
], ],
"Oem": { }, "Oem": {
"Switches": [ "Intel_RackScale": {
{ "@odata.type": "#Intel.Oem.ChassisLinks",
"@odata.id": "/redfish/v1/EthernetSwitches/switch1" "Switches": []
} }
]
},
"Manufacturer": "Intel Corporaion",
"Model": "Lenovo FLEX 8731",
"Name": "FLEX-1",
"Oem": {
"Intel:RackScale": {
"@odata.type": "#Intel.Oem.Chassis",
"Location": {
"Rack": "Rack1",
"UHeight": "10 U",
"ULocation": "25 U",
"UWidth": "1 U"
},
"UUID": "e1c2d764-5c72-36d6-9945-a78255edab51"
} }
},
"PartNumber": "5c72-36d6",
"SKU": "e1c2d764-5c72",
"SerialNumber": "a78255edab51",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
} }
} }

View File

@ -37,19 +37,45 @@ class TestChassis(base.TestCase):
self.chassis_inst._parse_attributes() self.chassis_inst._parse_attributes()
self.assertEqual('1.0.2', self.chassis_inst.redfish_version) self.assertEqual('1.0.2', self.chassis_inst.redfish_version)
self.assertEqual('FlexChassis1', self.chassis_inst.asset_tag) self.assertEqual('FlexChassis1', self.chassis_inst.asset_tag)
self.assertEqual('Drawer', self.chassis_inst.chassis_type) self.assertEqual('RackMount', self.chassis_inst.chassis_type)
self.assertEqual('this is a chassis', self.chassis_inst.description) self.assertEqual(
self.assertEqual('Chassis1', self.chassis_inst.identity) 'description-as-string', self.chassis_inst.description)
self.assertEqual('Intel Corporaion', self.chassis_inst.manufacturer) self.assertEqual('1', self.chassis_inst.identity)
self.assertEqual('FLEX-1', self.chassis_inst.name) self.assertEqual('Intel Corporation', self.chassis_inst.manufacturer)
self.assertEqual('5c72-36d6', self.chassis_inst.part_number) self.assertEqual('name-as-string', self.chassis_inst.name)
self.assertEqual('a78255edab51', self.chassis_inst.serial_number) self.assertEqual(
self.assertEqual('e1c2d764-5c72', self.chassis_inst.sku) 'part-number-as-string', self.chassis_inst.part_number)
self.assertEqual('e1c2d764-5c72-36d6-9945-a78255edab51', self.assertEqual(
self.chassis_inst.oem['Intel:RackScale']['UUID']) 'serial-number-as-string', self.chassis_inst.serial_number)
self.assertEqual('sku-as-string', self.chassis_inst.sku)
self.assertEqual('model-as-string', self.chassis_inst.model)
self.assertEqual('Unknown', self.chassis_inst.indicator_led)
self.assertEqual('Enabled', self.chassis_inst.status.state) self.assertEqual('Enabled', self.chassis_inst.status.state)
self.assertEqual('OK', self.chassis_inst.status.health) self.assertEqual('OK', self.chassis_inst.status.health)
self.assertEqual('OK', self.chassis_inst.status.health_rollup) self.assertEqual(None, self.chassis_inst.status.health_rollup)
# chassis links section
self.assertEqual(
('/redfish/v1/Chassis/Drawer1',), self.chassis_inst.links.contains)
self.assertEqual(None, self.chassis_inst.links.contained_by)
self.assertEqual(
('/redfish/v1/Systems/system1', '/redfish/v1/Systems/system2',
'/redfish/v1/Systems/system3', '/redfish/v1/Systems/system4'),
self.chassis_inst.links.computer_systems)
self.assertEqual(
('/redfish/v1/Managers/RMM',), self.chassis_inst.links.managed_by)
self.assertEqual(
('/redfish/v1/Managers/RMM',),
self.chassis_inst.links.managers_in_chassis)
self.assertEqual((), self.chassis_inst.links.switches)
# chassis oem section
self.assertEqual('Rack1', self.chassis_inst.oem.location.identity)
self.assertEqual('Pod1', self.chassis_inst.oem.location.parent_id)
self.assertEqual(True, self.chassis_inst.oem.rmm_present)
self.assertEqual(
True,
self.chassis_inst.oem.rack_supports_disaggregated_power_cooling)
self.assertEqual('Unique ID', self.chassis_inst.oem.uuid)
self.assertEqual('54.348103, 18.645172', self.chassis_inst.oem.geo_tag)
class TestChassisCollection(base.TestCase): class TestChassisCollection(base.TestCase):