Add fabrics port resource for RSD2.2

Change-Id: If8644aa9a782123cbf2d1b51c06218be45b5fd9e
This commit is contained in:
monokai 2019-01-17 12:29:30 +08:00
parent 8b0350759c
commit 141a7b4736
5 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,38 @@
# 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.
import logging
from rsd_lib.resources.v2_1.fabric import port as v2_1_port
from rsd_lib import utils as rsd_lib_utils
from sushy.resources import base
LOG = logging.getLogger(__name__)
class IntelRackScaleField(base.CompositeField):
metrics = base.Field("Metrics",
adapter=rsd_lib_utils.get_resource_identity)
class OemField(base.CompositeField):
intel_rackScale = IntelRackScaleField("Intel_RackScale")
"""The oem intel rack scale"""
class Port(v2_1_port.Port):
oem = OemField("Oem")
"""The port oem"""

View File

@ -0,0 +1,56 @@
{
"@odata.context":"/redfish/v1/$metadata#Port.Port",
"@odata.id":"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1",
"@odata.type":"#Port.v1_0_0.Port",
"Id":"Up1",
"Name":"PCIe Upstream Port 1",
"Description":"PCIe Upstream Port 1",
"Status":{
"State":"Enabled",
"Health":"OK",
"HealthRollup":null
},
"PortId":"1",
"PortProtocol":"PCIe",
"PortType":"UpstreamPort",
"CurrentSpeedGbps":32,
"Width":4,
"MaxSpeedGbps":64,
"Actions":{
"#Port.Reset":{
"target":"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/Actions/PCIePort.Reset",
"ResetType@Redfish.AllowableValues":[
"ForceOff",
"ForceRestart",
"ForceOn"
]
},
"Oem":{
}
},
"Links":{
"AssociatedEndpoints":[
{
"@odata.id":"/redfish/v1/Fabrics/PCIe/Endpoints/HostRootComplex1"
}
],
"ConnectedSwitches":[
],
"ConnectedSwitchPorts":[
]
},
"Oem":{
"Intel_RackScale":{
"@odata.type":"#Intel.Oem.Port",
"PCIeConnectionId":[
"XYZ1234567890"
],
"Metrics":{
"@odata.id":"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/Metrics"
}
}
}
}

View File

@ -0,0 +1,41 @@
# 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.
import json
import mock
import testtools
from rsd_lib.resources.v2_2.fabric import port
class PortTestCase(testtools.TestCase):
def setUp(self):
super(PortTestCase, self).setUp()
self.conn = mock.Mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/fabrics_port.json',
'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read())
self.port_inst = port.Port(
self.conn, '/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1',
redfish_version='1.0.2')
def test__parse_attributes(self):
self.port_inst._parse_attributes()
self.assertEqual('/redfish/v1/Fabrics/PCIe/Switches/1/'
'Ports/Up1/Metrics',
self.port_inst.oem.intel_rackScale.metrics)