Remove PCIe device collection
According to system.xml, it should return a list of PCIe device instead of PCIe device collection. Change-Id: I47d38d59f8c5e7e5990fdf1e3f0896c6ddcaabbd
This commit is contained in:
parent
0b29ff0628
commit
25af2ae2cf
@ -21,6 +21,7 @@ from rsd_lib.resources.v2_1.system import memory
|
||||
from rsd_lib.resources.v2_1.system import network_interface
|
||||
from rsd_lib.resources.v2_1.system import pcie_device
|
||||
from rsd_lib.resources.v2_1.system import storage_subsystem
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
class System(system.System):
|
||||
@ -89,21 +90,20 @@ class System(system.System):
|
||||
self._conn, self._get_network_interfaces_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_pcie_device_collection_path(self):
|
||||
"""Helper function to find the pcie device collection path"""
|
||||
return utils.get_sub_resource_path_by(self, 'PCIeDevices')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def pcie_devices(self):
|
||||
"""Property to provide reference to `PCIeDevice` collection
|
||||
"""Property to provide reference to a list of `PCIeDevice` instances
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return pcie_device.PCIeDeviceCollection(
|
||||
self._conn, self._get_pcie_device_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
pcie_device_paths = rsd_lib_utils.get_sub_resource_path_list_by(
|
||||
self, 'PCIeDevices')
|
||||
return [
|
||||
pcie_device.PCIeDevice(
|
||||
self._conn, path, redfish_version=self.redfish_version
|
||||
) for path in pcie_device_paths]
|
||||
|
||||
|
||||
class SystemCollection(system.SystemCollection):
|
||||
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#PCIeDeviceCollection.PCIeDeviceCollection",
|
||||
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices",
|
||||
"@odata.type": "#PCIeDeviceCollection.PCIeDeviceCollection",
|
||||
"Name": "PCIe Device Collection",
|
||||
"Members@odata.count": 1,
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/Device1"
|
||||
}
|
||||
]
|
||||
}
|
@ -90,9 +90,14 @@
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/EthernetInterfaces"
|
||||
},
|
||||
"PCIeDevices": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/PCIeDevices"
|
||||
},
|
||||
"PCIeDevices": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/Device1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/Device2"
|
||||
}
|
||||
],
|
||||
"SimpleStorage": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/SimpleStorage"
|
||||
},
|
||||
|
@ -274,28 +274,19 @@ class SystemTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(self.system_inst.network_interfaces,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
|
||||
def test__get_pcie_device_collection_path(self):
|
||||
self.assertEqual('/redfish/v1/Systems/437XR1138R2/PCIeDevices',
|
||||
self.system_inst._get_pcie_device_collection_path())
|
||||
|
||||
def test__get_pcie_device_collection_path_missing_attr(self):
|
||||
self.system_inst._json.pop('PCIeDevices')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute PCIeDevices'):
|
||||
self.system_inst._get_pcie_device_collection_path()
|
||||
|
||||
def test_pcie_devices(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'pcie_device_collection.json', 'r') as f:
|
||||
'pcie_device.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_pcie_devices = self.system_inst.pcie_devices
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_pcie_devices,
|
||||
pcie_device.PCIeDeviceCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
self.assertEqual(2, len(actual_pcie_devices))
|
||||
for pcie in actual_pcie_devices:
|
||||
self.assertIsInstance(pcie, pcie_device.PCIeDevice)
|
||||
self.assertEqual(2, self.conn.get.return_value.json.call_count)
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
@ -308,11 +299,12 @@ class SystemTestCase(testtools.TestCase):
|
||||
def test_pcie_devices_on_fresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'pcie_device_collection.json', 'r') as f:
|
||||
'pcie_device.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.system_inst.pcie_devices,
|
||||
pcie_device.PCIeDeviceCollection)
|
||||
for pcie in self.system_inst.pcie_devices:
|
||||
self.assertIsInstance(pcie,
|
||||
pcie_device.PCIeDevice)
|
||||
|
||||
# On refreshing the chassis instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@ -324,11 +316,12 @@ class SystemTestCase(testtools.TestCase):
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'pcie_device_collection.json', 'r') as f:
|
||||
'pcie_device.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.system_inst.pcie_devices,
|
||||
pcie_device.PCIeDeviceCollection)
|
||||
for pcie in self.system_inst.pcie_devices:
|
||||
self.assertIsInstance(pcie,
|
||||
pcie_device.PCIeDevice)
|
||||
|
||||
|
||||
class SystemCollectionTestCase(testtools.TestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user