Introduce `cache_it
and
cache_clear
`
It use the new method ``cache_it`` and ``cache_clear`` in sushy 1.7.0 to cache nested resource property methods. Change-Id: I684d5d2447e467a7f3ae4fc4fdc22804cd12ef71
This commit is contained in:
@@ -13,11 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import acl_rule
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
class ACL(base.ResourceBase):
|
||||
@@ -34,9 +33,6 @@ class ACL(base.ResourceBase):
|
||||
oem = base.Field('Oem')
|
||||
"""The acl oem info"""
|
||||
|
||||
_rules = None # ref to ACLRuleCollection instance
|
||||
"""The acl rules"""
|
||||
|
||||
links = base.Field('Links')
|
||||
"""The acl links"""
|
||||
|
||||
@@ -52,28 +48,19 @@ class ACL(base.ResourceBase):
|
||||
|
||||
def _get_acl_rule_collection_path(self):
|
||||
"""Helper function to find the RuleCollection path"""
|
||||
rule_col = self.json.get('Rules')
|
||||
if not rule_col:
|
||||
raise exceptions.MissingAttributeError(attribute='ACLRules',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(rule_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Rules')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def rules(self):
|
||||
"""Property to provide reference to `RuleCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._rules is None:
|
||||
self._rules = acl_rule.ACLRuleCollection(
|
||||
self._conn, self._get_acl_rule_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
return self._rules
|
||||
|
||||
def refresh(self):
|
||||
super(ACL, self).refresh()
|
||||
self._rules = None
|
||||
return acl_rule.ACLRuleCollection(
|
||||
self._conn, self._get_acl_rule_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class ACLCollection(base.ResourceCollectionBase):
|
||||
|
@@ -15,7 +15,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
@@ -82,12 +81,6 @@ class EthernetSwitch(base.ResourceBase):
|
||||
status = StatusField('Status')
|
||||
"""The ethernet switch status"""
|
||||
|
||||
_acls = None # ref to ACLCollection instance
|
||||
"""The ethernet switch ACLs"""
|
||||
|
||||
_ports = None # ref to PortCollection instance
|
||||
"""The ethernet switch ports"""
|
||||
|
||||
links = LinksField('Links')
|
||||
"""The links to ethernet switch"""
|
||||
|
||||
@@ -105,53 +98,35 @@ class EthernetSwitch(base.ResourceBase):
|
||||
|
||||
def _get_port_collection_path(self):
|
||||
"""Helper function to find the PortCollection path"""
|
||||
port_col = self.json.get('Ports')
|
||||
if not port_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Ports',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(port_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Ports')
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._ports is None:
|
||||
self._ports = port.PortCollection(
|
||||
self._conn, self._get_port_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._ports
|
||||
return port.PortCollection(
|
||||
self._conn, self._get_port_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_acl_collection_path(self):
|
||||
"""Helper function to find the ACLCollection path"""
|
||||
acl_col = self.json.get('ACLs')
|
||||
if not acl_col:
|
||||
raise exceptions.MissingAttributeError(attribute='ACLs',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(acl_col)
|
||||
return utils.get_sub_resource_path_by(self, 'ACLs')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def acls(self):
|
||||
"""Property to provide reference to `ACLCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._acls is None:
|
||||
self._acls = acl.ACLCollection(
|
||||
self._conn, self._get_acl_collection_path(),
|
||||
redfish_version=self.redfish_version
|
||||
)
|
||||
|
||||
return self._acls
|
||||
|
||||
def refresh(self):
|
||||
super(EthernetSwitch, self).refresh()
|
||||
self._ports = None
|
||||
self._acls = None
|
||||
return acl.ACLCollection(
|
||||
self._conn, self._get_acl_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class EthernetSwitchCollection(base.ResourceCollectionBase):
|
||||
|
@@ -15,7 +15,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
@@ -147,12 +146,6 @@ class Port(base.ResourceBase):
|
||||
port_type = base.Field('PortType')
|
||||
"""The port type"""
|
||||
|
||||
_vlans = None # ref to VLANCollection instance
|
||||
"""The port vlans"""
|
||||
|
||||
_static_macs = None # ref to StaticMACCollection instance
|
||||
"""The port static macs"""
|
||||
|
||||
links = LinksField('Links')
|
||||
"""The port links"""
|
||||
|
||||
@@ -168,52 +161,35 @@ class Port(base.ResourceBase):
|
||||
|
||||
def _get_static_mac_collection_path(self):
|
||||
"""Helper function to find the StaticMACCollection path"""
|
||||
static_mac_col = self.json.get('StaticMACs')
|
||||
if not static_mac_col:
|
||||
raise exceptions.MissingAttributeError(attribute='StaticMAC',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(static_mac_col)
|
||||
return utils.get_sub_resource_path_by(self, 'StaticMACs')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def static_macs(self):
|
||||
"""Property to provide reference to `StaticMACollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._static_macs is None:
|
||||
self._static_macs = static_mac.StaticMACCollection(
|
||||
self._conn, self._get_static_mac_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._static_macs
|
||||
return static_mac.StaticMACCollection(
|
||||
self._conn, self._get_static_mac_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_vlan_collection_path(self):
|
||||
"""Helper function to find the VLANCollection path"""
|
||||
vlan_col = self.json.get('VLANs')
|
||||
if not vlan_col:
|
||||
raise exceptions.MissingAttributeError(attribute='VLAN',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(vlan_col)
|
||||
return utils.get_sub_resource_path_by(self, 'VLANs')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def vlans(self):
|
||||
"""Property to provide reference to `VLANCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._vlans is None:
|
||||
self._vlans = vlan.VLANCollection(
|
||||
self._conn, self._get_vlan_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._vlans
|
||||
|
||||
def refresh(self):
|
||||
super(Port, self).refresh()
|
||||
self._static_macs = None
|
||||
self._vlans = None
|
||||
return vlan.VLANCollection(
|
||||
self._conn, self._get_vlan_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class PortCollection(base.ResourceCollectionBase):
|
||||
|
@@ -15,13 +15,12 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
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__)
|
||||
|
||||
@@ -50,12 +49,6 @@ class Fabric(base.ResourceBase):
|
||||
|
||||
status = StatusField('Status')
|
||||
|
||||
_endpoints = None # ref to EndpointCollection instance
|
||||
|
||||
_switches = None # ref to SwitchCollection instance
|
||||
|
||||
_zones = None # ref to ZoneCollection instance
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Fabric
|
||||
|
||||
@@ -69,75 +62,51 @@ class Fabric(base.ResourceBase):
|
||||
|
||||
def _get_endpoint_collection_path(self):
|
||||
"""Helper function to find the EndpointCollection path"""
|
||||
endpoint_col = self.json.get('Endpoints')
|
||||
if not endpoint_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Endpoints',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(endpoint_col)
|
||||
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.
|
||||
"""
|
||||
if self._endpoints is None:
|
||||
self._endpoints = endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._endpoints
|
||||
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"""
|
||||
switch_col = self.json.get('Switches')
|
||||
if not switch_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Switches',
|
||||
resource=self._path)
|
||||
return switch_col.get('@odata.id')
|
||||
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.
|
||||
"""
|
||||
if self._switches is None:
|
||||
self._switches = switch.SwitchCollection(
|
||||
self._conn, self._get_switch_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._switches
|
||||
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"""
|
||||
zone_col = self.json.get('Zones')
|
||||
if not zone_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Zones',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(zone_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Zones')
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._zones is None:
|
||||
self._zones = zone.ZoneCollection(
|
||||
self._conn, self._get_zone_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._zones
|
||||
|
||||
def refresh(self):
|
||||
super(Fabric, self).refresh()
|
||||
self._endpoints = None
|
||||
self._zones = None
|
||||
self._switches = None
|
||||
return zone.ZoneCollection(
|
||||
self._conn, self._get_zone_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class FabricCollection(base.ResourceCollectionBase):
|
||||
|
@@ -50,8 +50,6 @@ class Zone(base.ResourceBase):
|
||||
status = StatusField('Status')
|
||||
"""The zone status"""
|
||||
|
||||
_endpoints = None # ref to contained endpoints
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Zone
|
||||
|
||||
@@ -64,22 +62,16 @@ class Zone(base.ResourceBase):
|
||||
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.
|
||||
"""
|
||||
if self._endpoints is None:
|
||||
self._endpoints = [
|
||||
endpoint.Endpoint(self._conn, id_, self.redfish_version)
|
||||
for id_ in self.links.endpoint_identities]
|
||||
|
||||
return self._endpoints
|
||||
|
||||
def refresh(self):
|
||||
super(Zone, self).refresh()
|
||||
self._endpoints = None
|
||||
return [
|
||||
endpoint.Endpoint(self._conn, id_, self.redfish_version)
|
||||
for id_ in self.links.endpoint_identities]
|
||||
|
||||
def update(self, endpoints):
|
||||
"""Add or remove Endpoints from a Zone
|
||||
|
@@ -173,8 +173,6 @@ class Node(base.ResourceBase):
|
||||
links = LinksField('Links')
|
||||
"""These links to related components of this composed node"""
|
||||
|
||||
_system = None # ref to System instance
|
||||
|
||||
_actions = NodeActionsField('Actions', required=True)
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
@@ -305,24 +303,20 @@ class Node(base.ResourceBase):
|
||||
|
||||
def _get_system_path(self):
|
||||
"""Helper function to find the System path"""
|
||||
system_col = self.json.get('Links').get('ComputerSystem')
|
||||
if not system_col:
|
||||
raise exceptions.MissingAttributeError(attribute='System',
|
||||
resource=self._path)
|
||||
return system_col.get('@odata.id')
|
||||
return utils.get_sub_resource_path_by(
|
||||
self, ['Links', 'ComputerSystem'])
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def system(self):
|
||||
"""Property to provide reference to `System` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._system is None:
|
||||
self._system = system.System(self._conn, self._get_system_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._system
|
||||
return system.System(
|
||||
self._conn, self._get_system_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_attach_endpoint_action_element(self):
|
||||
attach_endpoint_action = self._actions.attach_endpoint
|
||||
@@ -411,10 +405,6 @@ class Node(base.ResourceBase):
|
||||
"""
|
||||
self._conn.delete(self.path)
|
||||
|
||||
def refresh(self):
|
||||
super(Node, self).refresh()
|
||||
self._system = None
|
||||
|
||||
|
||||
class NodeCollection(base.ResourceCollectionBase):
|
||||
|
||||
|
@@ -15,8 +15,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.storage_service import logical_drive
|
||||
from rsd_lib.resources.v2_1.storage_service import physical_drive
|
||||
@@ -45,12 +45,6 @@ class StorageService(base.ResourceBase):
|
||||
status = StatusField('Status')
|
||||
"""The storage service status"""
|
||||
|
||||
_logical_drives = None # ref to LogicalDriveCollection instance
|
||||
|
||||
_physical_drives = None # ref to PhysicalDrivesCollection instance
|
||||
|
||||
_remote_targets = None # ref to RemoteTargetCollection instance
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a StorageService
|
||||
|
||||
@@ -64,75 +58,51 @@ class StorageService(base.ResourceBase):
|
||||
|
||||
def _get_logical_drive_collection_path(self):
|
||||
"""Helper function to find the LogicalDriveCollection path"""
|
||||
logical_drive_col = self.json.get('LogicalDrives')
|
||||
if not logical_drive_col:
|
||||
raise exceptions.MissingAttributeError(attribute='LogicalDrives',
|
||||
resource=self._path)
|
||||
return logical_drive_col.get('@odata.id')
|
||||
return utils.get_sub_resource_path_by(self, 'LogicalDrives')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def logical_drives(self):
|
||||
"""Property to provide reference to `LogicalDriveCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._logical_drives is None:
|
||||
self._logical_drives = logical_drive.LogicalDriveCollection(
|
||||
self._conn, self._get_logical_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._logical_drives
|
||||
return logical_drive.LogicalDriveCollection(
|
||||
self._conn, self._get_logical_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_physical_drive_collection_path(self):
|
||||
"""Helper function to find the PhysicalDriveCollection path"""
|
||||
physical_drive_col = self.json.get('Drives')
|
||||
if not physical_drive_col:
|
||||
raise exceptions.MissingAttributeError(attribute='PhysicalDrives',
|
||||
resource=self._path)
|
||||
return physical_drive_col.get('@odata.id')
|
||||
return utils.get_sub_resource_path_by(self, 'Drives')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def physical_drives(self):
|
||||
"""Property to provide reference to `PhysicalDriveCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._physical_drives is None:
|
||||
self._physical_drives = physical_drive.PhysicalDriveCollection(
|
||||
self._conn, self._get_physical_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._physical_drives
|
||||
return physical_drive.PhysicalDriveCollection(
|
||||
self._conn, self._get_physical_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_remote_target_collection_path(self):
|
||||
"""Helper function to find the RemoteTargetCollection path"""
|
||||
remote_target_col = self.json.get('RemoteTargets')
|
||||
if not remote_target_col:
|
||||
raise exceptions.MissingAttributeError(attribute='RemoteTargets',
|
||||
resource=self._path)
|
||||
return remote_target_col.get('@odata.id')
|
||||
return utils.get_sub_resource_path_by(self, 'RemoteTargets')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def remote_targets(self):
|
||||
"""Property to provide reference to `RemoteTargetCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._remote_targets is None:
|
||||
self._remote_targets = remote_target.RemoteTargetCollection(
|
||||
self._conn, self._get_remote_target_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._remote_targets
|
||||
|
||||
def refresh(self):
|
||||
super(StorageService, self).refresh()
|
||||
self._logical_drives = None
|
||||
self._physical_drives = None
|
||||
self._remote_targets = None
|
||||
return remote_target.RemoteTargetCollection(
|
||||
self._conn, self._get_remote_target_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class StorageServiceCollection(base.ResourceCollectionBase):
|
||||
|
@@ -13,96 +13,63 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources.system import system
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.system import memory
|
||||
from rsd_lib.resources.v2_1.system import network_interface
|
||||
from rsd_lib.resources.v2_1.system import storage_subsystem
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class System(system.System):
|
||||
|
||||
_memory = None # ref to System memory collection instance
|
||||
_storage_subsystem = None # ref to storage subsystem collection instance
|
||||
_network_interface = None # ref to network interface collection instance
|
||||
|
||||
def _get_memory_collection_path(self):
|
||||
"""Helper function to find the memory path"""
|
||||
system_col = self.json.get('Memory')
|
||||
if not system_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Memory',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(system_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Memory')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def memory(self):
|
||||
"""Property to provide reference to `Metrics` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._memory is None:
|
||||
self._memory = memory.MemoryCollection(
|
||||
self._conn, self._get_memory_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._memory
|
||||
return memory.MemoryCollection(
|
||||
self._conn, self._get_memory_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_storage_subsystem_collection_path(self):
|
||||
"""Helper function to find the storage subsystem path"""
|
||||
storage_subsystem_col = self.json.get('Storage')
|
||||
if not storage_subsystem_col:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='StorageSubsystem',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(storage_subsystem_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Storage')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def storage_subsystem(self):
|
||||
"""Property to provide reference to `StorageSubsystem` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._storage_subsystem is None:
|
||||
self._storage_subsystem = storage_subsystem.\
|
||||
StorageSubsystemCollection(
|
||||
self._conn, self._get_storage_subsystem_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
return self._storage_subsystem
|
||||
return storage_subsystem.StorageSubsystemCollection(
|
||||
self._conn, self._get_storage_subsystem_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_network_interface_collection_path(self):
|
||||
"""Helper function to find the network interface path"""
|
||||
network_interface_col = self.json.get('EthernetInterfaces')
|
||||
if not network_interface_col:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='NetworkInterface',
|
||||
resource=self._path
|
||||
)
|
||||
return utils.get_resource_identity(network_interface_col)
|
||||
return utils.get_sub_resource_path_by(self, 'EthernetInterfaces')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def network_interface(self):
|
||||
"""Property to provide reference to `NetworkInterface` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._network_interface is None:
|
||||
self._network_interface = network_interface.\
|
||||
NetworkInterfaceCollection(
|
||||
self._conn, self._get_network_interface_collection_path(),
|
||||
redfish_version=self.redfish_version
|
||||
)
|
||||
return self._network_interface
|
||||
|
||||
def refresh(self):
|
||||
super(System, self).refresh()
|
||||
self._memory = None
|
||||
self._storage_subsystem = None
|
||||
self._network_interface = None
|
||||
return network_interface.NetworkInterfaceCollection(
|
||||
self._conn, self._get_network_interface_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class SystemCollection(system.SystemCollection):
|
||||
|
@@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import ethernet_switch \
|
||||
as v2_1_ethernet_switch
|
||||
@@ -23,18 +24,16 @@ from rsd_lib.resources.v2_2.ethernet_switch import port
|
||||
class EthernetSwitch(v2_1_ethernet_switch.EthernetSwitch):
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._ports is None:
|
||||
self._ports = port.PortCollection(
|
||||
self._conn, self._get_port_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._ports
|
||||
return port.PortCollection(
|
||||
self._conn, self._get_port_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class EthernetSwitchCollection(base.ResourceCollectionBase):
|
||||
|
@@ -13,44 +13,30 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import port as v2_1_port
|
||||
from rsd_lib.resources.v2_2.ethernet_switch import port_metrics
|
||||
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class Port(v2_1_port.Port):
|
||||
|
||||
_metrics = None # ref to Port metrics instance
|
||||
|
||||
def _get_metrics_path(self):
|
||||
"""Helper function to find the Port metrics path"""
|
||||
metrics = self.json.get('Metrics')
|
||||
if not metrics:
|
||||
raise exceptions.MissingAttributeError(attribute='Metrics',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(metrics)
|
||||
return utils.get_sub_resource_path_by(self, 'Metrics')
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._metrics is None:
|
||||
self._metrics = port_metrics.PortMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._metrics
|
||||
|
||||
def refresh(self):
|
||||
super(Port, self).refresh()
|
||||
self._metrics = None
|
||||
return port_metrics.PortMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class PortCollection(base.ResourceCollectionBase):
|
||||
|
@@ -13,45 +13,32 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.system import memory
|
||||
from rsd_lib.resources.v2_2.system import memory_metrics
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class Memory(memory.Memory):
|
||||
|
||||
max_tdp_milliwatts = base.Field('MaxTDPMilliWatts')
|
||||
|
||||
_metrics = None # ref to System instance
|
||||
|
||||
def _get_metrics_path(self):
|
||||
"""Helper function to find the memory metrics path"""
|
||||
metrics = self.json.get('Metrics')
|
||||
if not metrics:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='Memory Metrics', resource=self._path)
|
||||
return utils.get_resource_identity(metrics)
|
||||
return utils.get_sub_resource_path_by(self, 'Metrics')
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._metrics is None:
|
||||
self._metrics = memory_metrics.MemoryMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._metrics
|
||||
|
||||
def refresh(self):
|
||||
super(Memory, self).refresh()
|
||||
self._metrics = None
|
||||
return memory_metrics.MemoryMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class MemoryCollection(memory.MemoryCollection):
|
||||
|
@@ -13,12 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy.resources.system import processor
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_2.system import processor_metrics
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class StatusField(base.CompositeField):
|
||||
@@ -32,33 +31,22 @@ class Processor(processor.Processor):
|
||||
status = StatusField('Status')
|
||||
"""The processor status"""
|
||||
|
||||
_metrics = None # ref to System instance
|
||||
|
||||
def _get_metrics_path(self):
|
||||
"""Helper function to find the System process metrics path"""
|
||||
metrics = self.json.get('Oem').get('Intel_RackScale').get('Metrics')
|
||||
if not metrics:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='Processor Metrics', resource=self._path)
|
||||
return utils.get_resource_identity(metrics)
|
||||
return utils.get_sub_resource_path_by(
|
||||
self, ['Oem', 'Intel_RackScale', 'Metrics'])
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._metrics is None:
|
||||
self._metrics = processor_metrics.ProcessorMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._metrics
|
||||
|
||||
def refresh(self):
|
||||
super(Processor, self).refresh()
|
||||
self._metrics = None
|
||||
return processor_metrics.ProcessorMetrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class ProcessorCollection(processor.ProcessorCollection):
|
||||
|
@@ -13,76 +13,58 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.system import system
|
||||
from rsd_lib.resources.v2_2.system import memory
|
||||
from rsd_lib.resources.v2_2.system import metrics
|
||||
from rsd_lib.resources.v2_2.system import processor
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class System(system.System):
|
||||
|
||||
_metrics = None # ref to System metrics instance
|
||||
_processors = None # ref to ProcessorCollection instance
|
||||
_memory = None # ref to ProcessorCollection instance
|
||||
|
||||
def _get_metrics_path(self):
|
||||
"""Helper function to find the System metrics path"""
|
||||
metrics = self.json.get('Oem').get('Intel_RackScale').get('Metrics')
|
||||
if not metrics:
|
||||
raise exceptions.MissingAttributeError(attribute='Metrics',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(metrics)
|
||||
return utils.get_sub_resource_path_by(
|
||||
self, ['Oem', 'Intel_RackScale', 'Metrics'])
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._metrics is None:
|
||||
self._metrics = metrics.Metrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._metrics
|
||||
return metrics.Metrics(
|
||||
self._conn, self._get_metrics_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def processors(self):
|
||||
"""Property to provide reference to `ProcessorCollection` instance
|
||||
|
||||
It is calculated once when the first time it is queried. On refresh,
|
||||
this property gets reset.
|
||||
"""
|
||||
if self._processors is None:
|
||||
self._processors = processor.ProcessorCollection(
|
||||
self._conn, self._get_processor_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
return processor.ProcessorCollection(
|
||||
self._conn, self._get_processor_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._processors
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def memory(self):
|
||||
"""Property to provide reference to `Memory` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._memory is None:
|
||||
self._memory = memory.MemoryCollection(
|
||||
self._conn, self._get_memory_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._memory
|
||||
|
||||
def refresh(self):
|
||||
super(System, self).refresh()
|
||||
self._metrics = None
|
||||
self._processors = None
|
||||
self._memory = None
|
||||
return memory.MemoryCollection(
|
||||
self._conn, self._get_memory_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class SystemCollection(system.SystemCollection):
|
||||
|
@@ -13,12 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_2.telemetry.metric_definitions \
|
||||
import metric_definitions
|
||||
from rsd_lib import utils
|
||||
|
||||
|
||||
class StatusField(base.CompositeField):
|
||||
@@ -31,32 +30,18 @@ class Telemetry(base.ResourceBase):
|
||||
status = StatusField('Status')
|
||||
"""The telemetry service status"""
|
||||
|
||||
_metric_definitions = None
|
||||
"""ref to telemetry metrics definitions instance"""
|
||||
|
||||
def _get_metric_definitions_path(self):
|
||||
"""Helper function to find the metric definitions path"""
|
||||
metrics = self.json.get('MetricDefinitions')
|
||||
if not metrics:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='MetricDefinitions', resource=self._path)
|
||||
return utils.get_resource_identity(metrics)
|
||||
return utils.get_sub_resource_path_by(self, 'MetricDefinitions')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def metric_definitions(self):
|
||||
"""Property to provide reference to `MetricDefinitions` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
if self._metric_definitions is None:
|
||||
self._metric_definitions = \
|
||||
metric_definitions.MetricDefinitionsCollection(
|
||||
self._conn, self._get_metric_definitions_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._metric_definitions
|
||||
|
||||
def refresh(self):
|
||||
super(Telemetry, self).refresh()
|
||||
self._metric_definitions = None
|
||||
return metric_definitions.MetricDefinitionsCollection(
|
||||
self._conn, self._get_metric_definitions_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
@@ -15,12 +15,11 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_3.fabric import endpoint
|
||||
from rsd_lib.resources.v2_3.fabric import zone
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -50,10 +49,6 @@ class Fabric(base.ResourceBase):
|
||||
|
||||
status = StatusField('Status')
|
||||
|
||||
_endpoints = None # ref to EndpointCollection instance
|
||||
|
||||
_zones = None # ref to ZoneCollection instance
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Fabric
|
||||
|
||||
@@ -67,52 +62,35 @@ class Fabric(base.ResourceBase):
|
||||
|
||||
def _get_endpoint_collection_path(self):
|
||||
"""Helper function to find the EndpointCollection path"""
|
||||
endpoint_col = self.json.get('Endpoints')
|
||||
if not endpoint_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Endpoints',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(endpoint_col)
|
||||
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.
|
||||
"""
|
||||
if self._endpoints is None:
|
||||
self._endpoints = endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._endpoints
|
||||
return endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_zone_collection_path(self):
|
||||
"""Helper function to find the ZoneCollection path"""
|
||||
zone_col = self.json.get('Zones')
|
||||
if not zone_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Zones',
|
||||
resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(zone_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Zones')
|
||||
|
||||
@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.
|
||||
"""
|
||||
if self._zones is None:
|
||||
self._zones = zone.ZoneCollection(
|
||||
self._conn, self._get_zone_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._zones
|
||||
|
||||
def refresh(self):
|
||||
super(Fabric, self).refresh()
|
||||
self._endpoints = None
|
||||
self._zones = None
|
||||
return zone.ZoneCollection(
|
||||
self._conn, self._get_zone_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class FabricCollection(base.ResourceCollectionBase):
|
||||
|
@@ -40,8 +40,6 @@ class AttachResourceActionInfo(base.ResourceBase):
|
||||
name = base.Field('Name')
|
||||
"""The storage pool name string"""
|
||||
|
||||
_parameters = None # ref to allocated volumes collection
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a LogicalDrive
|
||||
|
||||
@@ -54,27 +52,23 @@ class AttachResourceActionInfo(base.ResourceBase):
|
||||
connector, identity, redfish_version)
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def parameters(self):
|
||||
"""Property to provide reference to `Parameters` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._parameters is None:
|
||||
self._parameters = []
|
||||
for i in self.json.get('Parameters'):
|
||||
item = {}
|
||||
for key in NAME_MAPPING:
|
||||
item[NAME_MAPPING[key]] = i[key]
|
||||
parameters = []
|
||||
for i in self.json.get('Parameters'):
|
||||
item = {}
|
||||
for key in NAME_MAPPING:
|
||||
item[NAME_MAPPING[key]] = i[key]
|
||||
|
||||
if item['name'] == 'Resource':
|
||||
item['allowable_values'] = utils.get_members_identities(
|
||||
item['allowable_values'])
|
||||
if item['name'] == 'Resource':
|
||||
item['allowable_values'] = utils.get_members_identities(
|
||||
item['allowable_values'])
|
||||
|
||||
self._parameters.append(item)
|
||||
parameters.append(item)
|
||||
|
||||
return self._parameters
|
||||
|
||||
def refresh(self):
|
||||
super(AttachResourceActionInfo, self).refresh()
|
||||
self._parameters = None
|
||||
return parameters
|
||||
|
@@ -147,8 +147,8 @@ class Node(v2_1_node.Node):
|
||||
|
||||
self._conn.post(target_uri, data=data)
|
||||
|
||||
def refresh(self):
|
||||
super(Node, self).refresh()
|
||||
def refresh(self, force=True):
|
||||
super(Node, self).refresh(force)
|
||||
if self._actions.attach_endpoint:
|
||||
self._actions.attach_endpoint.action_info = None
|
||||
if self._actions.detach_endpoint:
|
||||
|
@@ -15,7 +15,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
@@ -77,10 +76,6 @@ class StoragePool(base.ResourceBase):
|
||||
identifier = IdentifierField('Identifier')
|
||||
"""These identifiers list of this volume"""
|
||||
|
||||
_allocated_volumes = None # ref to allocated volumes collection
|
||||
|
||||
_allocated_pools = None # ref to allocated pools collection
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a LogicalDrive
|
||||
|
||||
@@ -93,52 +88,35 @@ class StoragePool(base.ResourceBase):
|
||||
|
||||
def _get_allocated_volumes_path(self):
|
||||
"""Helper function to find the AllocatedVolumes path"""
|
||||
volume_col = self.json.get('AllocatedVolumes')
|
||||
if not volume_col:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='AllocatedVolumes', resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(volume_col)
|
||||
return utils.get_sub_resource_path_by(self, 'AllocatedVolumes')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def allocated_volumes(self):
|
||||
"""Property to provide reference to `AllocatedVolumes` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._allocated_volumes is None:
|
||||
self._allocated_volumes = volume.VolumeCollection(
|
||||
self._conn, self._get_allocated_volumes_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._allocated_volumes
|
||||
return volume.VolumeCollection(
|
||||
self._conn, self._get_allocated_volumes_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_allocated_pools_path(self):
|
||||
"""Helper function to find the AllocatedPools path"""
|
||||
storage_pool_col = self.json.get('AllocatedPools')
|
||||
if not storage_pool_col:
|
||||
raise exceptions.MissingAttributeError(
|
||||
attribute='AllocatedPools', resource=self._path)
|
||||
return rsd_lib_utils.get_resource_identity(storage_pool_col)
|
||||
return utils.get_sub_resource_path_by(self, 'AllocatedPools')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def allocated_pools(self):
|
||||
"""Property to provide reference to `AllocatedPools` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._allocated_pools is None:
|
||||
self._allocated_pools = StoragePoolCollection(
|
||||
self._conn, self._get_allocated_pools_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._allocated_pools
|
||||
|
||||
def refresh(self):
|
||||
super(StoragePool, self).refresh()
|
||||
self._allocated_volumes = None
|
||||
self._allocated_pools = None
|
||||
return StoragePoolCollection(
|
||||
self._conn, self._get_allocated_pools_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class StoragePoolCollection(base.ResourceCollectionBase):
|
||||
|
@@ -15,14 +15,13 @@
|
||||
|
||||
import logging
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_3.fabric import endpoint
|
||||
from rsd_lib.resources.v2_3.storage_service import drive
|
||||
from rsd_lib.resources.v2_3.storage_service import storage_pool
|
||||
from rsd_lib.resources.v2_3.storage_service import volume
|
||||
from rsd_lib import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -47,14 +46,6 @@ class StorageService(base.ResourceBase):
|
||||
status = StatusField('Status')
|
||||
"""The storage service status"""
|
||||
|
||||
_volumes = None # ref to Volumes collection
|
||||
|
||||
_storage_pools = None # ref to StoragePool collection
|
||||
|
||||
_drives = None # ref to Drive collection
|
||||
|
||||
_endpoints = None # ref to Endpoint collection
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a StorageService
|
||||
|
||||
@@ -68,98 +59,67 @@ class StorageService(base.ResourceBase):
|
||||
|
||||
def _get_volume_collection_path(self):
|
||||
"""Helper function to find the VolumeCollection path"""
|
||||
volume_col = self.json.get('Volumes')
|
||||
if not volume_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Volumes',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(volume_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Volumes')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def volumes(self):
|
||||
"""Property to provide reference to `VolumeCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._volumes is None:
|
||||
self._volumes = volume.VolumeCollection(
|
||||
self._conn, self._get_volume_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._volumes
|
||||
return volume.VolumeCollection(
|
||||
self._conn, self._get_volume_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_storage_pool_collection_path(self):
|
||||
"""Helper function to find the StoragePoolCollection path"""
|
||||
storage_pool_col = self.json.get('StoragePools')
|
||||
if not storage_pool_col:
|
||||
raise exceptions.MissingAttributeError(attribute='StoragePools',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(storage_pool_col)
|
||||
return utils.get_sub_resource_path_by(self, 'StoragePools')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def storage_pools(self):
|
||||
"""Property to provide reference to `StoragePoolCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._storage_pools is None:
|
||||
self._storage_pools = storage_pool.StoragePoolCollection(
|
||||
self._conn, self._get_storage_pool_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._storage_pools
|
||||
return storage_pool.StoragePoolCollection(
|
||||
self._conn, self._get_storage_pool_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_drive_collection_path(self):
|
||||
"""Helper function to find the DriveCollection path"""
|
||||
drive_col = self.json.get('Drives')
|
||||
if not drive_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Drives',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(drive_col)
|
||||
return utils.get_sub_resource_path_by(self, 'Drives')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def drives(self):
|
||||
"""Property to provide reference to `DriveCollection` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
if self._drives is None:
|
||||
self._drives = drive.DriveCollection(
|
||||
self._conn, self._get_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._drives
|
||||
return drive.DriveCollection(
|
||||
self._conn, self._get_drive_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_endpoint_collection_path(self):
|
||||
"""Helper function to find the EndpointCollection path"""
|
||||
endpoint_col = self.json.get('Endpoints')
|
||||
if not endpoint_col:
|
||||
raise exceptions.MissingAttributeError(attribute='Endpoints',
|
||||
resource=self._path)
|
||||
return utils.get_resource_identity(endpoint_col)
|
||||
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.
|
||||
"""
|
||||
if self._endpoints is None:
|
||||
self._endpoints = endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
return self._endpoints
|
||||
|
||||
def refresh(self):
|
||||
super(StorageService, self).refresh()
|
||||
self._volumes = None
|
||||
self._storage_pools = None
|
||||
self._drives = None
|
||||
self._endpoints = None
|
||||
return endpoint.EndpointCollection(
|
||||
self._conn, self._get_endpoint_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class StorageServiceCollection(base.ResourceCollectionBase):
|
||||
|
@@ -47,7 +47,6 @@ class ACLTestCase(testtools.TestCase):
|
||||
self.acl_inst.name)
|
||||
self.assertEqual('Switch ACL', self.acl_inst.description)
|
||||
self.assertEqual({}, self.acl_inst.oem)
|
||||
self.assertIsNone(self.acl_inst._rules)
|
||||
|
||||
def test__get_acl_rule_collection_path(self):
|
||||
self.assertEqual(
|
||||
@@ -57,12 +56,10 @@ class ACLTestCase(testtools.TestCase):
|
||||
def test__get_acl_rule_collection_path_missing_attr(self):
|
||||
self.acl_inst._json.pop('Rules')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute ACLRule',
|
||||
exceptions.MissingAttributeError, 'attribute Rules',
|
||||
self.acl_inst._get_acl_rule_collection_path)
|
||||
|
||||
def test_acl_rule(self):
|
||||
# check for the underpath variable value
|
||||
self.assertIsNone(self.acl_inst._rules)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -96,10 +93,9 @@ class ACLTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_switch_acl.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.acl_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.acl_inst._rules)
|
||||
self.acl_inst.invalidate()
|
||||
self.acl_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -57,8 +57,6 @@ class EthernetSwtichTestCase(testtools.TestCase):
|
||||
self.assertEqual('TOR', self.ethernet_switch_inst.role)
|
||||
self.assertEqual('Enabled', self.ethernet_switch_inst.status.state)
|
||||
self.assertEqual('OK', self.ethernet_switch_inst.status.health)
|
||||
self.assertIsNone(self.ethernet_switch_inst._acls)
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
self.assertEqual('/redfish/v1/Chassis/FabricModule1',
|
||||
self.ethernet_switch_inst.links.chassis)
|
||||
self.assertEqual(('/redfish/v1/Managers/Manager1',),
|
||||
@@ -76,8 +74,6 @@ class EthernetSwtichTestCase(testtools.TestCase):
|
||||
self.ethernet_switch_inst._get_port_collection_path)
|
||||
|
||||
def test_ports(self):
|
||||
# check for the underpath variable value
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -111,10 +107,9 @@ class EthernetSwtichTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_switch.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_switch_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
self.ethernet_switch_inst.invalidate()
|
||||
self.ethernet_switch_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -135,8 +130,6 @@ class EthernetSwtichTestCase(testtools.TestCase):
|
||||
self.ethernet_switch_inst._get_acl_collection_path()
|
||||
|
||||
def test_acl(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.ethernet_switch_inst._acls)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -169,9 +162,9 @@ class EthernetSwtichTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_switch.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_switch_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.ethernet_switch_inst._acls)
|
||||
|
||||
self.ethernet_switch_inst.invalidate()
|
||||
self.ethernet_switch_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -81,8 +81,6 @@ class PortTestCase(testtools.TestCase):
|
||||
self.assertEqual('Logical', self.port_inst.port_class)
|
||||
self.assertEqual('LinkAggregationStatic', self.port_inst.port_mode)
|
||||
self.assertEqual('Upstream', self.port_inst.port_type)
|
||||
self.assertIsNone(self.port_inst._vlans)
|
||||
self.assertIsNone(self.port_inst._static_macs)
|
||||
self.assertEqual(
|
||||
'/redfish/v1/EthernetSwitches/Switch1/Ports/Port1/VLANs/VLAN1',
|
||||
self.port_inst.links.primary_vlan)
|
||||
@@ -109,8 +107,6 @@ class PortTestCase(testtools.TestCase):
|
||||
self.port_inst._get_static_mac_collection_path)
|
||||
|
||||
def test_static_mac(self):
|
||||
# checkou for the underpath variable value
|
||||
self.assertIsNone(self.port_inst._static_macs)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -142,10 +138,9 @@ class PortTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_switch_port.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.port_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.port_inst._static_macs)
|
||||
self.port_inst.invalidate()
|
||||
self.port_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -167,8 +162,6 @@ class PortTestCase(testtools.TestCase):
|
||||
self.port_inst._get_vlan_collection_path)
|
||||
|
||||
def test_vlan(self):
|
||||
# checkou for the underpath variable value
|
||||
self.assertIsNone(self.port_inst._vlans)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -200,10 +193,9 @@ class PortTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_switch_port.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.port_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.port_inst._vlans)
|
||||
self.port_inst.invalidate()
|
||||
self.port_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -48,8 +48,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.assertEqual(5, self.fabric_inst.max_zones)
|
||||
self.assertEqual('Enabled', self.fabric_inst.status.state)
|
||||
self.assertEqual('OK', self.fabric_inst.status.health)
|
||||
self.assertIsNone(self.fabric_inst._endpoints)
|
||||
self.assertIsNone(self.fabric_inst._zones)
|
||||
|
||||
def test__get_endpoint_collection_path(self):
|
||||
expected = '/redfish/v1/Fabrics/PCIe/Endpoints'
|
||||
@@ -63,8 +61,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.fabric_inst._get_endpoint_collection_path)
|
||||
|
||||
def test_endpoints(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.fabric_inst._endpoints)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -98,10 +94,9 @@ class FabricTestCase(testtools.TestCase):
|
||||
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.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.fabric_inst._endpoints)
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -118,7 +113,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.fabric_inst._get_switch_collection_path)
|
||||
|
||||
def test_switches(self):
|
||||
self.assertIsNone(self.fabric_inst._switches)
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'switch_collection.json', 'r') as f:
|
||||
@@ -142,8 +136,8 @@ class FabricTestCase(testtools.TestCase):
|
||||
'fabric.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.fabric_inst.refresh()
|
||||
self.assertIsNone(self.fabric_inst._switches)
|
||||
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:
|
||||
@@ -158,8 +152,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.fabric_inst._get_zone_collection_path)
|
||||
|
||||
def test_zones(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.fabric_inst._zones)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -193,10 +185,9 @@ class FabricTestCase(testtools.TestCase):
|
||||
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.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.fabric_inst._zones)
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -49,8 +49,6 @@ class ZoneTestCase(testtools.TestCase):
|
||||
self.assertEqual('OK', self.zone_inst.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.zone_inst._endpoints)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -84,10 +82,9 @@ class ZoneTestCase(testtools.TestCase):
|
||||
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.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.zone_inst._endpoints)
|
||||
self.zone_inst.invalidate()
|
||||
self.zone_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -319,7 +319,7 @@ class NodeTestCase(testtools.TestCase):
|
||||
def test__get_system_path_missing_systems_attr(self):
|
||||
self.node_inst._json.get('Links').pop('ComputerSystem')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute System',
|
||||
exceptions.MissingAttributeError, 'attribute Links/ComputerSystem',
|
||||
self.node_inst._get_system_path)
|
||||
|
||||
def test_memory_summary_missing_attr(self):
|
||||
@@ -380,8 +380,6 @@ class NodeTestCase(testtools.TestCase):
|
||||
self.assertEqual(None, self.node_inst.memory_summary)
|
||||
|
||||
def test_system(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.node_inst._system)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
@@ -414,10 +412,9 @@ class NodeTestCase(testtools.TestCase):
|
||||
# On refreshing the system instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/node.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.node_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.node_inst._system)
|
||||
self.node_inst.invalidate()
|
||||
self.node_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
|
@@ -48,9 +48,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.assertEqual('Enabled', self.storage_service_inst.status.state)
|
||||
self.assertEqual('OK', self.storage_service_inst.status.health)
|
||||
self.assertEqual('OK', self.storage_service_inst.status.health_rollup)
|
||||
self.assertIsNone(self.storage_service_inst._logical_drives)
|
||||
self.assertIsNone(self.storage_service_inst._physical_drives)
|
||||
self.assertIsNone(self.storage_service_inst._remote_targets)
|
||||
|
||||
def test__get_logical_drive_collection_path_missing_processors_attr(self):
|
||||
self.storage_service_inst._json.pop('LogicalDrives')
|
||||
@@ -59,8 +56,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_logical_drive_collection_path)
|
||||
|
||||
def test_logical_drives(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._logical_drives)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -94,10 +89,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._logical_drives)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -110,12 +104,10 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
def test__get_physical_drive_collection_path_missing_processors_attr(self):
|
||||
self.storage_service_inst._json.pop('Drives')
|
||||
self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute PhysicalDrives',
|
||||
exceptions.MissingAttributeError, 'attribute Drives',
|
||||
self.storage_service_inst._get_physical_drive_collection_path)
|
||||
|
||||
def test_physical_drives(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._physical_drives)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -149,10 +141,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._physical_drives)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -169,8 +160,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_remote_target_collection_path)
|
||||
|
||||
def test_remote_targets(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._remote_targets)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -204,10 +193,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._remote_targets)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -54,8 +54,6 @@ class SystemTestCase(testtools.TestCase):
|
||||
self.system_inst._get_memory_collection_path()
|
||||
|
||||
def test_memory(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._memory)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -89,9 +87,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._memory)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -109,12 +107,10 @@ class SystemTestCase(testtools.TestCase):
|
||||
def test__get_storage_collection_path_missing_systems_attr(self):
|
||||
self.system_inst._json.pop('Storage')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute StorageSubsystem'):
|
||||
exceptions.MissingAttributeError, 'attribute Storage'):
|
||||
self.system_inst._get_storage_subsystem_collection_path()
|
||||
|
||||
def test_storage_subsystem(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._storage_subsystem)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -148,9 +144,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._storage_subsystem)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -168,12 +164,10 @@ class SystemTestCase(testtools.TestCase):
|
||||
def test__get_network_interface_collection_path_missing_systems_attr(self):
|
||||
self.system_inst._json.pop('EthernetInterfaces')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute NetworkInterface'):
|
||||
exceptions.MissingAttributeError, 'attribute EthernetInterfaces'):
|
||||
self.system_inst._get_network_interface_collection_path()
|
||||
|
||||
def test_network_interface(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._network_interface)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -207,9 +201,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._network_interface)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
@@ -35,8 +35,6 @@ class EthernetSwitchTestCase(testtools.TestCase):
|
||||
redfish_version='1.0.2')
|
||||
|
||||
def test_ports(self):
|
||||
# check for the underpath variable value
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -70,10 +68,9 @@ class EthernetSwitchTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_switch.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_switch_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
self.ethernet_switch_inst.invalidate()
|
||||
self.ethernet_switch_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -48,8 +48,6 @@ class PortTestCase(testtools.TestCase):
|
||||
self.port_inst._get_metrics_path()
|
||||
|
||||
def test_metrics(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.port_inst._metrics)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -83,9 +81,9 @@ class PortTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_switch_port.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.port_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.port_inst._metrics)
|
||||
|
||||
self.port_inst.invalidate()
|
||||
self.port_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -79,12 +79,10 @@ class MemoryTestCase(testtools.TestCase):
|
||||
def test__get_metrics_path_missing_systems_attr(self):
|
||||
self.memory_inst._json.pop('Metrics')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Memory Metrics'):
|
||||
exceptions.MissingAttributeError, 'attribute Metrics'):
|
||||
self.memory_inst._get_metrics_path()
|
||||
|
||||
def test_metrics(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.memory_inst._metrics)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -118,9 +116,9 @@ class MemoryTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/memory.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.memory_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.memory_inst._metrics)
|
||||
|
||||
self.memory_inst.invalidate()
|
||||
self.memory_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -63,13 +63,11 @@ class ProcessorTestCase(testtools.TestCase):
|
||||
def test__get_metrics_path_missing_systems_attr(self):
|
||||
self.processor_inst._json.get('Oem').get('Intel_RackScale')\
|
||||
.pop('Metrics')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Processor Metrics'):
|
||||
with self.assertRaisesRegex(exceptions.MissingAttributeError,
|
||||
'attribute Oem/Intel_RackScale/Metrics'):
|
||||
self.processor_inst._get_metrics_path()
|
||||
|
||||
def test_metrics(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.processor_inst._metrics)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -103,9 +101,9 @@ class ProcessorTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/processor.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.processor_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.processor_inst._metrics)
|
||||
|
||||
self.processor_inst.invalidate()
|
||||
self.processor_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -51,13 +51,11 @@ class SystemTestCase(testtools.TestCase):
|
||||
|
||||
def test__get_metrics_path_missing_systems_attr(self):
|
||||
self.system_inst._json.get('Oem').get('Intel_RackScale').pop('Metrics')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute Metrics'):
|
||||
with self.assertRaisesRegex(exceptions.MissingAttributeError,
|
||||
'attribute Oem/Intel_RackScale/Metrics'):
|
||||
self.system_inst._get_metrics_path()
|
||||
|
||||
def test_metrics(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._metrics)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/system_metrics.json',
|
||||
@@ -91,9 +89,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._metrics)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/system_metrics.json',
|
||||
@@ -104,8 +102,6 @@ class SystemTestCase(testtools.TestCase):
|
||||
metrics.Metrics)
|
||||
|
||||
def test_processors(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._processors)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -139,9 +135,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._processors)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -152,8 +148,6 @@ class SystemTestCase(testtools.TestCase):
|
||||
processor.ProcessorCollection)
|
||||
|
||||
def test_memory(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.system_inst._memory)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -187,9 +181,9 @@ class SystemTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.system_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.system_inst._memory)
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -54,8 +54,6 @@ class TelemetryTestCase(testtools.TestCase):
|
||||
self.telemetry_inst._get_metric_definitions_path()
|
||||
|
||||
def test_metric_definitions(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.telemetry_inst._metric_definitions)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
@@ -89,9 +87,9 @@ class TelemetryTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'telemetry_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.telemetry_inst.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.telemetry_inst._metric_definitions)
|
||||
|
||||
self.telemetry_inst.invalidate()
|
||||
self.telemetry_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
|
@@ -52,8 +52,6 @@ class TestEthernetSwtich(base.TestCase):
|
||||
self.assertEqual('TOR', self.ethernet_switch_inst.role)
|
||||
self.assertEqual('Enabled', self.ethernet_switch_inst.status.state)
|
||||
self.assertEqual('OK', self.ethernet_switch_inst.status.health)
|
||||
self.assertIsNone(self.ethernet_switch_inst._acls)
|
||||
self.assertIsNone(self.ethernet_switch_inst._ports)
|
||||
self.assertEqual('/redfish/v1/Chassis/FabricModule1',
|
||||
self.ethernet_switch_inst.links.chassis)
|
||||
self.assertEqual(('/redfish/v1/Managers/PSME',),
|
||||
|
@@ -60,8 +60,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.fabric_inst._get_endpoint_collection_path)
|
||||
|
||||
def test_endpoints(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.fabric_inst._endpoints)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -95,10 +93,9 @@ class FabricTestCase(testtools.TestCase):
|
||||
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.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.fabric_inst._endpoints)
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -120,8 +117,6 @@ class FabricTestCase(testtools.TestCase):
|
||||
self.fabric_inst._get_zone_collection_path)
|
||||
|
||||
def test_zones(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.fabric_inst._zones)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -155,10 +150,9 @@ class FabricTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'fabric.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.fabric_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.fabric_inst._zones)
|
||||
self.fabric_inst.invalidate()
|
||||
self.fabric_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
|
@@ -49,8 +49,6 @@ class ZoneTestCase(testtools.TestCase):
|
||||
self.assertEqual('OK', self.zone_inst.status.health)
|
||||
|
||||
def test_endpoints(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.zone_inst._endpoints)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -84,10 +82,9 @@ class ZoneTestCase(testtools.TestCase):
|
||||
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.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.zone_inst._endpoints)
|
||||
self.zone_inst.invalidate()
|
||||
self.zone_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
|
@@ -41,12 +41,8 @@ class AttachResourceActionInfoTestCase(testtools.TestCase):
|
||||
self.attach_action_info.identity)
|
||||
self.assertEqual('Attach Resource ActionInfo',
|
||||
self.attach_action_info.name)
|
||||
self.assertIsNone(self.attach_action_info._parameters)
|
||||
|
||||
def test_parameters(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.attach_action_info._parameters)
|
||||
|
||||
# | WHEN |
|
||||
actual_parameters = self.attach_action_info.parameters
|
||||
# | THEN |
|
||||
@@ -95,10 +91,8 @@ class AttachResourceActionInfoTestCase(testtools.TestCase):
|
||||
]
|
||||
self.assertEqual(expected, self.attach_action_info.parameters)
|
||||
|
||||
# On refreshing the storage service instance...
|
||||
self.attach_action_info.refresh()
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.attach_action_info._parameters)
|
||||
self.attach_action_info.invalidate()
|
||||
self.attach_action_info.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
|
@@ -92,8 +92,6 @@ class StoragePoolTestCase(testtools.TestCase):
|
||||
self.storage_pool_inst._get_allocated_volumes_path)
|
||||
|
||||
def test_allocated_volumes(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_pool_inst._allocated_volumes)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -127,10 +125,9 @@ class StoragePoolTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'storage_pool.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_pool_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_pool_inst._allocated_volumes)
|
||||
self.storage_pool_inst.invalidate()
|
||||
self.storage_pool_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -153,8 +150,6 @@ class StoragePoolTestCase(testtools.TestCase):
|
||||
self.storage_pool_inst._get_allocated_pools_path)
|
||||
|
||||
def test_allocated_pools(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_pool_inst._allocated_pools)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -188,10 +183,9 @@ class StoragePoolTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'storage_pool.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_pool_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_pool_inst._allocated_pools)
|
||||
self.storage_pool_inst.invalidate()
|
||||
self.storage_pool_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
|
@@ -49,7 +49,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.assertEqual('Enabled', self.storage_service_inst.status.state)
|
||||
self.assertEqual('OK', self.storage_service_inst.status.health)
|
||||
self.assertEqual('OK', self.storage_service_inst.status.health_rollup)
|
||||
self.assertIsNone(self.storage_service_inst._volumes)
|
||||
|
||||
def test__get_volume_collection_path(self):
|
||||
expected = '/redfish/v1/StorageServices/1/Volumes'
|
||||
@@ -63,8 +62,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_volume_collection_path)
|
||||
|
||||
def test_volumes(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._volumes)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -98,10 +95,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._volumes)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -123,8 +119,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_storage_pool_collection_path)
|
||||
|
||||
def test_storage_pools(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._storage_pools)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -158,10 +152,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._storage_pools)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -183,8 +176,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_drive_collection_path)
|
||||
|
||||
def test_drives(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._drives)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -218,10 +209,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'storage_service.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._drives)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@@ -243,8 +233,6 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
self.storage_service_inst._get_endpoint_collection_path)
|
||||
|
||||
def test_endpoints(self):
|
||||
# check for the underneath variable value
|
||||
self.assertIsNone(self.storage_service_inst._endpoints)
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@@ -278,10 +266,9 @@ class StorageServiceTestCase(testtools.TestCase):
|
||||
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.storage_service_inst.refresh()
|
||||
|
||||
# | WHEN & THEN |
|
||||
self.assertIsNone(self.storage_service_inst._endpoints)
|
||||
self.storage_service_inst.invalidate()
|
||||
self.storage_service_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
|
Reference in New Issue
Block a user