139 lines
4.0 KiB
Python
139 lines
4.0 KiB
Python
# 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 sushy.resources import base
|
|
|
|
from sushy import utils
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class StatusField(base.CompositeField):
|
|
state = base.Field("State")
|
|
"""The status state"""
|
|
|
|
health = base.Field("Health")
|
|
"""The status health"""
|
|
|
|
|
|
class PortResetField(base.CompositeField):
|
|
target = base.Field("target")
|
|
"""The port reset target"""
|
|
|
|
reset_type_redfish_allowable_values = base.Field("ResetType@Redfish."
|
|
"AllowableValues")
|
|
"""The port reset type redfish allowable values"""
|
|
|
|
|
|
class ActionsField(base.CompositeField):
|
|
port_reset = PortResetField("#Port.Reset")
|
|
"""The action port reset"""
|
|
|
|
|
|
class LinksField(base.CompositeField):
|
|
associated_endpoints = base.Field("AssociatedEndpoints", default=[],
|
|
adapter=utils.get_members_identities)
|
|
"""The link associated endpoints"""
|
|
|
|
|
|
class IntelRackScaleField(base.CompositeField):
|
|
odata_type = base.Field("@odata.type")
|
|
"""The Intel Rack Scale odata type"""
|
|
|
|
pcie_connection_id = base.Field("PCIeConnectionId")
|
|
"""The Intel Rack Scale PCIe Connection Id"""
|
|
|
|
|
|
class OemField(base.CompositeField):
|
|
intel_rackScale = IntelRackScaleField("Intel_RackScale")
|
|
"""The oem intel rack scale"""
|
|
|
|
|
|
class Port(base.ResourceBase):
|
|
identity = base.Field("Id")
|
|
"""The port identity string"""
|
|
|
|
name = base.Field("Name")
|
|
"""The port name"""
|
|
|
|
description = base.Field("Description")
|
|
"""The port description"""
|
|
|
|
status = StatusField("Status")
|
|
"""The port status"""
|
|
|
|
port_id = base.Field("PortId")
|
|
"""The port id"""
|
|
|
|
port_protocol = base.Field("PortProtocol")
|
|
"""The port protocol"""
|
|
|
|
port_type = base.Field("PortType")
|
|
"""The port type"""
|
|
|
|
current_speed_gbps = base.Field("CurrentSpeedGbps")
|
|
"""The port current speed Gbps"""
|
|
|
|
width = base.Field("Width")
|
|
"""The port width"""
|
|
|
|
max_speed_gbps = base.Field("MaxSpeedGbps")
|
|
"""The port max speed gbps"""
|
|
|
|
actions = ActionsField("Actions")
|
|
"""The port actions"""
|
|
|
|
oem = OemField("Oem")
|
|
"""The port oem"""
|
|
|
|
links = LinksField("Links")
|
|
"""The port links"""
|
|
|
|
def __init__(self, connector, identity, redfish_version=None):
|
|
"""A class representing a Port
|
|
|
|
:param connector: A Connector instance
|
|
:param identity: The identity of the Port resource
|
|
:param redfish_version: The version of RedFish. Used to construct
|
|
the object according to schema of the given version.
|
|
"""
|
|
super(Port, self).__init__(connector, identity,
|
|
redfish_version)
|
|
|
|
def reset_port(self):
|
|
"""A post method to reset port"""
|
|
|
|
data = {"ResetType": "ForceRestart"}
|
|
target_uri = self.actions.port_reset.target
|
|
self._conn.post(target_uri, data=data)
|
|
|
|
|
|
class PortCollection(base.ResourceCollectionBase):
|
|
@property
|
|
def _resource_type(self):
|
|
return Port
|
|
|
|
def __init__(self, connector, path, redfish_version=None):
|
|
"""A class representing a Port
|
|
|
|
:param connector: A Connector instance
|
|
:param path: The canonical path to the Port collection resource
|
|
:param redfish_version: The version of RedFish. Used to construct
|
|
the object according to schema of the given version.
|
|
"""
|
|
super(PortCollection, self).__init__(connector, path, redfish_version)
|