Add PCIeFunction resource for RSD 2.1
Change-Id: I538c7fa8e57b67959a33aa833fafdc48c181a8e3
This commit is contained in:
parent
aca4e4fef2
commit
203df22a5e
97
rsd_lib/resources/v2_1/chassis/pcie_function.py
Normal file
97
rsd_lib/resources/v2_1/chassis/pcie_function.py
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# Copyright 2018 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 utils as rsd_lib_utils
|
||||||
|
|
||||||
|
|
||||||
|
class StatusField(base.CompositeField):
|
||||||
|
state = base.Field('State')
|
||||||
|
health = base.Field('Health')
|
||||||
|
health_rollup = base.Field('HealthRollup')
|
||||||
|
|
||||||
|
|
||||||
|
class LinksField(base.CompositeField):
|
||||||
|
ethernet_interfaces = base.Field(
|
||||||
|
'EthernetInterfaces', adapter=utils.get_members_identities)
|
||||||
|
"""The value of this property shall reference a resource of type
|
||||||
|
EthernetInterface that represents the network interfaces associated
|
||||||
|
with this resource.
|
||||||
|
"""
|
||||||
|
|
||||||
|
drives = base.Field('Drives', adapter=utils.get_members_identities)
|
||||||
|
"""The value of this property shall reference a resource of type Drive
|
||||||
|
that represents the storage drives associated with this resource.
|
||||||
|
"""
|
||||||
|
|
||||||
|
storage_controllers = base.Field(
|
||||||
|
'StorageControllers', adapter=utils.get_members_identities)
|
||||||
|
"""The value of this property shall reference a resource of type
|
||||||
|
StorageController that represents the storage controllers associated
|
||||||
|
with this resource.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pcie_device = base.Field(
|
||||||
|
'PCIeDevice', adapter=rsd_lib_utils.get_resource_identity)
|
||||||
|
"""The value of this property shall be a reference to the resource that
|
||||||
|
this function is a part of and shall reference a resource of
|
||||||
|
type PCIeDevice.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class PCIeFunction(base.ResourceBase):
|
||||||
|
identity = base.Field('Id', required=True)
|
||||||
|
"""The PCIe function identity string"""
|
||||||
|
|
||||||
|
name = base.Field('Name')
|
||||||
|
"""The PCIe function name"""
|
||||||
|
|
||||||
|
description = base.Field('Description')
|
||||||
|
"""The PCIe function description"""
|
||||||
|
|
||||||
|
function_id = base.Field('FunctionId', adapter=rsd_lib_utils.num_or_none)
|
||||||
|
"""The the PCIe Function identifier"""
|
||||||
|
|
||||||
|
function_type = base.Field('FunctionType')
|
||||||
|
"""The type of the PCIe Function"""
|
||||||
|
|
||||||
|
device_class = base.Field('DeviceClass')
|
||||||
|
"""The class for this PCIe Function"""
|
||||||
|
|
||||||
|
device_id = base.Field('DeviceId')
|
||||||
|
"""The Device ID of this PCIe function"""
|
||||||
|
|
||||||
|
vendor_id = base.Field('VendorId')
|
||||||
|
"""The Vendor ID of this PCIe function"""
|
||||||
|
|
||||||
|
class_code = base.Field('ClassCode')
|
||||||
|
"""The Class Code of this PCIe function"""
|
||||||
|
|
||||||
|
revision_id = base.Field('RevisionId')
|
||||||
|
"""The Revision ID of this PCIe function"""
|
||||||
|
|
||||||
|
subsystem_id = base.Field('SubsystemId')
|
||||||
|
"""The Subsystem ID of this PCIe function"""
|
||||||
|
|
||||||
|
subsystem_vendor_id = base.Field('SubsystemVendorId')
|
||||||
|
"""The Subsystem Vendor ID of this PCIe function"""
|
||||||
|
|
||||||
|
status = StatusField('Status')
|
||||||
|
"""The PCIe function status"""
|
||||||
|
|
||||||
|
links = LinksField('Links')
|
||||||
|
"""The link section of PCIe function"""
|
33
rsd_lib/tests/unit/json_samples/v2_1/pcie_function.json
Normal file
33
rsd_lib/tests/unit/json_samples/v2_1/pcie_function.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"@odata.context": "/redfish/v1/$metadata#PCIeFunction.PCIeFunction",
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/Device1/Functions/1",
|
||||||
|
"@odata.type": "#PCIeFunction.v1_0_0.PCIeFunction",
|
||||||
|
"Id": "1",
|
||||||
|
"Name": "SSD",
|
||||||
|
"Description": "SSD Drive",
|
||||||
|
"FunctionId": 1,
|
||||||
|
"FunctionType": "Physical",
|
||||||
|
"DeviceClass": "MassStorageController",
|
||||||
|
"DeviceId": "0xABCD",
|
||||||
|
"VendorId": "0x8086",
|
||||||
|
"ClassCode": "0x10802",
|
||||||
|
"RevisionId": "0x00",
|
||||||
|
"SubsystemId": "0xABCD",
|
||||||
|
"SubsystemVendorId": "0xABCD",
|
||||||
|
"Status": {
|
||||||
|
"State": "Enabled",
|
||||||
|
"Health": "OK",
|
||||||
|
"HealthRollup": "OK"
|
||||||
|
},
|
||||||
|
"Links": {
|
||||||
|
"Drives": [
|
||||||
|
{
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/PCIeSwitch1/Drives/Disk.Bay.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PCIeDevice": {
|
||||||
|
"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/Device1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Oem": {}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
# Copyright 2018 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.
|
||||||
|
|
||||||
|
import json
|
||||||
|
import mock
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
from rsd_lib.resources.v2_1.chassis import pcie_function
|
||||||
|
|
||||||
|
|
||||||
|
class PCIeFunctionTestCase(testtools.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(PCIeFunctionTestCase, self).setUp()
|
||||||
|
self.conn = mock.Mock()
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||||
|
'pcie_function.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
|
||||||
|
self.pcie_function_inst = pcie_function.PCIeFunction(
|
||||||
|
self.conn, '/redfish/v1/Chassis/1/PCIeDevices/Device1/Functions/1',
|
||||||
|
redfish_version='1.1.0')
|
||||||
|
|
||||||
|
def test__parse_attributes(self):
|
||||||
|
self.pcie_function_inst._parse_attributes()
|
||||||
|
self.assertEqual('1', self.pcie_function_inst.identity)
|
||||||
|
self.assertEqual('SSD', self.pcie_function_inst.name)
|
||||||
|
self.assertEqual('SSD Drive',
|
||||||
|
self.pcie_function_inst.description)
|
||||||
|
self.assertEqual(
|
||||||
|
'Enabled', self.pcie_function_inst.status.state)
|
||||||
|
self.assertEqual('OK', self.pcie_function_inst.status.health)
|
||||||
|
self.assertEqual(
|
||||||
|
'OK', self.pcie_function_inst.status.health_rollup)
|
||||||
|
self.assertEqual(1, self.pcie_function_inst.function_id)
|
||||||
|
self.assertEqual('Physical', self.pcie_function_inst.function_type)
|
||||||
|
self.assertEqual(
|
||||||
|
'MassStorageController', self.pcie_function_inst.device_class)
|
||||||
|
self.assertEqual('0xABCD', self.pcie_function_inst.device_id)
|
||||||
|
self.assertEqual('0x8086', self.pcie_function_inst.vendor_id)
|
||||||
|
self.assertEqual('0x10802', self.pcie_function_inst.class_code)
|
||||||
|
self.assertEqual('0x00', self.pcie_function_inst.revision_id)
|
||||||
|
self.assertEqual('0xABCD', self.pcie_function_inst.subsystem_id)
|
||||||
|
self.assertEqual('0xABCD', self.pcie_function_inst.subsystem_vendor_id)
|
||||||
|
self.assertEqual(
|
||||||
|
None, self.pcie_function_inst.links.ethernet_interfaces)
|
||||||
|
self.assertEqual(
|
||||||
|
('/redfish/v1/Chassis/PCIeSwitch1/Drives/Disk.Bay.1',),
|
||||||
|
self.pcie_function_inst.links.drives)
|
||||||
|
self.assertEqual(
|
||||||
|
None, self.pcie_function_inst.links.storage_controllers)
|
||||||
|
self.assertEqual(
|
||||||
|
'/redfish/v1/Chassis/1/PCIeDevices/Device1',
|
||||||
|
self.pcie_function_inst.links.pcie_device)
|
Loading…
x
Reference in New Issue
Block a user