Add missing attribute in Chassis in RSD 2.3
Change-Id: Icc76a4b629a3a9d522fffb7aea412804729be2c6
This commit is contained in:
parent
deee42caba
commit
ff39abe91b
@ -17,6 +17,7 @@ from sushy.resources import base
|
||||
|
||||
from rsd_lib import exceptions as rsd_lib_exceptions
|
||||
from rsd_lib.resources import v2_2
|
||||
from rsd_lib.resources.v2_3.chassis import chassis
|
||||
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch
|
||||
from rsd_lib.resources.v2_3.fabric import fabric
|
||||
from rsd_lib.resources.v2_3.manager import manager
|
||||
@ -35,6 +36,29 @@ class RSDLibV2_3(v2_2.RSDLibV2_2):
|
||||
_storage_service_path = base.Field(['StorageServices', '@odata.id'])
|
||||
"""StorageServiceCollection path"""
|
||||
|
||||
def get_chassis_collection(self):
|
||||
"""Get the ChassisCollection object
|
||||
|
||||
:raises: MissingAttributeError, if the collection attribute is
|
||||
not found
|
||||
:returns: a ChassisCollection object
|
||||
"""
|
||||
return chassis.ChassisCollection(
|
||||
self._conn,
|
||||
self._chassis_path,
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
def get_chassis(self, identity):
|
||||
"""Given the identity return a Chassis object
|
||||
|
||||
:param identity: The identity of the Chassis resource
|
||||
:returns: The Chassis object
|
||||
"""
|
||||
return chassis.Chassis(
|
||||
self._conn, identity, redfish_version=self.redfish_version
|
||||
)
|
||||
|
||||
def get_system(self, identity):
|
||||
"""Given the identity return a System object
|
||||
|
||||
|
0
rsd_lib/resources/v2_3/chassis/__init__.py
Normal file
0
rsd_lib/resources/v2_3/chassis/__init__.py
Normal file
172
rsd_lib/resources/v2_3/chassis/chassis.py
Normal file
172
rsd_lib/resources/v2_3/chassis/chassis.py
Normal file
@ -0,0 +1,172 @@
|
||||
# Copyright 2019 Intel, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
from rsd_lib.resources.v2_1.chassis import chassis
|
||||
from rsd_lib.resources.v2_1.chassis import log_service
|
||||
from rsd_lib.resources.v2_2.chassis import power
|
||||
from rsd_lib.resources.v2_2.chassis import thermal
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
class LinksField(chassis.LinksField):
|
||||
|
||||
pcie_devices = base.Field(
|
||||
"PCIeDevices", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the PCIe Devices located in this Chassis."""
|
||||
|
||||
|
||||
class Chassis(rsd_lib_base.ResourceBase):
|
||||
"""Chassis resource class
|
||||
|
||||
A Chassis represents the physical components for any system. This
|
||||
resource represents the sheet-metal confined spaces and logical zones
|
||||
like racks, enclosures, chassis and all other containers. Subsystems
|
||||
(like sensors), which operate outside of a system's data plane (meaning
|
||||
the resources are not accessible to software running on the system) are
|
||||
linked either directly or indirectly through this resource.
|
||||
"""
|
||||
|
||||
chassis_type = base.Field("ChassisType")
|
||||
"""This property indicates the type of physical form factor of this
|
||||
resource.
|
||||
"""
|
||||
|
||||
manufacturer = base.Field("Manufacturer")
|
||||
"""This is the manufacturer of this chassis."""
|
||||
|
||||
model = base.Field("Model")
|
||||
"""This is the model number for the chassis."""
|
||||
|
||||
sku = base.Field("SKU")
|
||||
"""This is the SKU for this chassis."""
|
||||
|
||||
serial_number = base.Field("SerialNumber")
|
||||
"""The serial number for this chassis."""
|
||||
|
||||
part_number = base.Field("PartNumber")
|
||||
"""The part number for this chassis."""
|
||||
|
||||
asset_tag = base.Field("AssetTag")
|
||||
"""The user assigned asset tag for this chassis."""
|
||||
|
||||
indicator_led = base.Field("IndicatorLED")
|
||||
"""The state of the indicator LED, used to identify the chassis."""
|
||||
|
||||
links = LinksField("Links")
|
||||
"""Contains references to other resources that are related to this
|
||||
resource.
|
||||
"""
|
||||
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
power_state = base.Field("PowerState")
|
||||
"""This is the current power state of the chassis."""
|
||||
|
||||
physical_security = chassis.PhysicalSecurityField("PhysicalSecurity")
|
||||
"""The state of the physical security sensor."""
|
||||
|
||||
location = rsd_lib_base.LocationField("Location")
|
||||
"""Location of a resource"""
|
||||
|
||||
height_mm = base.Field("HeightMm", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The height of the chassis."""
|
||||
|
||||
width_mm = base.Field("WidthMm", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The width of the chassis."""
|
||||
|
||||
depth_mm = base.Field("DepthMm", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The depth of the chassis."""
|
||||
|
||||
weight_kg = base.Field("WeightKg", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The weight of the chassis."""
|
||||
|
||||
oem = chassis.OemField("Oem")
|
||||
"""Oem specific properties."""
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def log_services(self):
|
||||
"""Property to provide reference to `LogServiceCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return log_service.LogServiceCollection(
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "LogServices"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def thermal(self):
|
||||
"""Property to provide reference to `Thermal` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return thermal.Thermal(
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "Thermal"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def power(self):
|
||||
"""Property to provide reference to `Power` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return power.Power(
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "Power"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
def update(self, asset_tag=None, location_id=None):
|
||||
"""Update AssetTag and Location->Id properties
|
||||
|
||||
:param asset_tag: The user assigned asset tag for this chassis
|
||||
:param location_id: The user assigned location id for this chassis.
|
||||
It can be changed only for a Rack Chassis
|
||||
"""
|
||||
|
||||
data = {}
|
||||
|
||||
if asset_tag is not None:
|
||||
data["AssetTag"] = asset_tag
|
||||
|
||||
if location_id is not None:
|
||||
data["Oem"] = {
|
||||
"Intel_RackScale": {"Location": {"Id": location_id}}
|
||||
}
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
|
||||
|
||||
class ChassisCollection(rsd_lib_base.ResourceCollectionBase):
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return Chassis
|
@ -23,10 +23,10 @@ from rsd_lib.resources.v2_1.event_service import event_service \
|
||||
from rsd_lib.resources.v2_1.registries import message_registry_file \
|
||||
as v2_1_registries
|
||||
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
||||
from rsd_lib.resources.v2_2.chassis import chassis as v2_2_chassis
|
||||
from rsd_lib.resources.v2_2.update_service import update_service \
|
||||
as v2_2_update_service
|
||||
from rsd_lib.resources import v2_3
|
||||
from rsd_lib.resources.v2_3.chassis import chassis as v2_3_chassis
|
||||
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
||||
as v2_3_ethernet_switch
|
||||
from rsd_lib.resources.v2_3.fabric import fabric as v2_3_fabric
|
||||
@ -112,14 +112,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
||||
self.rsd._conn, 'fake-fabric-id',
|
||||
redfish_version=self.rsd.redfish_version)
|
||||
|
||||
@mock.patch.object(v2_2_chassis, 'ChassisCollection', autospec=True)
|
||||
@mock.patch.object(v2_3_chassis, 'ChassisCollection', autospec=True)
|
||||
def test_get_chassis_collection(self, mock_chassis_collection):
|
||||
self.rsd.get_chassis_collection()
|
||||
mock_chassis_collection.assert_called_once_with(
|
||||
self.rsd._conn, '/redfish/v1/Chassis',
|
||||
redfish_version=self.rsd.redfish_version)
|
||||
|
||||
@mock.patch.object(v2_2_chassis, 'Chassis', autospec=True)
|
||||
@mock.patch.object(v2_3_chassis, 'Chassis', autospec=True)
|
||||
def test_get_chassis(self, mock_chassis):
|
||||
self.rsd.get_chassis('fake-chassis-id')
|
||||
mock_chassis.assert_called_once_with(
|
||||
|
@ -22,9 +22,9 @@ from rsd_lib.resources.v2_1.event_service import event_service \
|
||||
from rsd_lib.resources.v2_1.registries import message_registry_file \
|
||||
as v2_1_registries
|
||||
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
||||
from rsd_lib.resources.v2_2.chassis import chassis as v2_2_chassis
|
||||
from rsd_lib.resources.v2_2.update_service import update_service \
|
||||
as v2_2_update_service
|
||||
from rsd_lib.resources.v2_3.chassis import chassis as v2_3_chassis
|
||||
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
||||
as v2_3_ethernet_switch
|
||||
from rsd_lib.resources.v2_3.manager import manager as v2_3_manager
|
||||
@ -111,14 +111,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
||||
self.rsd._conn, 'fake-fabric-id',
|
||||
redfish_version=self.rsd.redfish_version)
|
||||
|
||||
@mock.patch.object(v2_2_chassis, 'ChassisCollection', autospec=True)
|
||||
@mock.patch.object(v2_3_chassis, 'ChassisCollection', autospec=True)
|
||||
def test_get_chassis_collection(self, mock_chassis_collection):
|
||||
self.rsd.get_chassis_collection()
|
||||
mock_chassis_collection.assert_called_once_with(
|
||||
self.rsd._conn, '/redfish/v1/Chassis',
|
||||
redfish_version=self.rsd.redfish_version)
|
||||
|
||||
@mock.patch.object(v2_2_chassis, 'Chassis', autospec=True)
|
||||
@mock.patch.object(v2_3_chassis, 'Chassis', autospec=True)
|
||||
def test_get_chassis(self, mock_chassis):
|
||||
self.rsd.get_chassis('fake-chassis-id')
|
||||
mock_chassis.assert_called_once_with(
|
||||
|
Loading…
x
Reference in New Issue
Block a user