Browse Source

Add missing attribute in Chassis in RSD 2.3

Change-Id: Icc76a4b629a3a9d522fffb7aea412804729be2c6
tags/1.1.1
Lin Yang 1 month ago
parent
commit
ff39abe91b

+ 24
- 0
rsd_lib/resources/v2_3/__init__.py View File

@@ -17,6 +17,7 @@ from sushy.resources import base
17 17
 
18 18
 from rsd_lib import exceptions as rsd_lib_exceptions
19 19
 from rsd_lib.resources import v2_2
20
+from rsd_lib.resources.v2_3.chassis import chassis
20 21
 from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch
21 22
 from rsd_lib.resources.v2_3.fabric import fabric
22 23
 from rsd_lib.resources.v2_3.manager import manager
@@ -35,6 +36,29 @@ class RSDLibV2_3(v2_2.RSDLibV2_2):
35 36
     _storage_service_path = base.Field(['StorageServices', '@odata.id'])
36 37
     """StorageServiceCollection path"""
37 38
 
39
+    def get_chassis_collection(self):
40
+        """Get the ChassisCollection object
41
+
42
+        :raises: MissingAttributeError, if the collection attribute is
43
+            not found
44
+        :returns: a ChassisCollection object
45
+        """
46
+        return chassis.ChassisCollection(
47
+            self._conn,
48
+            self._chassis_path,
49
+            redfish_version=self.redfish_version,
50
+        )
51
+
52
+    def get_chassis(self, identity):
53
+        """Given the identity return a Chassis object
54
+
55
+        :param identity: The identity of the Chassis resource
56
+        :returns: The Chassis object
57
+        """
58
+        return chassis.Chassis(
59
+            self._conn, identity, redfish_version=self.redfish_version
60
+        )
61
+
38 62
     def get_system(self, identity):
