Add PortMetrics in RSD 2.2
Change-Id: Ifb0ceade2ddfca0427f5f0a5f71847e504c11541
This commit is contained in:
parent
ebdcb4ca45
commit
171b075a92
@ -17,6 +17,7 @@ from sushy.resources import base
|
|||||||
|
|
||||||
from rsd_lib.resources import v2_1
|
from rsd_lib.resources import v2_1
|
||||||
from rsd_lib.resources.v2_2.ethernet_switch import ethernet_switch
|
from rsd_lib.resources.v2_2.ethernet_switch import ethernet_switch
|
||||||
|
from rsd_lib.resources.v2_2.fabric import fabric
|
||||||
from rsd_lib.resources.v2_2.node import node
|
from rsd_lib.resources.v2_2.node import node
|
||||||
from rsd_lib.resources.v2_2.system import system
|
from rsd_lib.resources.v2_2.system import system
|
||||||
from rsd_lib.resources.v2_2.telemetry import telemetry
|
from rsd_lib.resources.v2_2.telemetry import telemetry
|
||||||
@ -125,3 +126,26 @@ class RSDLibV2_2(v2_1.RSDLibV2_1):
|
|||||||
self._update_service_path,
|
self._update_service_path,
|
||||||
redfish_version=self.redfish_version,
|
redfish_version=self.redfish_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_fabric_collection(self):
|
||||||
|
"""Get the FabricCollection object
|
||||||
|
|
||||||
|
:raises: MissingAttributeError, if the collection attribute is
|
||||||
|
not found
|
||||||
|
:returns: a FabricCollection object
|
||||||
|
"""
|
||||||
|
return fabric.FabricCollection(
|
||||||
|
self._conn,
|
||||||
|
self._fabrics_path,
|
||||||
|
redfish_version=self.redfish_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_fabric(self, identity):
|
||||||
|
"""Given the identity return a Fabric object
|
||||||
|
|
||||||
|
:param identity: The identity of the Fabric resource
|
||||||
|
:returns: The Fabric object
|
||||||
|
"""
|
||||||
|
return fabric.Fabric(
|
||||||
|
self._conn, identity, redfish_version=self.redfish_version
|
||||||
|
)
|
||||||
|
48
rsd_lib/resources/v2_2/fabric/fabric.py
Normal file
48
rsd_lib/resources/v2_2/fabric/fabric.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# 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 import utils
|
||||||
|
|
||||||
|
from rsd_lib import base as rsd_lib_base
|
||||||
|
from rsd_lib.resources.v2_1.fabric import fabric
|
||||||
|
from rsd_lib.resources.v2_2.fabric import switch
|
||||||
|
|
||||||
|
|
||||||
|
class Fabric(fabric.Fabric):
|
||||||
|
"""Fabric resource class
|
||||||
|
|
||||||
|
Fabric contains properties describing a simple fabric consisting of one
|
||||||
|
or more switches, zero or more endpoints, and zero or more zones.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
@utils.cache_it
|
||||||
|
def switches(self):
|
||||||
|
"""Property to provide reference to `SwitchCollection` instance
|
||||||
|
|
||||||
|
It is calculated once when it is queried for the first time. On
|
||||||
|
refresh, this property is reset.
|
||||||
|
"""
|
||||||
|
return switch.SwitchCollection(
|
||||||
|
self._conn,
|
||||||
|
utils.get_sub_resource_path_by(self, "Switches"),
|
||||||
|
redfish_version=self.redfish_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class FabricCollection(rsd_lib_base.ResourceCollectionBase):
|
||||||
|
@property
|
||||||
|
def _resource_type(self):
|
||||||
|
return Fabric
|
@ -15,24 +15,64 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from rsd_lib.resources.v2_1.fabric import port as v2_1_port
|
from sushy.resources import base
|
||||||
|
from sushy import utils
|
||||||
|
|
||||||
|
from rsd_lib import base as rsd_lib_base
|
||||||
|
from rsd_lib.resources.v2_1.fabric import port
|
||||||
|
from rsd_lib.resources.v2_2.fabric import port_metrics
|
||||||
from rsd_lib import utils as rsd_lib_utils
|
from rsd_lib import utils as rsd_lib_utils
|
||||||
|
|
||||||
from sushy.resources import base
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IntelRackScaleField(base.CompositeField):
|
class IntelRackScaleField(base.CompositeField):
|
||||||
metrics = base.Field("Metrics",
|
|
||||||
adapter=rsd_lib_utils.get_resource_identity)
|
pc_ie_connection_id = base.Field("PCIeConnectionId")
|
||||||
|
"""An array of references to the PCIe connection identifiers (e.g. cable
|
||||||
|
ID).
|
||||||
|
"""
|
||||||
|
|
||||||
|
metrics = base.Field(
|
||||||
|
"Metrics", adapter=rsd_lib_utils.get_resource_identity
|
||||||
|
)
|
||||||
|
"""A reference to the Metrics associated with this Port"""
|
||||||
|
|
||||||
|
|
||||||
class OemField(base.CompositeField):
|
class OemField(base.CompositeField):
|
||||||
intel_rackScale = IntelRackScaleField("Intel_RackScale")
|
|
||||||
"""The oem intel rack scale"""
|
intel_rackscale = IntelRackScaleField("Intel_RackScale")
|
||||||
|
"""Intel Rack Scale Design specific properties."""
|
||||||
|
|
||||||
|
|
||||||
class Port(v2_1_port.Port):
|
class Port(port.Port):
|
||||||
|
"""Port resource class
|
||||||
|
|
||||||
|
Port contains properties describing a port of a switch.
|
||||||
|
"""
|
||||||
|
|
||||||
oem = OemField("Oem")
|
oem = OemField("Oem")
|
||||||
"""The port oem"""
|
"""Oem specific properties."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
@utils.cache_it
|
||||||
|
def metrics(self):
|
||||||
|
"""Property to provide reference to `Metrics` instance
|
||||||
|
|
||||||
|
It is calculated once the first time it is queried. On refresh,
|
||||||
|
this property is reset.
|
||||||
|
"""
|
||||||
|
return port_metrics.PortMetrics(
|
||||||
|
self._conn,
|
||||||
|
utils.get_sub_resource_path_by(
|
||||||
|
self, ["Oem", "Intel_RackScale", "Metrics"]
|
||||||
|
),
|
||||||
|
redfish_version=self.redfish_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PortCollection(rsd_lib_base.ResourceCollectionBase):
|
||||||
|
@property
|
||||||
|
def _resource_type(self):
|
||||||
|
return Port
|
||||||
|
28
rsd_lib/resources/v2_2/fabric/port_metrics.py
Normal file
28
rsd_lib/resources/v2_2/fabric/port_metrics.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# 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 rsd_lib import base as rsd_lib_base
|
||||||
|
|
||||||
|
|
||||||
|
class PortMetrics(rsd_lib_base.ResourceBase):
|
||||||
|
"""PortMetrics resource class
|
||||||
|
|
||||||
|
Contains usage and health statistics of a Fabric Port.
|
||||||
|
"""
|
||||||
|
|
||||||
|
health = base.Field("Health")
|
||||||
|
"""Port health as a discrete sensor reading"""
|
47
rsd_lib/resources/v2_2/fabric/switch.py
Normal file
47
rsd_lib/resources/v2_2/fabric/switch.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 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 import utils
|
||||||
|
|
||||||
|
from rsd_lib import base as rsd_lib_base
|
||||||
|
from rsd_lib.resources.v2_1.fabric import switch
|
||||||
|
from rsd_lib.resources.v2_2.fabric import port
|
||||||
|
|
||||||
|
|
||||||
|
class Switch(switch.Switch):
|
||||||
|
"""Switch resource class
|
||||||
|
|
||||||
|
Switch contains properties describing a simple fabric switch.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
@utils.cache_it
|
||||||
|
def ports(self):
|
||||||
|
"""Property to provide reference to `PortCollection` instance
|
||||||
|
|
||||||
|
It is calculated once when it is queried for the first time. On
|
||||||
|
refresh, this property is reset.
|
||||||
|
"""
|
||||||
|
return port.PortCollection(
|
||||||
|
self._conn,
|
||||||
|
utils.get_sub_resource_path_by(self, "Ports"),
|
||||||
|
redfish_version=self.redfish_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SwitchCollection(rsd_lib_base.ResourceCollectionBase):
|
||||||
|
@property
|
||||||
|
def _resource_type(self):
|
||||||
|
return Switch
|
@ -38,4 +38,4 @@ class PortTestCase(testtools.TestCase):
|
|||||||
self.port_inst._parse_attributes()
|
self.port_inst._parse_attributes()
|
||||||
self.assertEqual('/redfish/v1/Fabrics/PCIe/Switches/1/'
|
self.assertEqual('/redfish/v1/Fabrics/PCIe/Switches/1/'
|
||||||
'Ports/Up1/Metrics',
|
'Ports/Up1/Metrics',
|
||||||
self.port_inst.oem.intel_rackScale.metrics)
|
self.port_inst.oem.intel_rackscale.metrics)
|
||||||
|
@ -20,7 +20,6 @@ import testtools
|
|||||||
from rsd_lib.resources.v2_1.chassis import chassis as v2_1_chassis
|
from rsd_lib.resources.v2_1.chassis import chassis as v2_1_chassis
|
||||||
from rsd_lib.resources.v2_1.event_service import event_service \
|
from rsd_lib.resources.v2_1.event_service import event_service \
|
||||||
as v2_1_event_service
|
as v2_1_event_service
|
||||||
from rsd_lib.resources.v2_1.fabric import fabric as v2_1_fabric
|
|
||||||
from rsd_lib.resources.v2_1.manager import manager as v2_1_manager
|
from rsd_lib.resources.v2_1.manager import manager as v2_1_manager
|
||||||
from rsd_lib.resources.v2_1.node import node as v2_1_node
|
from rsd_lib.resources.v2_1.node import node as v2_1_node
|
||||||
from rsd_lib.resources.v2_1.registries import message_registry_file \
|
from rsd_lib.resources.v2_1.registries import message_registry_file \
|
||||||
@ -31,6 +30,7 @@ from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
|||||||
from rsd_lib.resources import v2_2
|
from rsd_lib.resources import v2_2
|
||||||
from rsd_lib.resources.v2_2.ethernet_switch import ethernet_switch \
|
from rsd_lib.resources.v2_2.ethernet_switch import ethernet_switch \
|
||||||
as v2_2_ethernet_switch
|
as v2_2_ethernet_switch
|
||||||
|
from rsd_lib.resources.v2_2.fabric import fabric as v2_2_fabric
|
||||||
from rsd_lib.resources.v2_2.node import node as v2_2_node
|
from rsd_lib.resources.v2_2.node import node as v2_2_node
|
||||||
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
||||||
from rsd_lib.resources.v2_2.telemetry import telemetry as v2_2_telemetry
|
from rsd_lib.resources.v2_2.telemetry import telemetry as v2_2_telemetry
|
||||||
@ -111,7 +111,7 @@ class RSDLibV2_2TestCase(testtools.TestCase):
|
|||||||
redfish_version=self.rsd.redfish_version,
|
redfish_version=self.rsd.redfish_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch.object(v2_1_fabric, "FabricCollection", autospec=True)
|
@mock.patch.object(v2_2_fabric, "FabricCollection", autospec=True)
|
||||||
def test_get_fabric_collection(self, mock_fabric_collection):
|
def test_get_fabric_collection(self, mock_fabric_collection):
|
||||||
self.rsd.get_fabric_collection()
|
self.rsd.get_fabric_collection()
|
||||||
mock_fabric_collection.assert_called_once_with(
|
mock_fabric_collection.assert_called_once_with(
|
||||||
@ -120,7 +120,7 @@ class RSDLibV2_2TestCase(testtools.TestCase):
|
|||||||
redfish_version=self.rsd.redfish_version,
|
redfish_version=self.rsd.redfish_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch.object(v2_1_fabric, "Fabric", autospec=True)
|
@mock.patch.object(v2_2_fabric, "Fabric", autospec=True)
|
||||||
def test_get_fabric(self, mock_fabric):
|
def test_get_fabric(self, mock_fabric):
|
||||||
self.rsd.get_fabric("fake-fabric-id")
|
self.rsd.get_fabric("fake-fabric-id")
|
||||||
mock_fabric.assert_called_once_with(
|
mock_fabric.assert_called_once_with(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user