Add all missing attributes of Fabric in RSD 2.1
Change-Id: I01cdc5554f48d1f7db04585879557e182f3771ba
This commit is contained in:
parent
24a51a3b36
commit
ac3a3c622a
@ -91,6 +91,15 @@ class IdentifierField(base.CompositeField):
|
||||
"""This represents the format of the DurableName property."""
|
||||
|
||||
|
||||
class IdentifierCollectionField(ReferenceableMemberField):
|
||||
|
||||
durable_name = base.Field("DurableName")
|
||||
"""This indicates the world wide, persistent name of the resource."""
|
||||
|
||||
durable_name_format = base.Field("DurableNameFormat")
|
||||
"""This represents the format of the DurableName property."""
|
||||
|
||||
|
||||
class ResourceBase(base.ResourceBase):
|
||||
|
||||
identity = base.Field("Id", required=True)
|
||||
|
@ -16,85 +16,124 @@
|
||||
import logging
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import common as rsd_lib_common
|
||||
from rsd_lib import utils
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
from rsd_lib.resources.v2_1.common import redundancy
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IdentifiersField(base.ListField):
|
||||
name_format = base.Field('DurableNameFormat')
|
||||
name = base.Field('DurableName')
|
||||
class LinksField(base.CompositeField):
|
||||
|
||||
mutually_exclusive_endpoints = base.Field(
|
||||
"MutuallyExclusiveEndpoints", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the endpoints that may not be used in zones
|
||||
if this endpoint is used in a zone.
|
||||
"""
|
||||
|
||||
ports = base.Field("Ports", adapter=utils.get_members_identities)
|
||||
"""An array of references to the the physical ports associated with this
|
||||
endpoint.
|
||||
"""
|
||||
|
||||
|
||||
class EntityLinkField(base.CompositeField):
|
||||
# TODO(ntpttr): Link to the actual object once we have a class for it.
|
||||
identity = base.Field('@odata.id')
|
||||
class PciIdField(base.CompositeField):
|
||||
|
||||
device_id = base.Field("DeviceId")
|
||||
"""The Device ID of this PCIe function."""
|
||||
|
||||
vendor_id = base.Field("VendorId")
|
||||
"""The Vendor 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."""
|
||||
|
||||
|
||||
class ConnectedEntitiesField(base.ListField):
|
||||
entity_type = base.Field('EntityType')
|
||||
entity_role = base.Field('EntityRole')
|
||||
entity_link = base.Field('EntityLink',
|
||||
adapter=utils.get_resource_identity)
|
||||
identifiers = IdentifiersField('Identifiers')
|
||||
class ConnectedEntityCollectionField(rsd_lib_base.ReferenceableMemberField):
|
||||
"""ConnectedEntity field
|
||||
|
||||
Represents a remote resource that is connected to the network
|
||||
accessible to this endpoint.
|
||||
"""
|
||||
|
||||
entity_type = base.Field("EntityType")
|
||||
"""The type of the connected entity."""
|
||||
|
||||
entity_role = base.Field("EntityRole")
|
||||
"""The role of the connected entity."""
|
||||
|
||||
entity_link = base.Field(
|
||||
"EntityLink", adapter=rsd_lib_utils.get_resource_identity
|
||||
)
|
||||
"""A link to the associated entity."""
|
||||
|
||||
entity_pci_id = PciIdField("EntityPciId")
|
||||
"""The PCI ID of the connected entity."""
|
||||
|
||||
pci_function_number = base.Field(
|
||||
"PciFunctionNumber", adapter=rsd_lib_utils.num_or_none
|
||||
)
|
||||
"""The PCI ID of the connected entity."""
|
||||
|
||||
pci_class_code = base.Field("PciClassCode")
|
||||
"""The Class Code and Subclass code of this PCIe function."""
|
||||
|
||||
identifiers = rsd_lib_base.IdentifierCollectionField("Identifiers")
|
||||
"""Identifiers for the remote entity."""
|
||||
|
||||
|
||||
class Endpoint(base.ResourceBase):
|
||||
class Endpoint(rsd_lib_base.ResourceBase):
|
||||
"""Endpoint resource class
|
||||
|
||||
connected_entities = ConnectedEntitiesField('ConnectedEntities')
|
||||
"""Entities connected to endpoint"""
|
||||
This is the schema definition for the Endpoint resource. It represents
|
||||
the properties of an entity that sends or receives protocol defined
|
||||
messages over a transport.
|
||||
"""
|
||||
|
||||
description = base.Field('Description')
|
||||
"""The endpoint description"""
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
host_reservation_memory = base.Field('HostReservationMemoryBytes')
|
||||
"""Host reservation memory in bytes"""
|
||||
endpoint_protocol = base.Field("EndpointProtocol")
|
||||
"""The protocol supported by this endpoint."""
|
||||
|
||||
protocol = base.Field('EndpointProtocol')
|
||||
"""Protocol for endpoint (i.e. PCIe)"""
|
||||
connected_entities = ConnectedEntityCollectionField("ConnectedEntities")
|
||||
"""All the entities connected to this endpoint."""
|
||||
|
||||
identifiers = IdentifiersField('Identifiers')
|
||||
"""Identifiers for endpoint"""
|
||||
identifiers = rsd_lib_base.IdentifierCollectionField("Identifiers")
|
||||
"""Identifiers for this endpoint"""
|
||||
|
||||
identity = base.Field('Id', required=True)
|
||||
"""The endpoint identity string"""
|
||||
pci_id = PciIdField("PciId")
|
||||
"""The PCI ID of the endpoint."""
|
||||
|
||||
name = base.Field('Name')
|
||||
"""The endpoint name"""
|
||||
host_reservation_memory_bytes = base.Field(
|
||||
"HostReservationMemoryBytes", adapter=rsd_lib_utils.num_or_none
|
||||
)
|
||||
"""The amount of memory in Bytes that the Host should allocate to connect
|
||||
to this endpoint.
|
||||
"""
|
||||
|
||||
redundancy = base.Field('Redundancy')
|
||||
"""The endpoint redundancy"""
|
||||
links = LinksField("Links")
|
||||
"""The links object contains the links to other resources that are related
|
||||
to this resource.
|
||||
"""
|
||||
|
||||
status = rsd_lib_common.StatusField('Status')
|
||||
"""The endpoint status"""
|
||||
redundancy = redundancy.RedundancyCollectionField("Redundancy")
|
||||
"""Redundancy information for the lower level endpoints supporting this
|
||||
endpoint
|
||||
"""
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing an Endpoint
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param identity: The identity of the RemoteTarget resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(Endpoint, self).__init__(connector, identity,
|
||||
redfish_version)
|
||||
# TODO(linyang): Add Action Field
|
||||
|
||||
|
||||
class EndpointCollection(base.ResourceCollectionBase):
|
||||
|
||||
class EndpointCollection(rsd_lib_base.ResourceCollectionBase):
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return Endpoint
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing an Endpoint
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the Endpoint collection resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(EndpointCollection, self).__init__(connector, path,
|
||||
redfish_version)
|
||||
|
@ -18,107 +18,81 @@ import logging
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import common as rsd_lib_common
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
from rsd_lib.resources.v2_1.fabric import endpoint
|
||||
from rsd_lib.resources.v2_1.fabric import switch
|
||||
from rsd_lib.resources.v2_1.fabric import zone
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Fabric(base.ResourceBase):
|
||||
class Fabric(rsd_lib_base.ResourceBase):
|
||||
"""Fabric resource class
|
||||
|
||||
description = base.Field('Description')
|
||||
"""The fabric description"""
|
||||
Fabric contains properties describing a simple fabric consisting of one
|
||||
or more switches, zero or more endpoints, and zero or more zones.
|
||||
"""
|
||||
|
||||
fabric_type = base.Field('FabricType')
|
||||
"""The fabric type"""
|
||||
fabric_type = base.Field("FabricType")
|
||||
"""The protocol being sent over this fabric."""
|
||||
|
||||
identity = base.Field('Id', required=True)
|
||||
"""The fabric identity string"""
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
max_zones = base.Field('MaxZones')
|
||||
"""Maximum number of zones for the fabric"""
|
||||
max_zones = base.Field("MaxZones", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The value of this property shall contain the maximum number of zones
|
||||
the switch can currently configure.
|
||||
"""
|
||||
|
||||
name = base.Field('Name')
|
||||
"""The fabric name"""
|
||||
|
||||
status = rsd_lib_common.StatusField('Status')
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Fabric
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param identity: The identity of the Fabric resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(Fabric, self).__init__(connector, identity,
|
||||
redfish_version)
|
||||
|
||||
def _get_endpoint_collection_path(self):
|
||||
"""Helper function to find the EndpointCollection path"""
|
||||
return utils.get_sub_resource_path_by(self, 'Endpoints')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def endpoints(self):
|
||||
"""Property to provide reference to `EndpointCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_switch_collection_path(self):
|
||||
"""Helper function to find the SwitchCollection path"""
|
||||
return utils.get_sub_resource_path_by(self, 'Switches')
|
||||
|
||||
@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, self._get_switch_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_zone_collection_path(self):
|
||||
"""Helper function to find the ZoneCollection path"""
|
||||
return utils.get_sub_resource_path_by(self, 'Zones')
|
||||
# TODO(linyang): Add Action Field
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def zones(self):
|
||||
"""Property to provide reference to `ZoneCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return zone.ZoneCollection(
|
||||
self._conn, self._get_zone_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "Zones"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def endpoints(self):
|
||||
"""Property to provide reference to `EndpointCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return endpoint.EndpointCollection(
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "Endpoints"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
@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(base.ResourceCollectionBase):
|
||||
|
||||
class FabricCollection(rsd_lib_base.ResourceCollectionBase):
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return Fabric
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing a FabricCollection
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the Fabric collection
|
||||
resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(FabricCollection, self).__init__(connector, path,
|
||||
redfish_version)
|
||||
|
@ -20,75 +20,102 @@ from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import common as rsd_lib_common
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ActionsField(base.CompositeField):
|
||||
|
||||
reset = common.ResetActionField("#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"""
|
||||
pc_ie_connection_id = base.Field("PCIeConnectionId")
|
||||
"""An array of references to the PCIe connection identifiers (e.g. cable
|
||||
ID).
|
||||
"""
|
||||
|
||||
|
||||
class LinksField(base.CompositeField):
|
||||
|
||||
associated_endpoints = base.Field(
|
||||
"AssociatedEndpoints", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the endpoints that connect to the switch
|
||||
through this port.
|
||||
"""
|
||||
|
||||
connected_switches = base.Field(
|
||||
"ConnectedSwitches", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the switches that connect to the switch
|
||||
through this port.
|
||||
"""
|
||||
|
||||
connected_switch_ports = base.Field(
|
||||
"ConnectedSwitchPorts", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the ports that connect to the switch through
|
||||
this port.
|
||||
"""
|
||||
|
||||
|
||||
class OemField(base.CompositeField):
|
||||
intel_rackScale = IntelRackScaleField("Intel_RackScale")
|
||||
|
||||
intel_rackscale = IntelRackScaleField("Intel_RackScale")
|
||||
"""The oem intel rack scale"""
|
||||
|
||||
|
||||
class Port(base.ResourceBase):
|
||||
identity = base.Field("Id")
|
||||
"""The port identity string"""
|
||||
class Port(rsd_lib_base.ResourceBase):
|
||||
"""Port resource class
|
||||
|
||||
name = base.Field("Name")
|
||||
"""The port name"""
|
||||
Port contains properties describing a port of a switch.
|
||||
"""
|
||||
|
||||
description = base.Field("Description")
|
||||
"""The port description"""
|
||||
|
||||
status = rsd_lib_common.StatusField('Status')
|
||||
"""The port status"""
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
port_id = base.Field("PortId")
|
||||
"""The port id"""
|
||||
"""This is the label of this port on the physical switch package."""
|
||||
|
||||
port_protocol = base.Field("PortProtocol")
|
||||
"""The port protocol"""
|
||||
"""The protocol being sent over this port."""
|
||||
|
||||
port_type = base.Field("PortType")
|
||||
"""The port type"""
|
||||
"""This is the type of this port."""
|
||||
|
||||
current_speed_gbps = base.Field("CurrentSpeedGbps")
|
||||
"""The port current speed Gbps"""
|
||||
current_speed_gbps = base.Field(
|
||||
"CurrentSpeedGbps", adapter=rsd_lib_utils.num_or_none
|
||||
)
|
||||
"""The current speed of this port."""
|
||||
|
||||
width = base.Field("Width")
|
||||
"""The port width"""
|
||||
max_speed_gbps = base.Field(
|
||||
"MaxSpeedGbps", adapter=rsd_lib_utils.num_or_none
|
||||
)
|
||||
"""The maximum speed of this port as currently configured."""
|
||||
|
||||
max_speed_gbps = base.Field("MaxSpeedGbps")
|
||||
"""The port max speed gbps"""
|
||||
width = base.Field("Width", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The number of lanes, phys, or other physical transport links that this
|
||||
port contains.
|
||||
"""
|
||||
|
||||
links = LinksField("Links")
|
||||
"""Contains references to other resources that are related to this
|
||||
resource.
|
||||
"""
|
||||
|
||||
oem = OemField("Oem")
|
||||
"""Oem specific properties."""
|
||||
|
||||
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
|
||||
|
||||
@ -97,14 +124,14 @@ class Port(base.ResourceBase):
|
||||
: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)
|
||||
super(Port, self).__init__(connector, identity, redfish_version)
|
||||
|
||||
def _get_reset_action_element(self):
|
||||
reset_action = self.actions.reset
|
||||
if not reset_action:
|
||||
raise exceptions.MissingActionError(action='#Port.Reset',
|
||||
resource=self._path)
|
||||
raise exceptions.MissingActionError(
|
||||
action="#Port.Reset", resource=self._path
|
||||
)
|
||||
return reset_action
|
||||
|
||||
def get_allowed_reset_port_values(self):
|
||||
@ -126,24 +153,15 @@ class Port(base.ResourceBase):
|
||||
valid_resets = self.get_allowed_reset_port_values()
|
||||
if value not in valid_resets:
|
||||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='value', value=value, valid_values=valid_resets)
|
||||
parameter="value", value=value, valid_values=valid_resets
|
||||
)
|
||||
|
||||
target_uri = self._get_reset_action_element().target_uri
|
||||
|
||||
self._conn.post(target_uri, data={'ResetType': value})
|
||||
self._conn.post(target_uri, data={"ResetType": value})
|
||||
|
||||
|
||||
class PortCollection(base.ResourceCollectionBase):
|
||||
class PortCollection(rsd_lib_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)
|
||||
|
@ -20,7 +20,9 @@ from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import common as rsd_lib_common
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
from rsd_lib.resources.v2_1.chassis import log_service
|
||||
from rsd_lib.resources.v2_1.common import redundancy
|
||||
from rsd_lib.resources.v2_1.fabric import port
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
@ -28,86 +30,89 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LinksField(base.CompositeField):
|
||||
chassis = base.Field("Chassis", adapter=utils.get_members_identities)
|
||||
|
||||
chassis = base.Field(
|
||||
"Chassis", adapter=rsd_lib_utils.get_resource_identity
|
||||
)
|
||||
"""A reference to the chassis which contains this switch."""
|
||||
|
||||
managed_by = base.Field("ManagedBy", adapter=utils.get_members_identities)
|
||||
"""An array of references to the managers that manage this switch."""
|
||||
|
||||
|
||||
class ActionsField(base.CompositeField):
|
||||
reset = common.ResetActionField('#Switch.Reset')
|
||||
reset = common.ResetActionField("#Switch.Reset")
|
||||
"""The actions switch reset"""
|
||||
|
||||
|
||||
class Switch(base.ResourceBase):
|
||||
identity = base.Field('Id')
|
||||
"""The switch identity"""
|
||||
class Switch(rsd_lib_base.ResourceBase):
|
||||
"""Switch resource class
|
||||
|
||||
name = base.Field('Name')
|
||||
"""The switch name"""
|
||||
Switch contains properties describing a simple fabric switch.
|
||||
"""
|
||||
|
||||
description = base.Field('Description')
|
||||
"""The switch description"""
|
||||
switch_type = base.Field("SwitchType")
|
||||
"""The protocol being sent over this switch."""
|
||||
|
||||
switch_type = base.Field('SwitchType')
|
||||
"""The switch type"""
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
status = rsd_lib_common.StatusField('Status')
|
||||
"""The switch status"""
|
||||
manufacturer = base.Field("Manufacturer")
|
||||
"""This is the manufacturer of this switch."""
|
||||
|
||||
manufacturer = base.Field('Manufacturer')
|
||||
"""The switch manufacturer name"""
|
||||
|
||||
model = base.Field('Model')
|
||||
"""The switch model"""
|
||||
model = base.Field("Model")
|
||||
"""The product model number of this switch."""
|
||||
|
||||
sku = base.Field("SKU")
|
||||
"""The switch SKU"""
|
||||
"""This is the SKU for this switch."""
|
||||
|
||||
serial_number = base.Field('SerialNumber')
|
||||
"""The switch serial number"""
|
||||
serial_number = base.Field("SerialNumber")
|
||||
"""The serial number for this switch."""
|
||||
|
||||
part_number = base.Field('PartNumber')
|
||||
"""The switch part number"""
|
||||
part_number = base.Field("PartNumber")
|
||||
"""The part number for this switch."""
|
||||
|
||||
asset_tag = base.Field('AssetTag')
|
||||
"""The switch custom asset tag"""
|
||||
asset_tag = base.Field("AssetTag")
|
||||
"""The user assigned asset tag for this switch."""
|
||||
|
||||
domain_id = base.Field('DomainID')
|
||||
"""The switch domain id"""
|
||||
domain_id = base.Field("DomainID", adapter=rsd_lib_utils.num_or_none)
|
||||
"""The Domain ID for this switch."""
|
||||
|
||||
is_managed = base.Field('IsManaged')
|
||||
"""The switch managed state"""
|
||||
is_managed = base.Field("IsManaged", adapter=bool)
|
||||
"""This indicates whether the switch is in a managed or unmanaged state."""
|
||||
|
||||
total_switch_width = base.Field('TotalSwitchWidth',
|
||||
adapter=rsd_lib_utils.num_or_none)
|
||||
"""The switch total switch width"""
|
||||
total_switch_width = base.Field(
|
||||
"TotalSwitchWidth", adapter=rsd_lib_utils.num_or_none
|
||||
)
|
||||
"""The total number of lanes, phys, or other physical transport links that
|
||||
this switch contains.
|
||||
"""
|
||||
|
||||
indicator_led = base.Field('IndicatorLED')
|
||||
"""The switch indicator led"""
|
||||
indicator_led = base.Field("IndicatorLED")
|
||||
"""The state of the indicator LED, used to identify the switch."""
|
||||
|
||||
power_state = base.Field('PowerState')
|
||||
"""The switch power state"""
|
||||
power_state = base.Field("PowerState")
|
||||
"""This is the current power state of the switch."""
|
||||
|
||||
links = LinksField("Links")
|
||||
"""The switch links"""
|
||||
"""Contains references to other resources that are related to this
|
||||
resource.
|
||||
"""
|
||||
|
||||
redundancy = redundancy.RedundancyCollectionField("Redundancy")
|
||||
"""Redundancy information for the switches"""
|
||||
|
||||
actions = ActionsField("Actions")
|
||||
"""The switch actions"""
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Switch
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param identity: The identity of the Switch resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(Switch, self).__init__(connector, identity,
|
||||
redfish_version)
|
||||
|
||||
def _get_reset_action_element(self):
|
||||
reset_action = self.actions.reset
|
||||
if not reset_action:
|
||||
raise exceptions.MissingActionError(action='#Switch.Reset',
|
||||
resource=self._path)
|
||||
raise exceptions.MissingActionError(
|
||||
action="#Switch.Reset", resource=self._path
|
||||
)
|
||||
return reset_action
|
||||
|
||||
def get_allowed_reset_switch_values(self):
|
||||
@ -129,42 +134,43 @@ class Switch(base.ResourceBase):
|
||||
valid_resets = self.get_allowed_reset_switch_values()
|
||||
if value not in valid_resets:
|
||||
raise exceptions.InvalidParameterValueError(
|
||||
parameter='value', value=value, valid_values=valid_resets)
|
||||
parameter="value", value=value, valid_values=valid_resets
|
||||
)
|
||||
|
||||
target_uri = self._get_reset_action_element().target_uri
|
||||
|
||||
self._conn.post(target_uri, data={'ResetType': value})
|
||||
|
||||
def _get_ports_path(self):
|
||||
"""Helper function to find the network protocol path"""
|
||||
return utils.get_sub_resource_path_by(self, 'Ports')
|
||||
self._conn.post(target_uri, data={"ResetType": value})
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def ports(self):
|
||||
"""Property to provide reference to ` Ports` instance
|
||||
"""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.
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return port.PortCollection(
|
||||
self._conn, self._get_ports_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "Ports"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def log_services(self):
|
||||
"""Property to provide reference to `LogServiceCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return log_service.LogServiceCollection(
|
||||
self._conn,
|
||||
utils.get_sub_resource_path_by(self, "LogServices"),
|
||||
redfish_version=self.redfish_version,
|
||||
)
|
||||
|
||||
|
||||
class SwitchCollection(base.ResourceCollectionBase):
|
||||
|
||||
class SwitchCollection(rsd_lib_base.ResourceCollectionBase):
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return Switch
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing an Endpoint
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the Switch collection resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(SwitchCollection, self).__init__(connector, path,
|
||||
redfish_version)
|
||||
|
@ -18,64 +18,38 @@ import logging
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib import common as rsd_lib_common
|
||||
from rsd_lib.resources.v2_1.fabric import endpoint
|
||||
from rsd_lib import base as rsd_lib_base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ZoneLinksField(base.CompositeField):
|
||||
endpoint_identities = base.Field('Endpoints', default=[],
|
||||
adapter=utils.get_members_identities)
|
||||
"""An array of references to the endpoints
|
||||
that are contained in this zone
|
||||
class LinksField(base.CompositeField):
|
||||
|
||||
endpoints = base.Field("Endpoints", adapter=utils.get_members_identities)
|
||||
"""An array of references to the endpoints that are contained in this zone.
|
||||
"""
|
||||
|
||||
involved_switches = base.Field('InvolvedSwitches', default=[],
|
||||
adapter=utils.get_members_identities)
|
||||
"""An array of references to the switchs
|
||||
that are utilized in this zone
|
||||
involved_switches = base.Field(
|
||||
"InvolvedSwitches", adapter=utils.get_members_identities
|
||||
)
|
||||
"""An array of references to the switchs that are utilized in this zone."""
|
||||
|
||||
|
||||
class Zone(rsd_lib_base.ResourceBase):
|
||||
"""Zone resource class
|
||||
|
||||
Switch contains properties describing a simple fabric zone.
|
||||
"""
|
||||
|
||||
status = rsd_lib_base.StatusField("Status")
|
||||
"""This indicates the known state of the resource, such as if it is
|
||||
enabled.
|
||||
"""
|
||||
|
||||
class Zone(base.ResourceBase):
|
||||
description = base.Field('Description')
|
||||
"""The zone description"""
|
||||
|
||||
identity = base.Field('Id', required=True)
|
||||
"""The zone identity string"""
|
||||
|
||||
name = base.Field('Name')
|
||||
"""The zone name"""
|
||||
|
||||
links = ZoneLinksField('Links')
|
||||
"""The zone links"""
|
||||
|
||||
status = rsd_lib_common.StatusField('Status')
|
||||
"""The zone status"""
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Zone
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param identity: The identity of the Zone resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(Zone, self).__init__(connector, identity,
|
||||
redfish_version)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def endpoints(self):
|
||||
"""Return a list of Endpoints present in the Zone
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return [
|
||||
endpoint.Endpoint(self._conn, id_, self.redfish_version)
|
||||
for id_ in self.links.endpoint_identities]
|
||||
links = LinksField("Links")
|
||||
"""Contains references to other resources that are related to this
|
||||
resource.
|
||||
"""
|
||||
|
||||
def update(self, endpoints):
|
||||
"""Add or remove Endpoints from a Zone
|
||||
@ -85,24 +59,12 @@ class Zone(base.ResourceBase):
|
||||
:param endpoints: a full representation of Endpoints array
|
||||
"""
|
||||
data = {"Endpoints": []}
|
||||
data['Endpoints'] = [{'@odata.id': endpoint} for endpoint in endpoints]
|
||||
data["Endpoints"] = [{"@odata.id": endpoint} for endpoint in endpoints]
|
||||
|
||||
self._conn.patch(self.path, data=data)
|
||||
|
||||
|
||||
class ZoneCollection(base.ResourceCollectionBase):
|
||||
|
||||
class ZoneCollection(rsd_lib_base.ResourceCollectionBase):
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return Zone
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing a Zone Collection
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the Zone collection resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(ZoneCollection, self).__init__(connector, path,
|
||||
redfish_version)
|
||||
|
@ -27,11 +27,9 @@
|
||||
},
|
||||
"Redundancy": [],
|
||||
"Links": {
|
||||
"Chassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/PCIeSwitch1"
|
||||
}
|
||||
],
|
||||
"Chassis": {
|
||||
"@odata.id": "/redfish/v1/Chassis/PCIeSwitch1"
|
||||
},
|
||||
"ManagedBy": [],
|
||||
"Oem": {}
|
||||
},
|
||||
|
@ -22,87 +22,113 @@ from rsd_lib.resources.v2_1.fabric import endpoint
|
||||
|
||||
|
||||
class EndpointTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EndpointTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/endpoint.json',
|
||||
'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/endpoint.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.endpoint_inst = endpoint.Endpoint(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.endpoint_inst._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.endpoint_inst.redfish_version)
|
||||
self.assertEqual('The PCIe Physical function of an 850GB NVMe drive',
|
||||
self.endpoint_inst.description)
|
||||
self.assertEqual('NVMeDrivePF1', self.endpoint_inst.identity)
|
||||
self.assertEqual('NVMe Drive', self.endpoint_inst.name)
|
||||
self.assertEqual(1000, self.endpoint_inst.host_reservation_memory)
|
||||
self.assertEqual("1.0.2", self.endpoint_inst.redfish_version)
|
||||
self.assertEqual(
|
||||
"The PCIe Physical function of an 850GB NVMe drive",
|
||||
self.endpoint_inst.description,
|
||||
)
|
||||
self.assertEqual("NVMeDrivePF1", self.endpoint_inst.identity)
|
||||
self.assertEqual("NVMe Drive", self.endpoint_inst.name)
|
||||
self.assertEqual(
|
||||
1000, self.endpoint_inst.host_reservation_memory_bytes
|
||||
)
|
||||
self.assertEqual([], self.endpoint_inst.redundancy)
|
||||
self.assertEqual('UUID',
|
||||
self.endpoint_inst.identifiers[0].name_format)
|
||||
self.assertEqual('00000000-0000-0000-0000-000000000000',
|
||||
self.endpoint_inst.identifiers[0].name)
|
||||
self.assertEqual('Drive',
|
||||
self.endpoint_inst.connected_entities[0].entity_type)
|
||||
self.assertEqual('Target',
|
||||
self.endpoint_inst.connected_entities[0].entity_role)
|
||||
self.assertEqual('/redfish/v1/Chassis/PCIeSwitch1/Drives/Disk.Bay.0',
|
||||
self.endpoint_inst.connected_entities[0].entity_link)
|
||||
self.assertEqual(
|
||||
'UUID',
|
||||
self.endpoint_inst.connected_entities[0].
|
||||
identifiers[0].name_format)
|
||||
"UUID", self.endpoint_inst.identifiers[0].durable_name_format
|
||||
)
|
||||
self.assertEqual(
|
||||
'00000000-0000-0000-0000-000000000000',
|
||||
self.endpoint_inst.connected_entities[0].identifiers[0].name)
|
||||
self.assertEqual('Enabled', self.endpoint_inst.status.state)
|
||||
self.assertEqual('OK', self.endpoint_inst.status.health)
|
||||
self.assertEqual('OK', self.endpoint_inst.status.health_rollup)
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
self.endpoint_inst.identifiers[0].durable_name,
|
||||
)
|
||||
self.assertEqual(
|
||||
"Drive", self.endpoint_inst.connected_entities[0].entity_type
|
||||
)
|
||||
self.assertEqual(
|
||||
"Target", self.endpoint_inst.connected_entities[0].entity_role
|
||||
)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Chassis/PCIeSwitch1/Drives/Disk.Bay.0",
|
||||
self.endpoint_inst.connected_entities[0].entity_link,
|
||||
)
|
||||
self.assertEqual(
|
||||
"UUID",
|
||||
self.endpoint_inst.connected_entities[0]
|
||||
.identifiers[0]
|
||||
.durable_name_format,
|
||||
)
|
||||
self.assertEqual(
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
self.endpoint_inst.connected_entities[0]
|
||||
.identifiers[0]
|
||||
.durable_name,
|
||||
)
|
||||
self.assertEqual("Enabled", self.endpoint_inst.status.state)
|
||||
self.assertEqual("OK", self.endpoint_inst.status.health)
|
||||
self.assertEqual("OK", self.endpoint_inst.status.health_rollup)
|
||||
|
||||
|
||||
class EndpointCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EndpointCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "endpoint_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.endpoint_col = endpoint.EndpointCollection(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Endpoints',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.endpoint_col._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.endpoint_col.redfish_version)
|
||||
self.assertEqual('PCIe Endpoint Collection',
|
||||
self.endpoint_col.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1',
|
||||
'/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2',
|
||||
'/redfish/v1/Fabrics/PCIe/'
|
||||
'Endpoints/HostRootComplex1'),
|
||||
self.endpoint_col.members_identities)
|
||||
self.assertEqual("1.0.2", self.endpoint_col.redfish_version)
|
||||
self.assertEqual("PCIe Endpoint Collection", self.endpoint_col.name)
|
||||
self.assertEqual(
|
||||
(
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1",
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2",
|
||||
"/redfish/v1/Fabrics/PCIe/" "Endpoints/HostRootComplex1",
|
||||
),
|
||||
self.endpoint_col.members_identities,
|
||||
)
|
||||
|
||||
@mock.patch.object(endpoint, 'Endpoint', autospec=True)
|
||||
@mock.patch.object(endpoint, "Endpoint", autospec=True)
|
||||
def test_get_member(self, mock_endpoint):
|
||||
self.endpoint_col.get_member(
|
||||
'/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1')
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1"
|
||||
)
|
||||
mock_endpoint.assert_called_once_with(
|
||||
self.endpoint_col._conn,
|
||||
'/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1',
|
||||
redfish_version=self.endpoint_col.redfish_version)
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1",
|
||||
redfish_version=self.endpoint_col.redfish_version,
|
||||
)
|
||||
|
||||
@mock.patch.object(endpoint, 'Endpoint', autospec=True)
|
||||
@mock.patch.object(endpoint, "Endpoint", autospec=True)
|
||||
def test_get_members(self, mock_endpoint):
|
||||
members = self.endpoint_col.get_members()
|
||||
mock_endpoint.assert_called_with(
|
||||
self.endpoint_col._conn, '/redfish/v1/Fabrics/PCIe/Endpoints'
|
||||
'/HostRootComplex1',
|
||||
redfish_version=self.endpoint_col.redfish_version)
|
||||
self.endpoint_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints" "/HostRootComplex1",
|
||||
redfish_version=self.endpoint_col.redfish_version,
|
||||
)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(3, len(members))
|
||||
|
@ -16,7 +16,6 @@
|
||||
import json
|
||||
|
||||
import mock
|
||||
from sushy import exceptions
|
||||
import testtools
|
||||
|
||||
from rsd_lib.resources.v2_1.fabric import endpoint
|
||||
@ -26,209 +25,206 @@ from rsd_lib.resources.v2_1.fabric import zone
|
||||
|
||||
|
||||
class FabricTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FabricTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/fabric.json',
|
||||
'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/fabric.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.fabric_inst = fabric.Fabric(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe',
|
||||
redfish_version='1.0.2')
|
||||
self.conn, "/redfish/v1/Fabrics/PCIe", redfish_version="1.0.2"
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.fabric_inst._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.fabric_inst.redfish_version)
|
||||
self.assertEqual('PCIe Fabric', self.fabric_inst.description)
|
||||
self.assertEqual('PCIe', self.fabric_inst.identity)
|
||||
self.assertEqual('PCIe Fabric', self.fabric_inst.name)
|
||||
self.assertEqual('PCIe', self.fabric_inst.fabric_type)
|
||||
self.assertEqual("1.0.2", self.fabric_inst.redfish_version)
|
||||
self.assertEqual("PCIe Fabric", self.fabric_inst.description)
|
||||
self.assertEqual("PCIe", self.fabric_inst.identity)
|
||||
self.assertEqual("PCIe Fabric", self.fabric_inst.name)
|
||||
self.assertEqual("PCIe", self.fabric_inst.fabric_type)
|
||||
self.assertEqual(5, self.fabric_inst.max_zones)
|
||||
self.assertEqual('Enabled', self.fabric_inst.status.state)
|
||||
self.assertEqual('OK', self.fabric_inst.status.health)
|
||||
|
||||
def test__get_endpoint_collection_path(self):
|
||||
expected = '/redfish/v1/Fabrics/PCIe/Endpoints'
|
||||
result = self.fabric_inst._get_endpoint_collection_path()
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test__get_endpoint_collection_path_missing_attr(self):
|
||||
self.fabric_inst._json.pop('Endpoints')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Endpoints',
|
||||
self.fabric_inst._get_endpoint_collection_path)
|
||||
self.assertEqual("Enabled", self.fabric_inst.status.state)
|
||||
self.assertEqual("OK", self.fabric_inst.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "endpoint_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_endpoints = self.fabric_inst.endpoints
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_endpoints,
|
||||
endpoint.EndpointCollection)
|
||||
self.assertIsInstance(actual_endpoints, endpoint.EndpointCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_endpoints,
|
||||
self.fabric_inst.endpoints)
|
||||
self.assertIs(actual_endpoints, self.fabric_inst.endpoints)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_endpoints_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "endpoint_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.fabric_inst.endpoints,
|
||||
endpoint.EndpointCollection)
|
||||
self.assertIsInstance(
|
||||
self.fabric_inst.endpoints, endpoint.EndpointCollection
|
||||
)
|
||||
|
||||
# On refreshing the fabric instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabric.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabric.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "endpoint_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.fabric_inst.endpoints,
|
||||
endpoint.EndpointCollection)
|
||||
|
||||
def test__get_switch_collection_path_missing_attr(self):
|
||||
self.fabric_inst._json.pop('Switches')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Switches',
|
||||
self.fabric_inst._get_switch_collection_path)
|
||||
self.assertIsInstance(
|
||||
self.fabric_inst.endpoints, endpoint.EndpointCollection
|
||||
)
|
||||
|
||||
def test_switches(self):
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "switch_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
actual_switches = self.fabric_inst.switches
|
||||
self.assertIsInstance(actual_switches,
|
||||
switch.SwitchCollection)
|
||||
self.assertIsInstance(actual_switches, switch.SwitchCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
self.assertIs(actual_switches,
|
||||
self.fabric_inst.switches)
|
||||
self.assertIs(actual_switches, self.fabric_inst.switches)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_switches_on_refresh(self):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "switch_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.assertIsInstance(self.fabric_inst.switches,
|
||||
switch.SwitchCollection)
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabric.json', 'r') as f:
|
||||
self.assertIsInstance(
|
||||
self.fabric_inst.switches, switch.SwitchCollection
|
||||
)
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabric.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "switch_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.assertIsInstance(self.fabric_inst.switches,
|
||||
switch.SwitchCollection)
|
||||
|
||||
def test__get_zone_collection_path_missing_attr(self):
|
||||
self.fabric_inst._json.pop('Zones')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Zones',
|
||||
self.fabric_inst._get_zone_collection_path)
|
||||
self.assertIsInstance(
|
||||
self.fabric_inst.switches, switch.SwitchCollection
|
||||
)
|
||||
|
||||
def test_zones(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'zone_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "zone_collection.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_zones = self.fabric_inst.zones
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_zones,
|
||||
zone.ZoneCollection)
|
||||
self.assertIsInstance(actual_zones, zone.ZoneCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_zones,
|
||||
self.fabric_inst.zones)
|
||||
self.assertIs(actual_zones, self.fabric_inst.zones)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_zones_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'zone_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "zone_collection.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.fabric_inst.zones,
|
||||
zone.ZoneCollection)
|
||||
self.assertIsInstance(self.fabric_inst.zones, zone.ZoneCollection)
|
||||
|
||||
# On refreshing the fabric instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabric.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabric.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'zone_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "zone_collection.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.fabric_inst.zones,
|
||||
zone.ZoneCollection)
|
||||
self.assertIsInstance(self.fabric_inst.zones, zone.ZoneCollection)
|
||||
|
||||
|
||||
class FabricCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FabricCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabric_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabric_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.fabric_col = fabric.FabricCollection(
|
||||
self.conn, '/redfish/v1/Fabrics', redfish_version='1.0.2')
|
||||
self.conn, "/redfish/v1/Fabrics", redfish_version="1.0.2"
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.fabric_col._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.fabric_col.redfish_version)
|
||||
self.assertEqual('Fabric Collection',
|
||||
self.fabric_col.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe',),
|
||||
self.fabric_col.members_identities)
|
||||
self.assertEqual("1.0.2", self.fabric_col.redfish_version)
|
||||
self.assertEqual("Fabric Collection", self.fabric_col.name)
|
||||
self.assertEqual(
|
||||
("/redfish/v1/Fabrics/PCIe",), self.fabric_col.members_identities
|
||||
)
|
||||
|
||||
@mock.patch.object(fabric, 'Fabric', autospec=True)
|
||||
@mock.patch.object(fabric, "Fabric", autospec=True)
|
||||
def test_get_member(self, mock_fabric):
|
||||
self.fabric_col.get_member('/redfish/v1/Fabrics/PCIe')
|
||||
self.fabric_col.get_member("/redfish/v1/Fabrics/PCIe")
|
||||
mock_fabric.assert_called_once_with(
|
||||
self.fabric_col._conn, '/redfish/v1/Fabrics/PCIe',
|
||||
redfish_version=self.fabric_col.redfish_version)
|
||||
self.fabric_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe",
|
||||
redfish_version=self.fabric_col.redfish_version,
|
||||
)
|
||||
|
||||
@mock.patch.object(fabric, 'Fabric', autospec=True)
|
||||
@mock.patch.object(fabric, "Fabric", autospec=True)
|
||||
def test_get_members(self, mock_fabric):
|
||||
members = self.fabric_col.get_members()
|
||||
mock_fabric.assert_called_once_with(
|
||||
self.fabric_col._conn, '/redfish/v1/Fabrics/PCIe',
|
||||
redfish_version=self.fabric_col.redfish_version)
|
||||
self.fabric_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe",
|
||||
redfish_version=self.fabric_col.redfish_version,
|
||||
)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(1, len(members))
|
||||
|
@ -23,17 +23,19 @@ from rsd_lib.resources.v2_1.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_1/fabrics_port.json',
|
||||
'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/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')
|
||||
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()
|
||||
@ -48,40 +50,50 @@ class PortTestCase(testtools.TestCase):
|
||||
self.assertEqual(32, self.port_inst.current_speed_gbps)
|
||||
self.assertEqual(4, self.port_inst.width)
|
||||
self.assertEqual(64, self.port_inst.max_speed_gbps)
|
||||
self.assertEqual("/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1"
|
||||
"/Actions/PCIePort.Reset",
|
||||
self.port_inst.actions.reset.target_uri)
|
||||
self.assertEqual(["ForceOff", "ForceRestart", "ForceOn"],
|
||||
self.port_inst.actions.reset.allowed_values)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Endpoints/'
|
||||
'HostRootComplex1',),
|
||||
self.port_inst.links.associated_endpoints)
|
||||
self.assertEqual("#Intel.Oem.Port",
|
||||
self.port_inst.oem.intel_rackScale.odata_type)
|
||||
self.assertEqual(['XYZ1234567890'],
|
||||
self.port_inst.oem.intel_rackScale.pcie_connection_id)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1"
|
||||
"/Actions/PCIePort.Reset",
|
||||
self.port_inst.actions.reset.target_uri,
|
||||
)
|
||||
self.assertEqual(
|
||||
["ForceOff", "ForceRestart", "ForceOn"],
|
||||
self.port_inst.actions.reset.allowed_values,
|
||||
)
|
||||
self.assertEqual(
|
||||
("/redfish/v1/Fabrics/PCIe/Endpoints/" "HostRootComplex1",),
|
||||
self.port_inst.links.associated_endpoints,
|
||||
)
|
||||
self.assertEqual(
|
||||
["XYZ1234567890"],
|
||||
self.port_inst.oem.intel_rackscale.pc_ie_connection_id,
|
||||
)
|
||||
|
||||
def test__parse_attributes_missing_reset_target(self):
|
||||
self.port_inst.json['Actions']['#Port.Reset'].pop(
|
||||
'target')
|
||||
self.port_inst.json["Actions"]["#Port.Reset"].pop("target")
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError,
|
||||
'attribute Actions/#Port.Reset/target',
|
||||
self.port_inst._parse_attributes)
|
||||
"attribute Actions/#Port.Reset/target",
|
||||
self.port_inst._parse_attributes,
|
||||
)
|
||||
|
||||
def test_get__reset_action_element(self):
|
||||
value = self.port_inst._get_reset_action_element()
|
||||
self.assertEqual("/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/"
|
||||
"Actions/PCIePort.Reset",
|
||||
value.target_uri)
|
||||
self.assertEqual(["ForceOff", "ForceRestart", "ForceOn"],
|
||||
value.allowed_values)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/"
|
||||
"Actions/PCIePort.Reset",
|
||||
value.target_uri,
|
||||
)
|
||||
self.assertEqual(
|
||||
["ForceOff", "ForceRestart", "ForceOn"], value.allowed_values
|
||||
)
|
||||
|
||||
def test__get_reset_action_element_missing_reset_action(self):
|
||||
self.port_inst.actions.reset = None
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingActionError, 'action #Port.Reset',
|
||||
self.port_inst._get_reset_action_element)
|
||||
exceptions.MissingActionError,
|
||||
"action #Port.Reset",
|
||||
self.port_inst._get_reset_action_element,
|
||||
)
|
||||
|
||||
def test_get_allowed_reset_port_values(self):
|
||||
values = self.port_inst.get_allowed_reset_port_values()
|
||||
@ -90,57 +102,71 @@ class PortTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(values, list)
|
||||
|
||||
def test_reset_port(self):
|
||||
self.port_inst.reset_port('ForceOn')
|
||||
self.port_inst.reset_port("ForceOn")
|
||||
self.port_inst._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/Actions/'
|
||||
'PCIePort.Reset',
|
||||
data={'ResetType': 'ForceOn'})
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1/Actions/"
|
||||
"PCIePort.Reset",
|
||||
data={"ResetType": "ForceOn"},
|
||||
)
|
||||
|
||||
def test_reset_port_invalid_value(self):
|
||||
self.assertRaisesRegex(
|
||||
exceptions.InvalidParameterValueError,
|
||||
'"value" value "GracefulRestart" is invalid.',
|
||||
self.port_inst.reset_port, 'GracefulRestart')
|
||||
self.port_inst.reset_port,
|
||||
"GracefulRestart",
|
||||
)
|
||||
|
||||
|
||||
class PortCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(PortCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabrics_port_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/"
|
||||
"fabrics_port_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.port_col = port.PortCollection(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Switches/1/Ports',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.port_col._parse_attributes()
|
||||
self.assertEqual("PCIe Port Collection", self.port_col.name)
|
||||
self.assertEqual("1.0.2", self.port_col.redfish_version)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1',
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up2',
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Down1',
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Down2'),
|
||||
self.port_col.members_identities)
|
||||
self.assertEqual(
|
||||
(
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1",
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up2",
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Down1",
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Down2",
|
||||
),
|
||||
self.port_col.members_identities,
|
||||
)
|
||||
|
||||
@mock.patch.object(port, 'Port', autospec=True)
|
||||
@mock.patch.object(port, "Port", autospec=True)
|
||||
def test_get_member(self, mock_port):
|
||||
self.port_col.get_member(
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1')
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1"
|
||||
)
|
||||
mock_port.assert_called_once_with(
|
||||
self.port_col._conn,
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1',
|
||||
redfish_version=self.port_col.redfish_version)
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Ports/Up1",
|
||||
redfish_version=self.port_col.redfish_version,
|
||||
)
|
||||
|
||||
@mock.patch.object(port, 'Port', autospec=True)
|
||||
@mock.patch.object(port, "Port", autospec=True)
|
||||
def test_get_members(self, mock_port):
|
||||
members = self.port_col.get_members()
|
||||
mock_port.assert_called_with(
|
||||
self.port_col._conn, '/redfish/v1/Fabrics/PCIe/Switches/1/'
|
||||
'Ports/Down2',
|
||||
redfish_version='1.0.2')
|
||||
self.port_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/" "Ports/Down2",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(mock_port.call_count, 4)
|
||||
self.assertEqual(4, len(members))
|
||||
|
@ -24,65 +24,73 @@ from rsd_lib.resources.v2_1.fabric import switch
|
||||
|
||||
|
||||
class SwitchTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SwitchTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/switch.json',
|
||||
'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/switch.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.switch_inst = switch.Switch(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Switches/1',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.switch_inst._parse_attributes()
|
||||
self.assertEqual('1', self.switch_inst.identity)
|
||||
self.assertEqual('PCIe Switch', self.switch_inst.name)
|
||||
self.assertEqual('PCIe Switch', self.switch_inst.description)
|
||||
self.assertEqual('Enabled', self.switch_inst.status.state)
|
||||
self.assertEqual('OK', self.switch_inst.status.health)
|
||||
self.assertEqual('OK', self.switch_inst.status.health_rollup)
|
||||
self.assertEqual('Manufacturer Name', self.switch_inst.manufacturer)
|
||||
self.assertEqual('Model Name', self.switch_inst.model)
|
||||
self.assertEqual('SKU', self.switch_inst.sku)
|
||||
self.assertEqual('1234567890', self.switch_inst.serial_number)
|
||||
self.assertEqual('997', self.switch_inst.part_number)
|
||||
self.assertEqual('Customer Asset Tag', self.switch_inst.asset_tag)
|
||||
self.assertEqual("1", self.switch_inst.identity)
|
||||
self.assertEqual("PCIe Switch", self.switch_inst.name)
|
||||
self.assertEqual("PCIe Switch", self.switch_inst.description)
|
||||
self.assertEqual("Enabled", self.switch_inst.status.state)
|
||||
self.assertEqual("OK", self.switch_inst.status.health)
|
||||
self.assertEqual("OK", self.switch_inst.status.health_rollup)
|
||||
self.assertEqual("Manufacturer Name", self.switch_inst.manufacturer)
|
||||
self.assertEqual("Model Name", self.switch_inst.model)
|
||||
self.assertEqual("SKU", self.switch_inst.sku)
|
||||
self.assertEqual("1234567890", self.switch_inst.serial_number)
|
||||
self.assertEqual("997", self.switch_inst.part_number)
|
||||
self.assertEqual("Customer Asset Tag", self.switch_inst.asset_tag)
|
||||
self.assertEqual(1, self.switch_inst.domain_id)
|
||||
self.assertEqual(True, self.switch_inst.is_managed)
|
||||
self.assertEqual(97, self.switch_inst.total_switch_width)
|
||||
self.assertEqual(None, self.switch_inst.indicator_led)
|
||||
self.assertEqual('On', self.switch_inst.power_state)
|
||||
self.assertEqual(('/redfish/v1/Chassis/PCIeSwitch1',), self.
|
||||
switch_inst.
|
||||
links.chassis)
|
||||
self.assertEqual("/redfish/v1/Fabrics/PCIe/Switches/1/Actions/Switch."
|
||||
"Reset", self.switch_inst.actions.reset.target_uri)
|
||||
self.assertEqual(["GracefulRestart"], self.switch_inst.actions.
|
||||
reset.allowed_values)
|
||||
self.assertEqual("On", self.switch_inst.power_state)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Chassis/PCIeSwitch1", self.switch_inst.links.chassis
|
||||
)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Actions/Switch." "Reset",
|
||||
self.switch_inst.actions.reset.target_uri,
|
||||
)
|
||||
self.assertEqual(
|
||||
["GracefulRestart"], self.switch_inst.actions.reset.allowed_values
|
||||
)
|
||||
|
||||
def test__parse_attributes_missing_reset_target(self):
|
||||
self.switch_inst.json['Actions']['#Switch.Reset'].pop(
|
||||
'target')
|
||||
self.switch_inst.json["Actions"]["#Switch.Reset"].pop("target")
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError,
|
||||
'attribute Actions/#Switch.Reset/target',
|
||||
self.switch_inst._parse_attributes)
|
||||
"attribute Actions/#Switch.Reset/target",
|
||||
self.switch_inst._parse_attributes,
|
||||
)
|
||||
|
||||
def test_get__reset_action_element(self):
|
||||
value = self.switch_inst._get_reset_action_element()
|
||||
self.assertEqual("/redfish/v1/Fabrics/PCIe/Switches/1/Actions/"
|
||||
"Switch.Reset",
|
||||
value.target_uri)
|
||||
self.assertEqual(
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Actions/" "Switch.Reset",
|
||||
value.target_uri,
|
||||
)
|
||||
self.assertEqual(["GracefulRestart"], value.allowed_values)
|
||||
|
||||
def test__get_reset_action_element_missing_reset_action(self):
|
||||
self.switch_inst.actions.reset = None
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingActionError, 'action #Switch.Reset',
|
||||
self.switch_inst._get_reset_action_element)
|
||||
exceptions.MissingActionError,
|
||||
"action #Switch.Reset",
|
||||
self.switch_inst._get_reset_action_element,
|
||||
)
|
||||
|
||||
def test_get_allowed_reset_switch_values(self):
|
||||
values = self.switch_inst.get_allowed_reset_switch_values()
|
||||
@ -91,102 +99,106 @@ class SwitchTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(values, list)
|
||||
|
||||
def test_reset_node(self):
|
||||
self.switch_inst.reset_switch('GracefulRestart')
|
||||
self.switch_inst.reset_switch("GracefulRestart")
|
||||
self.switch_inst._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1/Actions/Switch.Reset',
|
||||
data={'ResetType': 'GracefulRestart'})
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1/Actions/Switch.Reset",
|
||||
data={"ResetType": "GracefulRestart"},
|
||||
)
|
||||
|
||||
def test_reset_node_invalid_value(self):
|
||||
self.assertRaisesRegex(
|
||||
exceptions.InvalidParameterValueError,
|
||||
'"value" value "ForceRestart" is invalid.',
|
||||
self.switch_inst.reset_switch, 'ForceRestart')
|
||||
|
||||
def test__get_ports_path(self):
|
||||
expected = '/redfish/v1/Fabrics/PCIe/Switches/1/Ports'
|
||||
result = self.switch_inst._get_ports_path()
|
||||
self.assertEqual(expected, result)
|
||||
self.switch_inst.reset_switch,
|
||||
"ForceRestart",
|
||||
)
|
||||
|
||||
def test_ports(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabrics_port.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabrics_port.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_ports = self.switch_inst.ports
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_ports,
|
||||
port.PortCollection)
|
||||
self.assertIsInstance(actual_ports, port.PortCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_ports,
|
||||
self.switch_inst.ports)
|
||||
self.assertIs(actual_ports, self.switch_inst.ports)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_ports_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabrics_port.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabrics_port.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.switch_inst.ports,
|
||||
port.PortCollection)
|
||||
self.assertIsInstance(self.switch_inst.ports, port.PortCollection)
|
||||
|
||||
# On refreshing the manager instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "switch.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.switch_inst.invalidate()
|
||||
self.switch_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'fabrics_port.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "fabrics_port.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.switch_inst.ports,
|
||||
port.PortCollection)
|
||||
self.assertIsInstance(self.switch_inst.ports, port.PortCollection)
|
||||
|
||||
|
||||
class SwitchCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SwitchCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "switch_collection.json",
|
||||
"r",
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.switch_col = switch.SwitchCollection(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Switches',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Switches",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.switch_col._parse_attributes()
|
||||
self.assertEqual('Switch Collection',
|
||||
self.switch_col.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Switches/1',),
|
||||
self.switch_col.members_identities)
|
||||
self.assertEqual("Switch Collection", self.switch_col.name)
|
||||
self.assertEqual(
|
||||
("/redfish/v1/Fabrics/PCIe/Switches/1",),
|
||||
self.switch_col.members_identities,
|
||||
)
|
||||
|
||||
@mock.patch.object(switch, 'Switch', autospec=True)
|
||||
@mock.patch.object(switch, "Switch", autospec=True)
|
||||
def test_get_member(self, mock_switch):
|
||||
self.switch_col.get_member(
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1')
|
||||
self.switch_col.get_member("/redfish/v1/Fabrics/PCIe/Switches/1")
|
||||
mock_switch.assert_called_once_with(
|
||||
self.switch_col._conn,
|
||||
'/redfish/v1/Fabrics/PCIe/Switches/1',
|
||||
redfish_version=self.switch_col.redfish_version)
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1",
|
||||
redfish_version=self.switch_col.redfish_version,
|
||||
)
|
||||
|
||||
@mock.patch.object(switch, 'Switch', autospec=True)
|
||||
@mock.patch.object(switch, "Switch", autospec=True)
|
||||
def test_get_members(self, mock_switch):
|
||||
members = self.switch_col.get_members()
|
||||
mock_switch.assert_called_with(
|
||||
self.switch_col._conn, '/redfish/v1/Fabrics/PCIe/Switches/1',
|
||||
redfish_version='1.0.2')
|
||||
self.switch_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Switches/1",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(1, len(members))
|
||||
|
@ -22,134 +22,120 @@ from rsd_lib.resources.v2_1.fabric import zone
|
||||
|
||||
|
||||
class ZoneTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ZoneTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/zone.json',
|
||||
'r') as f:
|
||||
with open("rsd_lib/tests/unit/json_samples/v2_1/zone.json", "r") as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.zone_inst = zone.Zone(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Zones/1',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/1",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.zone_inst._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.zone_inst.redfish_version)
|
||||
self.assertEqual('PCIe Zone 1',
|
||||
self.zone_inst.description)
|
||||
self.assertEqual('1', self.zone_inst.identity)
|
||||
self.assertEqual('PCIe Zone 1', self.zone_inst.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/'
|
||||
'Endpoints/HostRootComplex1',
|
||||
'/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2'),
|
||||
self.zone_inst.links.endpoint_identities)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Switches/1',),
|
||||
self.zone_inst.links.involved_switches)
|
||||
self.assertEqual('Enabled', self.zone_inst.status.state)
|
||||
self.assertEqual('OK', self.zone_inst.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_endpoints = self.zone_inst.endpoints
|
||||
# | THEN |
|
||||
self.assertEqual('NVMeDrivePF1', actual_endpoints[0].identity)
|
||||
self.assertEqual(2, len(actual_endpoints))
|
||||
self.conn.get.return_value.json.assert_called_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_endpoints,
|
||||
self.zone_inst.endpoints)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_endpoints_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual('NVMeDrivePF1', self.zone_inst.endpoints[0].identity)
|
||||
self.assertEqual(2, len(self.zone_inst.endpoints))
|
||||
|
||||
# On refreshing the fabric instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'zone.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.zone_inst.invalidate()
|
||||
self.zone_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'endpoint.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual('NVMeDrivePF1', self.zone_inst.endpoints[0].identity)
|
||||
self.assertEqual(2, len(self.zone_inst.endpoints))
|
||||
self.assertEqual("1.0.2", self.zone_inst.redfish_version)
|
||||
self.assertEqual("PCIe Zone 1", self.zone_inst.description)
|
||||
self.assertEqual("1", self.zone_inst.identity)
|
||||
self.assertEqual("PCIe Zone 1", self.zone_inst.name)
|
||||
self.assertEqual(
|
||||
(
|
||||
"/redfish/v1/Fabrics/PCIe/" "Endpoints/HostRootComplex1",
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2",
|
||||
),
|
||||
self.zone_inst.links.endpoints,
|
||||
)
|
||||
self.assertEqual(
|
||||
("/redfish/v1/Fabrics/PCIe/Switches/1",),
|
||||
self.zone_inst.links.involved_switches,
|
||||
)
|
||||
self.assertEqual("Enabled", self.zone_inst.status.state)
|
||||
self.assertEqual("OK", self.zone_inst.status.health)
|
||||
|
||||
def test_update(self):
|
||||
self.zone_inst.update(
|
||||
['/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1'])
|
||||
["/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF1"]
|
||||
)
|
||||
self.zone_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/PCIe/Zones/1',
|
||||
data={"Endpoints": [{"@odata.id": "/redfish/v1/Fabrics/PCIe/"
|
||||
"Endpoints/NVMeDrivePF1"}]})
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/1",
|
||||
data={
|
||||
"Endpoints": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Fabrics/PCIe/"
|
||||
"Endpoints/NVMeDrivePF1"
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
self.zone_inst._conn.patch.reset_mock()
|
||||
self.zone_inst.update(
|
||||
['/redfish/v1/Fabrics/PCIe/Endpoints/HostRootComplex1',
|
||||
'/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2'])
|
||||
[
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/HostRootComplex1",
|
||||
"/redfish/v1/Fabrics/PCIe/Endpoints/NVMeDrivePF2",
|
||||
]
|
||||
)
|
||||
self.zone_inst._conn.patch.assert_called_once_with(
|
||||
'/redfish/v1/Fabrics/PCIe/Zones/1',
|
||||
data={"Endpoints":
|
||||
[{"@odata.id": "/redfish/v1/Fabrics/PCIe/Endpoints/"
|
||||
"HostRootComplex1"},
|
||||
{"@odata.id": "/redfish/v1/Fabrics/PCIe/Endpoints/"
|
||||
"NVMeDrivePF2"}]})
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/1",
|
||||
data={
|
||||
"Endpoints": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Fabrics/PCIe/Endpoints/"
|
||||
"HostRootComplex1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Fabrics/PCIe/Endpoints/"
|
||||
"NVMeDrivePF2"
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class ZoneCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ZoneCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'zone_collection.json', 'r') as f:
|
||||
with open(
|
||||
"rsd_lib/tests/unit/json_samples/v2_1/" "zone_collection.json", "r"
|
||||
) as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.zone_col = zone.ZoneCollection(
|
||||
self.conn, '/redfish/v1/Fabrics/PCIe/Zones',
|
||||
redfish_version='1.0.2')
|
||||
self.conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Zones",
|
||||
redfish_version="1.0.2",
|
||||
)
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.zone_col._parse_attributes()
|
||||
self.assertEqual('1.0.2', self.zone_col.redfish_version)
|
||||
self.assertEqual('PCIe Zone Collection',
|
||||
self.zone_col.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/PCIe/Zones/1',
|
||||
'/redfish/v1/Fabrics/PCIe/Zones/2'),
|
||||
self.zone_col.members_identities)
|
||||
self.assertEqual("1.0.2", self.zone_col.redfish_version)
|
||||
self.assertEqual("PCIe Zone Collection", self.zone_col.name)
|
||||
self.assertEqual(
|
||||
(
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/1",
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/2",
|
||||
),
|
||||
self.zone_col.members_identities,
|
||||
)
|
||||
|
||||
@mock.patch.object(zone, 'Zone', autospec=True)
|
||||
@mock.patch.object(zone, "Zone", autospec=True)
|
||||
def test_get_member(self, mock_zone):
|
||||
self.zone_col.get_member('/redfish/v1/Fabrics/PCIe/Zones/1')
|
||||
self.zone_col.get_member("/redfish/v1/Fabrics/PCIe/Zones/1")
|
||||
mock_zone.assert_called_once_with(
|
||||
self.zone_col._conn, '/redfish/v1/Fabrics/PCIe/Zones/1',
|
||||
redfish_version=self.zone_col.redfish_version)
|
||||
self.zone_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/1",
|
||||
redfish_version=self.zone_col.redfish_version,
|
||||
)
|
||||
|
||||
@mock.patch.object(zone, 'Zone', autospec=True)
|
||||
@mock.patch.object(zone, "Zone", autospec=True)
|
||||
def test_get_members(self, mock_zone):
|
||||
members = self.zone_col.get_members()
|
||||
mock_zone.assert_called_with(
|
||||
self.zone_col._conn, '/redfish/v1/Fabrics/PCIe/Zones/2',
|
||||
redfish_version=self.zone_col.redfish_version)
|
||||
self.zone_col._conn,
|
||||
"/redfish/v1/Fabrics/PCIe/Zones/2",
|
||||
redfish_version=self.zone_col.redfish_version,
|
||||
)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(2, len(members))
|
||||
|
@ -44,56 +44,10 @@ class ZoneTestCase(testtools.TestCase):
|
||||
self.assertEqual('Zone 1', self.zone_inst.name)
|
||||
self.assertEqual(('/redfish/v1/Fabrics/NVMeoE/Endpoints/1',
|
||||
'/redfish/v1/Fabrics/NVMeoE/Endpoints/2'),
|
||||
self.zone_inst.links.endpoint_identities)
|
||||
self.zone_inst.links.endpoints)
|
||||
self.assertEqual('Enabled', self.zone_inst.status.state)
|
||||
self.assertEqual('OK', self.zone_inst.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'endpoint_1.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_endpoints = self.zone_inst.endpoints
|
||||
# | THEN |
|
||||
self.assertEqual('1', actual_endpoints[0].identity)
|
||||
self.assertEqual(2, len(actual_endpoints))
|
||||
self.conn.get.return_value.json.assert_called_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_endpoints,
|
||||
self.zone_inst.endpoints)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_endpoints_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'endpoint_1.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual('1', self.zone_inst.endpoints[0].identity)
|
||||
self.assertEqual(2, len(self.zone_inst.endpoints))
|
||||
|
||||
# On refreshing the fabric instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'zone.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.zone_inst.invalidate()
|
||||
self.zone_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'endpoint_1.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertEqual('1', self.zone_inst.endpoints[0].identity)
|
||||
self.assertEqual(2, len(self.zone_inst.endpoints))
|
||||
|
||||
def test_update(self):
|
||||
self.zone_inst.update(
|
||||
['/redfish/v1/Fabrics/NVMeoE/Endpoints/1'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user