39 63
         """Given the identity return a System object
40 64
 

+ 0
- 0
rsd_lib/resources/v2_3/chassis/__init__.py View File


+ 172
- 0
rsd_lib/resources/v2_3/chassis/chassis.py View File

@@ -0,0 +1,172 @@
1
+# Copyright 2019 Intel, Inc.
2
+# All Rights Reserved.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+
16
+from sushy.resources import base
17
+from sushy import utils
18
+
19
+from rsd_lib import base as rsd_lib_base
20
+from rsd_lib.resources.v2_1.chassis import chassis
21
+from rsd_lib.resources.v2_1.chassis import log_service
22
+from rsd_lib.resources.v2_2.chassis import power
23
+from rsd_lib.resources.v2_2.chassis import thermal
24
+from rsd_lib import utils as rsd_lib_utils
25
+
26
+
27
+class LinksField(chassis.LinksField):
28
+
29
+    pcie_devices = base.Field(
30
+        "PCIeDevices", adapter=utils.get_members_identities
31
+    )
32
+    """An array of references to the PCIe Devices located in this Chassis."""
33
+
34
+
35
+class Chassis(rsd_lib_base.ResourceBase):
36
+    """Chassis resource class
37
+
38
+       A Chassis represents the physical components for any system.  This
39
+       resource represents the sheet-metal confined spaces and logical zones
40
+       like racks, enclosures, chassis and all other containers. Subsystems
41
+       (like sensors), which operate outside of a system's data plane (meaning
42
+       the resources are not accessible to software running on the system) are
43
+       linked either directly or indirectly through this resource.
44
+    """
45
+
46
+    chassis_type = base.Field("ChassisType")
47
+    """This property indicates the type of physical form factor of this
48
+       resource.
49
+    """
50
+
51
+    manufacturer = base.Field("Manufacturer")
52
+    """This is the manufacturer of this chassis."""
53
+
54
+    model = base.Field("Model")
55
+    """This is the model number for the chassis."""
56
+
57
+    sku = base.Field("SKU")
58
+    """This is the SKU for this chassis."""
59
+
60
+    serial_number = base.Field("SerialNumber")
61
+    """The serial number for this chassis."""
62
+
63
+    part_number = base.Field("PartNumber")
64
+    """The part number for this chassis."""
65
+
66
+    asset_tag = base.Field("AssetTag")
67
+    """The user assigned asset tag for this chassis."""
68
+
69
+    indicator_led = base.Field("IndicatorLED")
70
+    """The state of the indicator LED, used to identify the chassis."""
71
+
72
+    links = LinksField("Links")
73
+    """Contains references to other resources that are related to this
74
+       resource.
75
+    """
76
+
77
+    status = rsd_lib_base.StatusField("Status")
78
+    """This indicates the known state of the resource, such as if it is
79
+       enabled.
80
+    """
81
+
82
+    power_state = base.Field("PowerState")
83
+    """This is the current power state of the chassis."""
84
+
85
+    physical_security = chassis.PhysicalSecurityField("PhysicalSecurity")
86
+    """The state of the physical security sensor."""
87
+
88
+    location = rsd_lib_base.LocationField("Location")
89
+    """Location of a resource"""
90
+
91
+    height_mm = base.Field("HeightMm", adapter=rsd_lib_utils.num_or_none)
92
+    """The height of the chassis."""
93
+
94
+    width_mm = base.Field("WidthMm", adapter=rsd_lib_utils.num_or_none)
95
+    """The width of the chassis."""
96
+
97
+    depth_mm = base.Field("DepthMm", adapter=rsd_lib_utils.num_or_none)
98
+    """The depth of the chassis."""
99
+
100
+    weight_kg = base.Field("WeightKg", adapter=rsd_lib_utils.num_or_none)
101
+    """The weight of the chassis."""
102
+
103
+    oem = chassis.OemField("Oem")
104
+    """Oem specific properties."""
105
+
106
+    @property
107
+    @utils.cache_it
108
+    def log_services(self):
109
+        """Property to provide reference to `LogServiceCollection` instance
110
+
111
+           It is calculated once when it is queried for the first time. On
112
+           refresh, this property is reset.
113
+        """
114
+        return log_service.LogServiceCollection(
115
+            self._conn,
116
+            utils.get_sub_resource_path_by(self, "LogServices"),
117
+            redfish_version=self.redfish_version,
118
+        )
119
+
120
+    @property
121
+    @utils.cache_it
122
+    def thermal(self):
123
+        """Property to provide reference to `Thermal` instance
124
+
125
+           It is calculated once when it is queried for the first time. On
126
+           refresh, this property is reset.
127
+        """
128
+        return thermal.Thermal(
129
+            self._conn,
130
+            utils.get_sub_resource_path_by(self, "Thermal"),
131
+            redfish_version=self.redfish_version,
132
+        )
133
+
134
+    @property
135
+    @utils.cache_it
136
+    def power(self):
137
+        """Property to provide reference to `Power` instance
138
+
139
+           It is calculated once when it is queried for the first time. On
140
+           refresh, this property is reset.
141
+        """
142
+        return power.Power(
143
+            self._conn,
144
+            utils.get_sub_resource_path_by(self, "Power"),
145
+            redfish_version=self.redfish_version,
146
+        )
147
+
148
+    def update(self, asset_tag=None, location_id=None):
149
+        """Update AssetTag and Location->Id properties
150
+
151
+        :param asset_tag: The user assigned asset tag for this chassis
152
+        :param location_id: The user assigned location id for this chassis.
153
+                            It can be changed only for a Rack Chassis
154
+        """
155
+
156
+        data = {}
157
+
158
+        if asset_tag is not None:
159
+            data["AssetTag"] = asset_tag
160
+
161
+        if location_id is not None:
162
+            data["Oem"] = {
163
+                "Intel_RackScale": {"Location": {"Id": location_id}}
164
+            }
165
+
166
+        self._conn.patch(self.path, data=data)
167
+
168
+
169
+class ChassisCollection(rsd_lib_base.ResourceCollectionBase):
170
+    @property
171
+    def _resource_type(self):
172
+        return Chassis

+ 3
- 3
rsd_lib/tests/unit/resources/v2_3/test_rsdlib_v2_3.py View File

@@ -23,10 +23,10 @@ from rsd_lib.resources.v2_1.event_service import event_service \
23 23
 from rsd_lib.resources.v2_1.registries import message_registry_file \
24 24
     as v2_1_registries
25 25
 from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
26
-from rsd_lib.resources.v2_2.chassis import chassis as v2_2_chassis
27 26
 from rsd_lib.resources.v2_2.update_service import update_service \
28 27
     as v2_2_update_service
29 28
 from rsd_lib.resources import v2_3
29
+from rsd_lib.resources.v2_3.chassis import chassis as v2_3_chassis
30 30
 from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
31 31
     as v2_3_ethernet_switch
32 32
 from rsd_lib.resources.v2_3.fabric import fabric as v2_3_fabric
@@ -112,14 +112,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
112 112
             self.rsd._conn, 'fake-fabric-id',
113 113
             redfish_version=self.rsd.redfish_version)
114 114
 
115
-    @mock.patch.object(v2_2_chassis, 'ChassisCollection', autospec=True)
115
+    @mock.patch.object(v2_3_chassis, 'ChassisCollection', autospec=True)
116 116
     def test_get_chassis_collection(self, mock_chassis_collection):
117 117
         self.rsd.get_chassis_collection()
118 118
         mock_chassis_collection.assert_called_once_with(
119 119
             self.rsd._conn, '/redfish/v1/Chassis',
120 120
             redfish_version=self.rsd.redfish_version)
121 121
 
122
-    @mock.patch.object(v2_2_chassis, 'Chassis', autospec=True)
122
+    @mock.patch.object(v2_3_chassis, 'Chassis', autospec=True)
123 123
     def test_get_chassis(self, mock_chassis):
124 124
         self.rsd.get_chassis('fake-chassis-id')
125 125
         mock_chassis.assert_called_once_with(

+ 3
- 3
rsd_lib/tests/unit/resources/v2_4/test_rsdlib_v2_4.py View File

@@ -22,9 +22,9 @@ from rsd_lib.resources.v2_1.event_service import event_service \
22 22
 from rsd_lib.resources.v2_1.registries import message_registry_file \
23 23
     as v2_1_registries
24 24
 from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
25
-from rsd_lib.resources.v2_2.chassis import chassis as v2_2_chassis
26 25
 from rsd_lib.resources.v2_2.update_service import update_service \
27 26
     as v2_2_update_service
27
+from rsd_lib.resources.v2_3.chassis import chassis as v2_3_chassis
28 28
 from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
29 29
     as v2_3_ethernet_switch
30 30
 from rsd_lib.resources.v2_3.manager import manager as v2_3_manager
@@ -111,14 +111,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
111 111
             self.rsd._conn, 'fake-fabric-id',
112 112
             redfish_version=self.rsd.redfish_version)
113 113
 
114
-    @mock.patch.object(v2_2_chassis, 'ChassisCollection', autospec=True)
114
+    @mock.patch.object(v2_3_chassis, 'ChassisCollection', autospec=True)
115 115
     def test_get_chassis_collection(self, mock_chassis_collection):
116 116
         self.rsd.get_chassis_collection()
117 117
         mock_chassis_collection.assert_called_once_with(
118 118
             self.rsd._conn, '/redfish/v1/Chassis',
119 119
             redfish_version=self.rsd.redfish_version)
120 120
 
121
-    @mock.patch.object(v2_2_chassis, 'Chassis', autospec=True)
121
+    @mock.patch.object(v2_3_chassis, 'Chassis', autospec=True)
122 122
     def test_get_chassis(self, mock_chassis):
123 123
         self.rsd.get_chassis('fake-chassis-id')
124 124
         mock_chassis.assert_called_once_with(

Loading…
Cancel
Save