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:
Lin Yang
2018-11-27 16:34:25 -08:00
parent 6eb9f60cce
commit a3d81c01fc
39 changed files with 273 additions and 715 deletions

View File

@@ -13,11 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib.resources.v2_1.ethernet_switch import acl_rule from rsd_lib.resources.v2_1.ethernet_switch import acl_rule
from rsd_lib import utils as rsd_lib_utils
class ACL(base.ResourceBase): class ACL(base.ResourceBase):
@@ -34,9 +33,6 @@ class ACL(base.ResourceBase):
oem = base.Field('Oem') oem = base.Field('Oem')
"""The acl oem info""" """The acl oem info"""
_rules = None # ref to ACLRuleCollection instance
"""The acl rules"""
links = base.Field('Links') links = base.Field('Links')
"""The acl links""" """The acl links"""
@@ -52,28 +48,19 @@ class ACL(base.ResourceBase):
def _get_acl_rule_collection_path(self): def _get_acl_rule_collection_path(self):
"""Helper function to find the RuleCollection path""" """Helper function to find the RuleCollection path"""
rule_col = self.json.get('Rules') return utils.get_sub_resource_path_by(self, 'Rules')
if not rule_col:
raise exceptions.MissingAttributeError(attribute='ACLRules',
resource=self._path)
return rsd_lib_utils.get_resource_identity(rule_col)
@property @property
@utils.cache_it
def rules(self): def rules(self):
"""Property to provide reference to `RuleCollection` instance """Property to provide reference to `RuleCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._rules is None: return acl_rule.ACLRuleCollection(
self._rules = acl_rule.ACLRuleCollection( self._conn, self._get_acl_rule_collection_path(),
self._conn, self._get_acl_rule_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._rules
def refresh(self):
super(ACL, self).refresh()
self._rules = None
class ACLCollection(base.ResourceCollectionBase): class ACLCollection(base.ResourceCollectionBase):

View File

@@ -15,7 +15,6 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils from sushy import utils
@@ -82,12 +81,6 @@ class EthernetSwitch(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
"""The ethernet switch 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') links = LinksField('Links')
"""The links to ethernet switch""" """The links to ethernet switch"""
@@ -105,53 +98,35 @@ class EthernetSwitch(base.ResourceBase):
def _get_port_collection_path(self): def _get_port_collection_path(self):
"""Helper function to find the PortCollection path""" """Helper function to find the PortCollection path"""
port_col = self.json.get('Ports') return utils.get_sub_resource_path_by(self, 'Ports')
if not port_col:
raise exceptions.MissingAttributeError(attribute='Ports',
resource=self._path)
return rsd_lib_utils.get_resource_identity(port_col)
@property @property
@utils.cache_it
def ports(self): def ports(self):
"""Property to provide reference to `PortCollection` instance """Property to provide reference to `PortCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._ports is None: return port.PortCollection(
self._ports = port.PortCollection( self._conn, self._get_port_collection_path(),
self._conn, self._get_port_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._ports
def _get_acl_collection_path(self): def _get_acl_collection_path(self):
"""Helper function to find the ACLCollection path""" """Helper function to find the ACLCollection path"""
acl_col = self.json.get('ACLs') return utils.get_sub_resource_path_by(self, 'ACLs')
if not acl_col:
raise exceptions.MissingAttributeError(attribute='ACLs',
resource=self._path)
return rsd_lib_utils.get_resource_identity(acl_col)
@property @property
@utils.cache_it
def acls(self): def acls(self):
"""Property to provide reference to `ACLCollection` instance """Property to provide reference to `ACLCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._acls is None: return acl.ACLCollection(
self._acls = acl.ACLCollection( self._conn, self._get_acl_collection_path(),
self._conn, self._get_acl_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version
)
return self._acls
def refresh(self):
super(EthernetSwitch, self).refresh()
self._ports = None
self._acls = None
class EthernetSwitchCollection(base.ResourceCollectionBase): class EthernetSwitchCollection(base.ResourceCollectionBase):

View File

@@ -15,7 +15,6 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils from sushy import utils
@@ -147,12 +146,6 @@ class Port(base.ResourceBase):
port_type = base.Field('PortType') port_type = base.Field('PortType')
"""The port type""" """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') links = LinksField('Links')
"""The port links""" """The port links"""
@@ -168,52 +161,35 @@ class Port(base.ResourceBase):
def _get_static_mac_collection_path(self): def _get_static_mac_collection_path(self):
"""Helper function to find the StaticMACCollection path""" """Helper function to find the StaticMACCollection path"""
static_mac_col = self.json.get('StaticMACs') return utils.get_sub_resource_path_by(self, 'StaticMACs')
if not static_mac_col:
raise exceptions.MissingAttributeError(attribute='StaticMAC',
resource=self._path)
return rsd_lib_utils.get_resource_identity(static_mac_col)
@property @property
@utils.cache_it
def static_macs(self): def static_macs(self):
"""Property to provide reference to `StaticMACollection` instance """Property to provide reference to `StaticMACollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._static_macs is None: return static_mac.StaticMACCollection(
self._static_macs = static_mac.StaticMACCollection( self._conn, self._get_static_mac_collection_path(),
self._conn, self._get_static_mac_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._static_macs
def _get_vlan_collection_path(self): def _get_vlan_collection_path(self):
"""Helper function to find the VLANCollection path""" """Helper function to find the VLANCollection path"""
vlan_col = self.json.get('VLANs') return utils.get_sub_resource_path_by(self, 'VLANs')
if not vlan_col:
raise exceptions.MissingAttributeError(attribute='VLAN',
resource=self._path)
return rsd_lib_utils.get_resource_identity(vlan_col)
@property @property
@utils.cache_it
def vlans(self): def vlans(self):
"""Property to provide reference to `VLANCollection` instance """Property to provide reference to `VLANCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._vlans is None: return vlan.VLANCollection(
self._vlans = vlan.VLANCollection( self._conn, self._get_vlan_collection_path(),
self._conn, self._get_vlan_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._vlans
def refresh(self):
super(Port, self).refresh()
self._static_macs = None
self._vlans = None
class PortCollection(base.ResourceCollectionBase): class PortCollection(base.ResourceCollectionBase):

View File

@@ -15,13 +15,12 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base 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 endpoint
from rsd_lib.resources.v2_1.fabric import switch from rsd_lib.resources.v2_1.fabric import switch
from rsd_lib.resources.v2_1.fabric import zone from rsd_lib.resources.v2_1.fabric import zone
from rsd_lib import utils as rsd_lib_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -50,12 +49,6 @@ class Fabric(base.ResourceBase):
status = StatusField('Status') 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): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a Fabric """A class representing a Fabric
@@ -69,75 +62,51 @@ class Fabric(base.ResourceBase):
def _get_endpoint_collection_path(self): def _get_endpoint_collection_path(self):
"""Helper function to find the EndpointCollection path""" """Helper function to find the EndpointCollection path"""
endpoint_col = self.json.get('Endpoints') return utils.get_sub_resource_path_by(self, 'Endpoints')
if not endpoint_col:
raise exceptions.MissingAttributeError(attribute='Endpoints',
resource=self._path)
return rsd_lib_utils.get_resource_identity(endpoint_col)
@property @property
@utils.cache_it
def endpoints(self): def endpoints(self):
"""Property to provide reference to `EndpointCollection` instance """Property to provide reference to `EndpointCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._endpoints is None: return endpoint.EndpointCollection(
self._endpoints = endpoint.EndpointCollection( self._conn, self._get_endpoint_collection_path(),
self._conn, self._get_endpoint_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._endpoints
def _get_switch_collection_path(self): def _get_switch_collection_path(self):
"""Helper function to find the SwitchCollection path""" """Helper function to find the SwitchCollection path"""
switch_col = self.json.get('Switches') return utils.get_sub_resource_path_by(self, 'Switches')
if not switch_col:
raise exceptions.MissingAttributeError(attribute='Switches',
resource=self._path)
return switch_col.get('@odata.id')
@property @property
@utils.cache_it
def switches(self): def switches(self):
"""Property to provide reference to `SwitchCollection` instance """Property to provide reference to `SwitchCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._switches is None: return switch.SwitchCollection(
self._switches = switch.SwitchCollection( self._conn, self._get_switch_collection_path(),
self._conn, self._get_switch_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._switches
def _get_zone_collection_path(self): def _get_zone_collection_path(self):
"""Helper function to find the ZoneCollection path""" """Helper function to find the ZoneCollection path"""
zone_col = self.json.get('Zones') return utils.get_sub_resource_path_by(self, 'Zones')
if not zone_col:
raise exceptions.MissingAttributeError(attribute='Zones',
resource=self._path)
return rsd_lib_utils.get_resource_identity(zone_col)
@property @property
@utils.cache_it
def zones(self): def zones(self):
"""Property to provide reference to `ZoneCollection` instance """Property to provide reference to `ZoneCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._zones is None: return zone.ZoneCollection(
self._zones = zone.ZoneCollection( self._conn, self._get_zone_collection_path(),
self._conn, self._get_zone_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._zones
def refresh(self):
super(Fabric, self).refresh()
self._endpoints = None
self._zones = None
self._switches = None
class FabricCollection(base.ResourceCollectionBase): class FabricCollection(base.ResourceCollectionBase):

View File

@@ -50,8 +50,6 @@ class Zone(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
"""The zone status""" """The zone status"""
_endpoints = None # ref to contained endpoints
def __init__(self, connector, identity, redfish_version=None): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a Zone """A class representing a Zone
@@ -64,22 +62,16 @@ class Zone(base.ResourceBase):
redfish_version) redfish_version)
@property @property
@utils.cache_it
def endpoints(self): def endpoints(self):
"""Return a list of Endpoints present in the Zone """Return a list of Endpoints present in the Zone
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._endpoints is None: return [
self._endpoints = [ endpoint.Endpoint(self._conn, id_, self.redfish_version)
endpoint.Endpoint(self._conn, id_, self.redfish_version) for id_ in self.links.endpoint_identities]
for id_ in self.links.endpoint_identities]
return self._endpoints
def refresh(self):
super(Zone, self).refresh()
self._endpoints = None
def update(self, endpoints): def update(self, endpoints):
"""Add or remove Endpoints from a Zone """Add or remove Endpoints from a Zone

View File

@@ -173,8 +173,6 @@ class Node(base.ResourceBase):
links = LinksField('Links') links = LinksField('Links')
"""These links to related components of this composed node""" """These links to related components of this composed node"""
_system = None # ref to System instance
_actions = NodeActionsField('Actions', required=True) _actions = NodeActionsField('Actions', required=True)
def __init__(self, connector, identity, redfish_version=None): def __init__(self, connector, identity, redfish_version=None):
@@ -305,24 +303,20 @@ class Node(base.ResourceBase):
def _get_system_path(self): def _get_system_path(self):
"""Helper function to find the System path""" """Helper function to find the System path"""
system_col = self.json.get('Links').get('ComputerSystem') return utils.get_sub_resource_path_by(
if not system_col: self, ['Links', 'ComputerSystem'])
raise exceptions.MissingAttributeError(attribute='System',
resource=self._path)
return system_col.get('@odata.id')
@property @property
@utils.cache_it
def system(self): def system(self):
"""Property to provide reference to `System` instance """Property to provide reference to `System` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._system is None: return system.System(
self._system = system.System(self._conn, self._get_system_path(), self._conn, self._get_system_path(),
redfish_version=self.redfish_version) redfish_version=self.redfish_version)
return self._system
def _get_attach_endpoint_action_element(self): def _get_attach_endpoint_action_element(self):
attach_endpoint_action = self._actions.attach_endpoint attach_endpoint_action = self._actions.attach_endpoint
@@ -411,10 +405,6 @@ class Node(base.ResourceBase):
""" """
self._conn.delete(self.path) self._conn.delete(self.path)
def refresh(self):
super(Node, self).refresh()
self._system = None
class NodeCollection(base.ResourceCollectionBase): class NodeCollection(base.ResourceCollectionBase):

View File

@@ -15,8 +15,8 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base 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 logical_drive
from rsd_lib.resources.v2_1.storage_service import physical_drive from rsd_lib.resources.v2_1.storage_service import physical_drive
@@ -45,12 +45,6 @@ class StorageService(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
"""The storage service 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): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a StorageService """A class representing a StorageService
@@ -64,75 +58,51 @@ class StorageService(base.ResourceBase):
def _get_logical_drive_collection_path(self): def _get_logical_drive_collection_path(self):
"""Helper function to find the LogicalDriveCollection path""" """Helper function to find the LogicalDriveCollection path"""
logical_drive_col = self.json.get('LogicalDrives') return utils.get_sub_resource_path_by(self, 'LogicalDrives')
if not logical_drive_col:
raise exceptions.MissingAttributeError(attribute='LogicalDrives',
resource=self._path)
return logical_drive_col.get('@odata.id')
@property @property
@utils.cache_it
def logical_drives(self): def logical_drives(self):
"""Property to provide reference to `LogicalDriveCollection` instance """Property to provide reference to `LogicalDriveCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._logical_drives is None: return logical_drive.LogicalDriveCollection(
self._logical_drives = logical_drive.LogicalDriveCollection( self._conn, self._get_logical_drive_collection_path(),
self._conn, self._get_logical_drive_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._logical_drives
def _get_physical_drive_collection_path(self): def _get_physical_drive_collection_path(self):
"""Helper function to find the PhysicalDriveCollection path""" """Helper function to find the PhysicalDriveCollection path"""
physical_drive_col = self.json.get('Drives') return utils.get_sub_resource_path_by(self, 'Drives')
if not physical_drive_col:
raise exceptions.MissingAttributeError(attribute='PhysicalDrives',
resource=self._path)
return physical_drive_col.get('@odata.id')
@property @property
@utils.cache_it
def physical_drives(self): def physical_drives(self):
"""Property to provide reference to `PhysicalDriveCollection` instance """Property to provide reference to `PhysicalDriveCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._physical_drives is None: return physical_drive.PhysicalDriveCollection(
self._physical_drives = physical_drive.PhysicalDriveCollection( self._conn, self._get_physical_drive_collection_path(),
self._conn, self._get_physical_drive_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._physical_drives
def _get_remote_target_collection_path(self): def _get_remote_target_collection_path(self):
"""Helper function to find the RemoteTargetCollection path""" """Helper function to find the RemoteTargetCollection path"""
remote_target_col = self.json.get('RemoteTargets') return utils.get_sub_resource_path_by(self, 'RemoteTargets')
if not remote_target_col:
raise exceptions.MissingAttributeError(attribute='RemoteTargets',
resource=self._path)
return remote_target_col.get('@odata.id')
@property @property
@utils.cache_it
def remote_targets(self): def remote_targets(self):
"""Property to provide reference to `RemoteTargetCollection` instance """Property to provide reference to `RemoteTargetCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._remote_targets is None: return remote_target.RemoteTargetCollection(
self._remote_targets = remote_target.RemoteTargetCollection( self._conn, self._get_remote_target_collection_path(),
self._conn, self._get_remote_target_collection_path(), redfish_version=self.redfish_version)
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
class StorageServiceCollection(base.ResourceCollectionBase): class StorageServiceCollection(base.ResourceCollectionBase):

View File

@@ -13,96 +13,63 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources.system import system 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 memory
from rsd_lib.resources.v2_1.system import network_interface from rsd_lib.resources.v2_1.system import network_interface
from rsd_lib.resources.v2_1.system import storage_subsystem from rsd_lib.resources.v2_1.system import storage_subsystem
from rsd_lib import utils
class System(system.System): 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): def _get_memory_collection_path(self):
"""Helper function to find the memory path""" """Helper function to find the memory path"""
system_col = self.json.get('Memory') return utils.get_sub_resource_path_by(self, 'Memory')
if not system_col:
raise exceptions.MissingAttributeError(attribute='Memory',
resource=self._path)
return utils.get_resource_identity(system_col)
@property @property
@utils.cache_it
def memory(self): def memory(self):
"""Property to provide reference to `Metrics` instance """Property to provide reference to `Metrics` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._memory is None: return memory.MemoryCollection(
self._memory = memory.MemoryCollection( self._conn, self._get_memory_collection_path(),
self._conn, self._get_memory_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._memory
def _get_storage_subsystem_collection_path(self): def _get_storage_subsystem_collection_path(self):
"""Helper function to find the storage subsystem path""" """Helper function to find the storage subsystem path"""
storage_subsystem_col = self.json.get('Storage') return utils.get_sub_resource_path_by(self, 'Storage')
if not storage_subsystem_col:
raise exceptions.MissingAttributeError(
attribute='StorageSubsystem',
resource=self._path)
return utils.get_resource_identity(storage_subsystem_col)
@property @property
@utils.cache_it
def storage_subsystem(self): def storage_subsystem(self):
"""Property to provide reference to `StorageSubsystem` instance """Property to provide reference to `StorageSubsystem` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._storage_subsystem is None: return storage_subsystem.StorageSubsystemCollection(
self._storage_subsystem = storage_subsystem.\ self._conn, self._get_storage_subsystem_collection_path(),
StorageSubsystemCollection( redfish_version=self.redfish_version)
self._conn, self._get_storage_subsystem_collection_path(),
redfish_version=self.redfish_version)
return self._storage_subsystem
def _get_network_interface_collection_path(self): def _get_network_interface_collection_path(self):
"""Helper function to find the network interface path""" """Helper function to find the network interface path"""
network_interface_col = self.json.get('EthernetInterfaces') return utils.get_sub_resource_path_by(self, 'EthernetInterfaces')
if not network_interface_col:
raise exceptions.MissingAttributeError(
attribute='NetworkInterface',
resource=self._path
)
return utils.get_resource_identity(network_interface_col)
@property @property
@utils.cache_it
def network_interface(self): def network_interface(self):
"""Property to provide reference to `NetworkInterface` instance """Property to provide reference to `NetworkInterface` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._network_interface is None: return network_interface.NetworkInterfaceCollection(
self._network_interface = network_interface.\ self._conn, self._get_network_interface_collection_path(),
NetworkInterfaceCollection( redfish_version=self.redfish_version)
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
class SystemCollection(system.SystemCollection): class SystemCollection(system.SystemCollection):

View File

@@ -14,6 +14,7 @@
# under the License. # under the License.
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib.resources.v2_1.ethernet_switch import ethernet_switch \ from rsd_lib.resources.v2_1.ethernet_switch import ethernet_switch \
as v2_1_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): class EthernetSwitch(v2_1_ethernet_switch.EthernetSwitch):
@property @property
@utils.cache_it
def ports(self): def ports(self):
"""Property to provide reference to `PortCollection` instance """Property to provide reference to `PortCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._ports is None: return port.PortCollection(
self._ports = port.PortCollection( self._conn, self._get_port_collection_path(),
self._conn, self._get_port_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._ports
class EthernetSwitchCollection(base.ResourceCollectionBase): class EthernetSwitchCollection(base.ResourceCollectionBase):

View File

@@ -13,44 +13,30 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources import base 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_1.ethernet_switch import port as v2_1_port
from rsd_lib.resources.v2_2.ethernet_switch import port_metrics from rsd_lib.resources.v2_2.ethernet_switch import port_metrics
from rsd_lib import utils
class Port(v2_1_port.Port): class Port(v2_1_port.Port):
_metrics = None # ref to Port metrics instance
def _get_metrics_path(self): def _get_metrics_path(self):
"""Helper function to find the Port metrics path""" """Helper function to find the Port metrics path"""
metrics = self.json.get('Metrics') return utils.get_sub_resource_path_by(self, 'Metrics')
if not metrics:
raise exceptions.MissingAttributeError(attribute='Metrics',
resource=self._path)
return utils.get_resource_identity(metrics)
@property @property
@utils.cache_it
def metrics(self): def metrics(self):
"""Property to provide reference to `Metrics` instance """Property to provide reference to `Metrics` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._metrics is None: return port_metrics.PortMetrics(
self._metrics = port_metrics.PortMetrics( self._conn, self._get_metrics_path(),
self._conn, self._get_metrics_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._metrics
def refresh(self):
super(Port, self).refresh()
self._metrics = None
class PortCollection(base.ResourceCollectionBase): class PortCollection(base.ResourceCollectionBase):

View File

@@ -13,45 +13,32 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib.resources.v2_1.system import memory from rsd_lib.resources.v2_1.system import memory
from rsd_lib.resources.v2_2.system import memory_metrics from rsd_lib.resources.v2_2.system import memory_metrics
from rsd_lib import utils
class Memory(memory.Memory): class Memory(memory.Memory):
max_tdp_milliwatts = base.Field('MaxTDPMilliWatts') max_tdp_milliwatts = base.Field('MaxTDPMilliWatts')
_metrics = None # ref to System instance
def _get_metrics_path(self): def _get_metrics_path(self):
"""Helper function to find the memory metrics path""" """Helper function to find the memory metrics path"""
metrics = self.json.get('Metrics') return utils.get_sub_resource_path_by(self, 'Metrics')
if not metrics:
raise exceptions.MissingAttributeError(
attribute='Memory Metrics', resource=self._path)
return utils.get_resource_identity(metrics)
@property @property
@utils.cache_it
def metrics(self): def metrics(self):
"""Property to provide reference to `Metrics` instance """Property to provide reference to `Metrics` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._metrics is None: return memory_metrics.MemoryMetrics(
self._metrics = memory_metrics.MemoryMetrics( self._conn, self._get_metrics_path(),
self._conn, self._get_metrics_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._metrics
def refresh(self):
super(Memory, self).refresh()
self._metrics = None
class MemoryCollection(memory.MemoryCollection): class MemoryCollection(memory.MemoryCollection):

View File

@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy.resources.system import processor from sushy.resources.system import processor
from sushy import utils
from rsd_lib.resources.v2_2.system import processor_metrics from rsd_lib.resources.v2_2.system import processor_metrics
from rsd_lib import utils
class StatusField(base.CompositeField): class StatusField(base.CompositeField):
@@ -32,33 +31,22 @@ class Processor(processor.Processor):
status = StatusField('Status') status = StatusField('Status')
"""The processor status""" """The processor status"""
_metrics = None # ref to System instance
def _get_metrics_path(self): def _get_metrics_path(self):
"""Helper function to find the System process metrics path""" """Helper function to find the System process metrics path"""
metrics = self.json.get('Oem').get('Intel_RackScale').get('Metrics') return utils.get_sub_resource_path_by(
if not metrics: self, ['Oem', 'Intel_RackScale', 'Metrics'])
raise exceptions.MissingAttributeError(
attribute='Processor Metrics', resource=self._path)
return utils.get_resource_identity(metrics)
@property @property
@utils.cache_it
def metrics(self): def metrics(self):
"""Property to provide reference to `Metrics` instance """Property to provide reference to `Metrics` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._metrics is None: return processor_metrics.ProcessorMetrics(
self._metrics = processor_metrics.ProcessorMetrics( self._conn, self._get_metrics_path(),
self._conn, self._get_metrics_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._metrics
def refresh(self):
super(Processor, self).refresh()
self._metrics = None
class ProcessorCollection(processor.ProcessorCollection): class ProcessorCollection(processor.ProcessorCollection):

View File

@@ -13,76 +13,58 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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_1.system import system
from rsd_lib.resources.v2_2.system import memory 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 metrics
from rsd_lib.resources.v2_2.system import processor from rsd_lib.resources.v2_2.system import processor
from rsd_lib import utils
class System(system.System): 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): def _get_metrics_path(self):
"""Helper function to find the System metrics path""" """Helper function to find the System metrics path"""
metrics = self.json.get('Oem').get('Intel_RackScale').get('Metrics') return utils.get_sub_resource_path_by(
if not metrics: self, ['Oem', 'Intel_RackScale', 'Metrics'])
raise exceptions.MissingAttributeError(attribute='Metrics',
resource=self._path)
return utils.get_resource_identity(metrics)
@property @property
@utils.cache_it
def metrics(self): def metrics(self):
"""Property to provide reference to `Metrics` instance """Property to provide reference to `Metrics` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._metrics is None: return metrics.Metrics(
self._metrics = metrics.Metrics( self._conn, self._get_metrics_path(),
self._conn, self._get_metrics_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._metrics
@property @property
@utils.cache_it
def processors(self): def processors(self):
"""Property to provide reference to `ProcessorCollection` instance """Property to provide reference to `ProcessorCollection` instance
It is calculated once when the first time it is queried. On refresh, It is calculated once when the first time it is queried. On refresh,
this property gets reset. this property gets reset.
""" """
if self._processors is None: return processor.ProcessorCollection(
self._processors = processor.ProcessorCollection( self._conn, self._get_processor_collection_path(),
self._conn, self._get_processor_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._processors return self._processors
@property @property
@utils.cache_it
def memory(self): def memory(self):
"""Property to provide reference to `Memory` instance """Property to provide reference to `Memory` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._memory is None: return memory.MemoryCollection(
self._memory = memory.MemoryCollection( self._conn, self._get_memory_collection_path(),
self._conn, self._get_memory_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._memory
def refresh(self):
super(System, self).refresh()
self._metrics = None
self._processors = None
self._memory = None
class SystemCollection(system.SystemCollection): class SystemCollection(system.SystemCollection):

View File

@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils
from rsd_lib.resources.v2_2.telemetry.metric_definitions \ from rsd_lib.resources.v2_2.telemetry.metric_definitions \
import metric_definitions import metric_definitions
from rsd_lib import utils
class StatusField(base.CompositeField): class StatusField(base.CompositeField):
@@ -31,32 +30,18 @@ class Telemetry(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
"""The telemetry service status""" """The telemetry service status"""
_metric_definitions = None
"""ref to telemetry metrics definitions instance"""
def _get_metric_definitions_path(self): def _get_metric_definitions_path(self):
"""Helper function to find the metric definitions path""" """Helper function to find the metric definitions path"""
metrics = self.json.get('MetricDefinitions') return utils.get_sub_resource_path_by(self, 'MetricDefinitions')
if not metrics:
raise exceptions.MissingAttributeError(
attribute='MetricDefinitions', resource=self._path)
return utils.get_resource_identity(metrics)
@property @property
@utils.cache_it
def metric_definitions(self): def metric_definitions(self):
"""Property to provide reference to `MetricDefinitions` instance """Property to provide reference to `MetricDefinitions` instance
It is calculated once the first time it is queried. On refresh, It is calculated once the first time it is queried. On refresh,
this property is reset. this property is reset.
""" """
if self._metric_definitions is None: return metric_definitions.MetricDefinitionsCollection(
self._metric_definitions = \ self._conn, self._get_metric_definitions_path(),
metric_definitions.MetricDefinitionsCollection( redfish_version=self.redfish_version)
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

View File

@@ -15,12 +15,11 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base 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 endpoint
from rsd_lib.resources.v2_3.fabric import zone from rsd_lib.resources.v2_3.fabric import zone
from rsd_lib import utils as rsd_lib_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -50,10 +49,6 @@ class Fabric(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
_endpoints = None # ref to EndpointCollection instance
_zones = None # ref to ZoneCollection instance
def __init__(self, connector, identity, redfish_version=None): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a Fabric """A class representing a Fabric
@@ -67,52 +62,35 @@ class Fabric(base.ResourceBase):
def _get_endpoint_collection_path(self): def _get_endpoint_collection_path(self):
"""Helper function to find the EndpointCollection path""" """Helper function to find the EndpointCollection path"""
endpoint_col = self.json.get('Endpoints') return utils.get_sub_resource_path_by(self, 'Endpoints')
if not endpoint_col:
raise exceptions.MissingAttributeError(attribute='Endpoints',
resource=self._path)
return rsd_lib_utils.get_resource_identity(endpoint_col)
@property @property
@utils.cache_it
def endpoints(self): def endpoints(self):
"""Property to provide reference to `EndpointCollection` instance """Property to provide reference to `EndpointCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._endpoints is None: return endpoint.EndpointCollection(
self._endpoints = endpoint.EndpointCollection( self._conn, self._get_endpoint_collection_path(),
self._conn, self._get_endpoint_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._endpoints
def _get_zone_collection_path(self): def _get_zone_collection_path(self):
"""Helper function to find the ZoneCollection path""" """Helper function to find the ZoneCollection path"""
zone_col = self.json.get('Zones') return utils.get_sub_resource_path_by(self, 'Zones')
if not zone_col:
raise exceptions.MissingAttributeError(attribute='Zones',
resource=self._path)
return rsd_lib_utils.get_resource_identity(zone_col)
@property @property
@utils.cache_it
def zones(self): def zones(self):
"""Property to provide reference to `ZoneCollection` instance """Property to provide reference to `ZoneCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._zones is None: return zone.ZoneCollection(
self._zones = zone.ZoneCollection( self._conn, self._get_zone_collection_path(),
self._conn, self._get_zone_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._zones
def refresh(self):
super(Fabric, self).refresh()
self._endpoints = None
self._zones = None
class FabricCollection(base.ResourceCollectionBase): class FabricCollection(base.ResourceCollectionBase):

View File

@@ -40,8 +40,6 @@ class AttachResourceActionInfo(base.ResourceBase):
name = base.Field('Name') name = base.Field('Name')
"""The storage pool name string""" """The storage pool name string"""
_parameters = None # ref to allocated volumes collection
def __init__(self, connector, identity, redfish_version=None): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a LogicalDrive """A class representing a LogicalDrive
@@ -54,27 +52,23 @@ class AttachResourceActionInfo(base.ResourceBase):
connector, identity, redfish_version) connector, identity, redfish_version)
@property @property
@utils.cache_it
def parameters(self): def parameters(self):
"""Property to provide reference to `Parameters` instance """Property to provide reference to `Parameters` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._parameters is None: parameters = []
self._parameters = [] for i in self.json.get('Parameters'):
for i in self.json.get('Parameters'): item = {}
item = {} for key in NAME_MAPPING:
for key in NAME_MAPPING: item[NAME_MAPPING[key]] = i[key]
item[NAME_MAPPING[key]] = i[key]
if item['name'] == 'Resource': if item['name'] == 'Resource':
item['allowable_values'] = utils.get_members_identities( item['allowable_values'] = utils.get_members_identities(
item['allowable_values']) item['allowable_values'])
self._parameters.append(item) parameters.append(item)
return self._parameters return parameters
def refresh(self):
super(AttachResourceActionInfo, self).refresh()
self._parameters = None

View File

@@ -147,8 +147,8 @@ class Node(v2_1_node.Node):
self._conn.post(target_uri, data=data) self._conn.post(target_uri, data=data)
def refresh(self): def refresh(self, force=True):
super(Node, self).refresh() super(Node, self).refresh(force)
if self._actions.attach_endpoint: if self._actions.attach_endpoint:
self._actions.attach_endpoint.action_info = None self._actions.attach_endpoint.action_info = None
if self._actions.detach_endpoint: if self._actions.detach_endpoint:

View File

@@ -15,7 +15,6 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base from sushy.resources import base
from sushy import utils from sushy import utils
@@ -77,10 +76,6 @@ class StoragePool(base.ResourceBase):
identifier = IdentifierField('Identifier') identifier = IdentifierField('Identifier')
"""These identifiers list of this volume""" """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): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a LogicalDrive """A class representing a LogicalDrive
@@ -93,52 +88,35 @@ class StoragePool(base.ResourceBase):
def _get_allocated_volumes_path(self): def _get_allocated_volumes_path(self):
"""Helper function to find the AllocatedVolumes path""" """Helper function to find the AllocatedVolumes path"""
volume_col = self.json.get('AllocatedVolumes') return utils.get_sub_resource_path_by(self, 'AllocatedVolumes')
if not volume_col:
raise exceptions.MissingAttributeError(
attribute='AllocatedVolumes', resource=self._path)
return rsd_lib_utils.get_resource_identity(volume_col)
@property @property
@utils.cache_it
def allocated_volumes(self): def allocated_volumes(self):
"""Property to provide reference to `AllocatedVolumes` instance """Property to provide reference to `AllocatedVolumes` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._allocated_volumes is None: return volume.VolumeCollection(
self._allocated_volumes = volume.VolumeCollection( self._conn, self._get_allocated_volumes_path(),
self._conn, self._get_allocated_volumes_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._allocated_volumes
def _get_allocated_pools_path(self): def _get_allocated_pools_path(self):
"""Helper function to find the AllocatedPools path""" """Helper function to find the AllocatedPools path"""
storage_pool_col = self.json.get('AllocatedPools') return utils.get_sub_resource_path_by(self, 'AllocatedPools')
if not storage_pool_col:
raise exceptions.MissingAttributeError(
attribute='AllocatedPools', resource=self._path)
return rsd_lib_utils.get_resource_identity(storage_pool_col)
@property @property
@utils.cache_it
def allocated_pools(self): def allocated_pools(self):
"""Property to provide reference to `AllocatedPools` instance """Property to provide reference to `AllocatedPools` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._allocated_pools is None: return StoragePoolCollection(
self._allocated_pools = StoragePoolCollection( self._conn, self._get_allocated_pools_path(),
self._conn, self._get_allocated_pools_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._allocated_pools
def refresh(self):
super(StoragePool, self).refresh()
self._allocated_volumes = None
self._allocated_pools = None
class StoragePoolCollection(base.ResourceCollectionBase): class StoragePoolCollection(base.ResourceCollectionBase):

View File

@@ -15,14 +15,13 @@
import logging import logging
from sushy import exceptions
from sushy.resources import base 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 endpoint
from rsd_lib.resources.v2_3.storage_service import drive 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 storage_pool
from rsd_lib.resources.v2_3.storage_service import volume from rsd_lib.resources.v2_3.storage_service import volume
from rsd_lib import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -47,14 +46,6 @@ class StorageService(base.ResourceBase):
status = StatusField('Status') status = StatusField('Status')
"""The storage service 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): def __init__(self, connector, identity, redfish_version=None):
"""A class representing a StorageService """A class representing a StorageService
@@ -68,98 +59,67 @@ class StorageService(base.ResourceBase):
def _get_volume_collection_path(self): def _get_volume_collection_path(self):
"""Helper function to find the VolumeCollection path""" """Helper function to find the VolumeCollection path"""
volume_col = self.json.get('Volumes') return utils.get_sub_resource_path_by(self, 'Volumes')
if not volume_col:
raise exceptions.MissingAttributeError(attribute='Volumes',
resource=self._path)
return utils.get_resource_identity(volume_col)
@property @property
@utils.cache_it
def volumes(self): def volumes(self):
"""Property to provide reference to `VolumeCollection` instance """Property to provide reference to `VolumeCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._volumes is None: return volume.VolumeCollection(
self._volumes = volume.VolumeCollection( self._conn, self._get_volume_collection_path(),
self._conn, self._get_volume_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._volumes
def _get_storage_pool_collection_path(self): def _get_storage_pool_collection_path(self):
"""Helper function to find the StoragePoolCollection path""" """Helper function to find the StoragePoolCollection path"""
storage_pool_col = self.json.get('StoragePools') return utils.get_sub_resource_path_by(self, 'StoragePools')
if not storage_pool_col:
raise exceptions.MissingAttributeError(attribute='StoragePools',
resource=self._path)
return utils.get_resource_identity(storage_pool_col)
@property @property
@utils.cache_it
def storage_pools(self): def storage_pools(self):
"""Property to provide reference to `StoragePoolCollection` instance """Property to provide reference to `StoragePoolCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._storage_pools is None: return storage_pool.StoragePoolCollection(
self._storage_pools = storage_pool.StoragePoolCollection( self._conn, self._get_storage_pool_collection_path(),
self._conn, self._get_storage_pool_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._storage_pools
def _get_drive_collection_path(self): def _get_drive_collection_path(self):
"""Helper function to find the DriveCollection path""" """Helper function to find the DriveCollection path"""
drive_col = self.json.get('Drives') return utils.get_sub_resource_path_by(self, 'Drives')
if not drive_col:
raise exceptions.MissingAttributeError(attribute='Drives',
resource=self._path)
return utils.get_resource_identity(drive_col)
@property @property
@utils.cache_it
def drives(self): def drives(self):
"""Property to provide reference to `DriveCollection` instance """Property to provide reference to `DriveCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._drives is None: return drive.DriveCollection(
self._drives = drive.DriveCollection( self._conn, self._get_drive_collection_path(),
self._conn, self._get_drive_collection_path(), redfish_version=self.redfish_version)
redfish_version=self.redfish_version)
return self._drives
def _get_endpoint_collection_path(self): def _get_endpoint_collection_path(self):
"""Helper function to find the EndpointCollection path""" """Helper function to find the EndpointCollection path"""
endpoint_col = self.json.get('Endpoints') return utils.get_sub_resource_path_by(self, 'Endpoints')
if not endpoint_col:
raise exceptions.MissingAttributeError(attribute='Endpoints',
resource=self._path)
return utils.get_resource_identity(endpoint_col)
@property @property
@utils.cache_it
def endpoints(self): def endpoints(self):
"""Property to provide reference to `EndpointCollection` instance """Property to provide reference to `EndpointCollection` instance
It is calculated once when it is queried for the first time. On It is calculated once when it is queried for the first time. On
refresh, this property is reset. refresh, this property is reset.
""" """
if self._endpoints is None: return endpoint.EndpointCollection(
self._endpoints = endpoint.EndpointCollection( self._conn, self._get_endpoint_collection_path(),
self._conn, self._get_endpoint_collection_path(), redfish_version=self.redfish_version)
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
class StorageServiceCollection(base.ResourceCollectionBase): class StorageServiceCollection(base.ResourceCollectionBase):

View File

@@ -47,7 +47,6 @@ class ACLTestCase(testtools.TestCase):
self.acl_inst.name) self.acl_inst.name)
self.assertEqual('Switch ACL', self.acl_inst.description) self.assertEqual('Switch ACL', self.acl_inst.description)
self.assertEqual({}, self.acl_inst.oem) self.assertEqual({}, self.acl_inst.oem)
self.assertIsNone(self.acl_inst._rules)
def test__get_acl_rule_collection_path(self): def test__get_acl_rule_collection_path(self):
self.assertEqual( self.assertEqual(
@@ -57,12 +56,10 @@ class ACLTestCase(testtools.TestCase):
def test__get_acl_rule_collection_path_missing_attr(self): def test__get_acl_rule_collection_path_missing_attr(self):
self.acl_inst._json.pop('Rules') self.acl_inst._json.pop('Rules')
self.assertRaisesRegex( self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute ACLRule', exceptions.MissingAttributeError, 'attribute Rules',
self.acl_inst._get_acl_rule_collection_path) self.acl_inst._get_acl_rule_collection_path)
def test_acl_rule(self): def test_acl_rule(self):
# check for the underpath variable value
self.assertIsNone(self.acl_inst._rules)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'ethernet_switch_acl.json', 'r') as f: 'ethernet_switch_acl.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.acl_inst.refresh()
# | WHEN & THEN | self.acl_inst.invalidate()
self.assertIsNone(self.acl_inst._rules) self.acl_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -57,8 +57,6 @@ class EthernetSwtichTestCase(testtools.TestCase):
self.assertEqual('TOR', self.ethernet_switch_inst.role) self.assertEqual('TOR', self.ethernet_switch_inst.role)
self.assertEqual('Enabled', self.ethernet_switch_inst.status.state) self.assertEqual('Enabled', self.ethernet_switch_inst.status.state)
self.assertEqual('OK', self.ethernet_switch_inst.status.health) 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.assertEqual('/redfish/v1/Chassis/FabricModule1',
self.ethernet_switch_inst.links.chassis) self.ethernet_switch_inst.links.chassis)
self.assertEqual(('/redfish/v1/Managers/Manager1',), self.assertEqual(('/redfish/v1/Managers/Manager1',),
@@ -76,8 +74,6 @@ class EthernetSwtichTestCase(testtools.TestCase):
self.ethernet_switch_inst._get_port_collection_path) self.ethernet_switch_inst._get_port_collection_path)
def test_ports(self): def test_ports(self):
# check for the underpath variable value
self.assertIsNone(self.ethernet_switch_inst._ports)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'ethernet_switch.json', 'r') as f: 'ethernet_switch.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.ethernet_switch_inst.refresh()
# | WHEN & THEN | self.ethernet_switch_inst.invalidate()
self.assertIsNone(self.ethernet_switch_inst._ports) self.ethernet_switch_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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() self.ethernet_switch_inst._get_acl_collection_path()
def test_acl(self): def test_acl(self):
# check for the underneath variable value
self.assertIsNone(self.ethernet_switch_inst._acls)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'ethernet_switch.json', 'r') as f: 'ethernet_switch.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.ethernet_switch_inst.refresh()
# | WHEN & THEN | self.ethernet_switch_inst.invalidate()
self.assertIsNone(self.ethernet_switch_inst._acls) self.ethernet_switch_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -81,8 +81,6 @@ class PortTestCase(testtools.TestCase):
self.assertEqual('Logical', self.port_inst.port_class) self.assertEqual('Logical', self.port_inst.port_class)
self.assertEqual('LinkAggregationStatic', self.port_inst.port_mode) self.assertEqual('LinkAggregationStatic', self.port_inst.port_mode)
self.assertEqual('Upstream', self.port_inst.port_type) self.assertEqual('Upstream', self.port_inst.port_type)
self.assertIsNone(self.port_inst._vlans)
self.assertIsNone(self.port_inst._static_macs)
self.assertEqual( self.assertEqual(
'/redfish/v1/EthernetSwitches/Switch1/Ports/Port1/VLANs/VLAN1', '/redfish/v1/EthernetSwitches/Switch1/Ports/Port1/VLANs/VLAN1',
self.port_inst.links.primary_vlan) self.port_inst.links.primary_vlan)
@@ -109,8 +107,6 @@ class PortTestCase(testtools.TestCase):
self.port_inst._get_static_mac_collection_path) self.port_inst._get_static_mac_collection_path)
def test_static_mac(self): def test_static_mac(self):
# checkou for the underpath variable value
self.assertIsNone(self.port_inst._static_macs)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'ethernet_switch_port.json', 'r') as f: 'ethernet_switch_port.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.port_inst.refresh()
# | WHEN & THEN | self.port_inst.invalidate()
self.assertIsNone(self.port_inst._static_macs) self.port_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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) self.port_inst._get_vlan_collection_path)
def test_vlan(self): def test_vlan(self):
# checkou for the underpath variable value
self.assertIsNone(self.port_inst._vlans)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'ethernet_switch_port.json', 'r') as f: 'ethernet_switch_port.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.port_inst.refresh()
# | WHEN & THEN | self.port_inst.invalidate()
self.assertIsNone(self.port_inst._vlans) self.port_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -48,8 +48,6 @@ class FabricTestCase(testtools.TestCase):
self.assertEqual(5, self.fabric_inst.max_zones) self.assertEqual(5, self.fabric_inst.max_zones)
self.assertEqual('Enabled', self.fabric_inst.status.state) self.assertEqual('Enabled', self.fabric_inst.status.state)
self.assertEqual('OK', self.fabric_inst.status.health) 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): def test__get_endpoint_collection_path(self):
expected = '/redfish/v1/Fabrics/PCIe/Endpoints' expected = '/redfish/v1/Fabrics/PCIe/Endpoints'
@@ -63,8 +61,6 @@ class FabricTestCase(testtools.TestCase):
self.fabric_inst._get_endpoint_collection_path) self.fabric_inst._get_endpoint_collection_path)
def test_endpoints(self): def test_endpoints(self):
# check for the underneath variable value
self.assertIsNone(self.fabric_inst._endpoints)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.fabric_inst.refresh()
# | WHEN & THEN | self.fabric_inst.invalidate()
self.assertIsNone(self.fabric_inst._endpoints) self.fabric_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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) self.fabric_inst._get_switch_collection_path)
def test_switches(self): def test_switches(self):
self.assertIsNone(self.fabric_inst._switches)
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'switch_collection.json', 'r') as f: 'switch_collection.json', 'r') as f:
@@ -142,8 +136,8 @@ class FabricTestCase(testtools.TestCase):
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.fabric_inst.refresh() self.fabric_inst.invalidate()
self.assertIsNone(self.fabric_inst._switches) self.fabric_inst.refresh(force=False)
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'switch_collection.json', 'r') as f: 'switch_collection.json', 'r') as f:
@@ -158,8 +152,6 @@ class FabricTestCase(testtools.TestCase):
self.fabric_inst._get_zone_collection_path) self.fabric_inst._get_zone_collection_path)
def test_zones(self): def test_zones(self):
# check for the underneath variable value
self.assertIsNone(self.fabric_inst._zones)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.fabric_inst.refresh()
# | WHEN & THEN | self.fabric_inst.invalidate()
self.assertIsNone(self.fabric_inst._zones) self.fabric_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -49,8 +49,6 @@ class ZoneTestCase(testtools.TestCase):
self.assertEqual('OK', self.zone_inst.status.health) self.assertEqual('OK', self.zone_inst.status.health)
def test_endpoints(self): def test_endpoints(self):
# check for the underneath variable value
self.assertIsNone(self.zone_inst._endpoints)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'zone.json', 'r') as f: 'zone.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.zone_inst.refresh()
# | WHEN & THEN | self.zone_inst.invalidate()
self.assertIsNone(self.zone_inst._endpoints) self.zone_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -319,7 +319,7 @@ class NodeTestCase(testtools.TestCase):
def test__get_system_path_missing_systems_attr(self): def test__get_system_path_missing_systems_attr(self):
self.node_inst._json.get('Links').pop('ComputerSystem') self.node_inst._json.get('Links').pop('ComputerSystem')
self.assertRaisesRegex( self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute System', exceptions.MissingAttributeError, 'attribute Links/ComputerSystem',
self.node_inst._get_system_path) self.node_inst._get_system_path)
def test_memory_summary_missing_attr(self): def test_memory_summary_missing_attr(self):
@@ -380,8 +380,6 @@ class NodeTestCase(testtools.TestCase):
self.assertEqual(None, self.node_inst.memory_summary) self.assertEqual(None, self.node_inst.memory_summary)
def test_system(self): def test_system(self):
# check for the underneath variable value
self.assertIsNone(self.node_inst._system)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json', 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... # On refreshing the system instance...
with open('rsd_lib/tests/unit/json_samples/v2_1/node.json', 'r') as f: 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.conn.get.return_value.json.return_value = json.loads(f.read())
self.node_inst.refresh()
# | WHEN & THEN | self.node_inst.invalidate()
self.assertIsNone(self.node_inst._system) self.node_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json', with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',

View File

@@ -48,9 +48,6 @@ class StorageServiceTestCase(testtools.TestCase):
self.assertEqual('Enabled', self.storage_service_inst.status.state) 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)
self.assertEqual('OK', self.storage_service_inst.status.health_rollup) 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): def test__get_logical_drive_collection_path_missing_processors_attr(self):
self.storage_service_inst._json.pop('LogicalDrives') self.storage_service_inst._json.pop('LogicalDrives')
@@ -59,8 +56,6 @@ class StorageServiceTestCase(testtools.TestCase):
self.storage_service_inst._get_logical_drive_collection_path) self.storage_service_inst._get_logical_drive_collection_path)
def test_logical_drives(self): def test_logical_drives(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._logical_drives)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._logical_drives) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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): def test__get_physical_drive_collection_path_missing_processors_attr(self):
self.storage_service_inst._json.pop('Drives') self.storage_service_inst._json.pop('Drives')
self.assertRaisesRegex( self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute PhysicalDrives', exceptions.MissingAttributeError, 'attribute Drives',
self.storage_service_inst._get_physical_drive_collection_path) self.storage_service_inst._get_physical_drive_collection_path)
def test_physical_drives(self): def test_physical_drives(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._physical_drives)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._physical_drives) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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) self.storage_service_inst._get_remote_target_collection_path)
def test_remote_targets(self): def test_remote_targets(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._remote_targets)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._remote_targets) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -54,8 +54,6 @@ class SystemTestCase(testtools.TestCase):
self.system_inst._get_memory_collection_path() self.system_inst._get_memory_collection_path()
def test_memory(self): def test_memory(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._memory)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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', with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._memory) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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): def test__get_storage_collection_path_missing_systems_attr(self):
self.system_inst._json.pop('Storage') self.system_inst._json.pop('Storage')
with self.assertRaisesRegex( with self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute StorageSubsystem'): exceptions.MissingAttributeError, 'attribute Storage'):
self.system_inst._get_storage_subsystem_collection_path() self.system_inst._get_storage_subsystem_collection_path()
def test_storage_subsystem(self): def test_storage_subsystem(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._storage_subsystem)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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', with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._storage_subsystem) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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): def test__get_network_interface_collection_path_missing_systems_attr(self):
self.system_inst._json.pop('EthernetInterfaces') self.system_inst._json.pop('EthernetInterfaces')
with self.assertRaisesRegex( with self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute NetworkInterface'): exceptions.MissingAttributeError, 'attribute EthernetInterfaces'):
self.system_inst._get_network_interface_collection_path() self.system_inst._get_network_interface_collection_path()
def test_network_interface(self): def test_network_interface(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._network_interface)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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', with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._network_interface) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'

View File

@@ -35,8 +35,6 @@ class EthernetSwitchTestCase(testtools.TestCase):
redfish_version='1.0.2') redfish_version='1.0.2')
def test_ports(self): def test_ports(self):
# check for the underpath variable value
self.assertIsNone(self.ethernet_switch_inst._ports)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_2/'
'ethernet_switch.json', 'r') as f: 'ethernet_switch.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.ethernet_switch_inst.refresh()
# | WHEN & THEN | self.ethernet_switch_inst.invalidate()
self.assertIsNone(self.ethernet_switch_inst._ports) self.ethernet_switch_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -48,8 +48,6 @@ class PortTestCase(testtools.TestCase):
self.port_inst._get_metrics_path() self.port_inst._get_metrics_path()
def test_metrics(self): def test_metrics(self):
# check for the underneath variable value
self.assertIsNone(self.port_inst._metrics)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_2/'
'ethernet_switch_port.json', 'r') as f: 'ethernet_switch_port.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.port_inst.refresh()
# | WHEN & THEN | self.port_inst.invalidate()
self.assertIsNone(self.port_inst._metrics) self.port_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -79,12 +79,10 @@ class MemoryTestCase(testtools.TestCase):
def test__get_metrics_path_missing_systems_attr(self): def test__get_metrics_path_missing_systems_attr(self):
self.memory_inst._json.pop('Metrics') self.memory_inst._json.pop('Metrics')
with self.assertRaisesRegex( with self.assertRaisesRegex(
exceptions.MissingAttributeError, 'attribute Memory Metrics'): exceptions.MissingAttributeError, 'attribute Metrics'):
self.memory_inst._get_metrics_path() self.memory_inst._get_metrics_path()
def test_metrics(self): def test_metrics(self):
# check for the underneath variable value
self.assertIsNone(self.memory_inst._metrics)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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', with open('rsd_lib/tests/unit/json_samples/v2_2/memory.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.memory_inst.refresh()
# | WHEN & THEN | self.memory_inst.invalidate()
self.assertIsNone(self.memory_inst._metrics) self.memory_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -63,13 +63,11 @@ class ProcessorTestCase(testtools.TestCase):
def test__get_metrics_path_missing_systems_attr(self): def test__get_metrics_path_missing_systems_attr(self):
self.processor_inst._json.get('Oem').get('Intel_RackScale')\ self.processor_inst._json.get('Oem').get('Intel_RackScale')\
.pop('Metrics') .pop('Metrics')
with self.assertRaisesRegex( with self.assertRaisesRegex(exceptions.MissingAttributeError,
exceptions.MissingAttributeError, 'attribute Processor Metrics'): 'attribute Oem/Intel_RackScale/Metrics'):
self.processor_inst._get_metrics_path() self.processor_inst._get_metrics_path()
def test_metrics(self): def test_metrics(self):
# check for the underneath variable value
self.assertIsNone(self.processor_inst._metrics)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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', with open('rsd_lib/tests/unit/json_samples/v2_2/processor.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.processor_inst.refresh()
# | WHEN & THEN | self.processor_inst.invalidate()
self.assertIsNone(self.processor_inst._metrics) self.processor_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -51,13 +51,11 @@ class SystemTestCase(testtools.TestCase):
def test__get_metrics_path_missing_systems_attr(self): def test__get_metrics_path_missing_systems_attr(self):
self.system_inst._json.get('Oem').get('Intel_RackScale').pop('Metrics') self.system_inst._json.get('Oem').get('Intel_RackScale').pop('Metrics')
with self.assertRaisesRegex( with self.assertRaisesRegex(exceptions.MissingAttributeError,
exceptions.MissingAttributeError, 'attribute Metrics'): 'attribute Oem/Intel_RackScale/Metrics'):
self.system_inst._get_metrics_path() self.system_inst._get_metrics_path()
def test_metrics(self): def test_metrics(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._metrics)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/system_metrics.json', 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', with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._metrics) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/system_metrics.json', with open('rsd_lib/tests/unit/json_samples/v2_2/system_metrics.json',
@@ -104,8 +102,6 @@ class SystemTestCase(testtools.TestCase):
metrics.Metrics) metrics.Metrics)
def test_processors(self): def test_processors(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._processors)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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', with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._processors) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'
@@ -152,8 +148,6 @@ class SystemTestCase(testtools.TestCase):
processor.ProcessorCollection) processor.ProcessorCollection)
def test_memory(self): def test_memory(self):
# check for the underneath variable value
self.assertIsNone(self.system_inst._memory)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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', with open('rsd_lib/tests/unit/json_samples/v2_2/system.json',
'r') as f: 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.system_inst.refresh()
# | WHEN & THEN | self.system_inst.invalidate()
self.assertIsNone(self.system_inst._memory) self.system_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -54,8 +54,6 @@ class TelemetryTestCase(testtools.TestCase):
self.telemetry_inst._get_metric_definitions_path() self.telemetry_inst._get_metric_definitions_path()
def test_metric_definitions(self): def test_metric_definitions(self):
# check for the underneath variable value
self.assertIsNone(self.telemetry_inst._metric_definitions)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_2/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_2/'
'telemetry_service.json', 'r') as f: 'telemetry_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.telemetry_inst.refresh()
# | WHEN & THEN | self.telemetry_inst.invalidate()
self.assertIsNone(self.telemetry_inst._metric_definitions) self.telemetry_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_2/' with open('rsd_lib/tests/unit/json_samples/v2_2/'

View File

@@ -52,8 +52,6 @@ class TestEthernetSwtich(base.TestCase):
self.assertEqual('TOR', self.ethernet_switch_inst.role) self.assertEqual('TOR', self.ethernet_switch_inst.role)
self.assertEqual('Enabled', self.ethernet_switch_inst.status.state) self.assertEqual('Enabled', self.ethernet_switch_inst.status.state)
self.assertEqual('OK', self.ethernet_switch_inst.status.health) 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.assertEqual('/redfish/v1/Chassis/FabricModule1',
self.ethernet_switch_inst.links.chassis) self.ethernet_switch_inst.links.chassis)
self.assertEqual(('/redfish/v1/Managers/PSME',), self.assertEqual(('/redfish/v1/Managers/PSME',),

View File

@@ -60,8 +60,6 @@ class FabricTestCase(testtools.TestCase):
self.fabric_inst._get_endpoint_collection_path) self.fabric_inst._get_endpoint_collection_path)
def test_endpoints(self): def test_endpoints(self):
# check for the underneath variable value
self.assertIsNone(self.fabric_inst._endpoints)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.fabric_inst.refresh()
# | WHEN & THEN | self.fabric_inst.invalidate()
self.assertIsNone(self.fabric_inst._endpoints) self.fabric_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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) self.fabric_inst._get_zone_collection_path)
def test_zones(self): def test_zones(self):
# check for the underneath variable value
self.assertIsNone(self.fabric_inst._zones)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.fabric_inst.refresh()
# | WHEN & THEN | self.fabric_inst.invalidate()
self.assertIsNone(self.fabric_inst._zones) self.fabric_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' with open('rsd_lib/tests/unit/json_samples/v2_3/'

View File

@@ -49,8 +49,6 @@ class ZoneTestCase(testtools.TestCase):
self.assertEqual('OK', self.zone_inst.status.health) self.assertEqual('OK', self.zone_inst.status.health)
def test_endpoints(self): def test_endpoints(self):
# check for the underneath variable value
self.assertIsNone(self.zone_inst._endpoints)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'zone.json', 'r') as f: 'zone.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.zone_inst.refresh()
# | WHEN & THEN | self.zone_inst.invalidate()
self.assertIsNone(self.zone_inst._endpoints) self.zone_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' with open('rsd_lib/tests/unit/json_samples/v2_3/'

View File

@@ -41,12 +41,8 @@ class AttachResourceActionInfoTestCase(testtools.TestCase):
self.attach_action_info.identity) self.attach_action_info.identity)
self.assertEqual('Attach Resource ActionInfo', self.assertEqual('Attach Resource ActionInfo',
self.attach_action_info.name) self.attach_action_info.name)
self.assertIsNone(self.attach_action_info._parameters)
def test_parameters(self): def test_parameters(self):
# check for the underneath variable value
self.assertIsNone(self.attach_action_info._parameters)
# | WHEN | # | WHEN |
actual_parameters = self.attach_action_info.parameters actual_parameters = self.attach_action_info.parameters
# | THEN | # | THEN |
@@ -95,10 +91,8 @@ class AttachResourceActionInfoTestCase(testtools.TestCase):
] ]
self.assertEqual(expected, self.attach_action_info.parameters) self.assertEqual(expected, self.attach_action_info.parameters)
# On refreshing the storage service instance... self.attach_action_info.invalidate()
self.attach_action_info.refresh() self.attach_action_info.refresh(force=False)
# | WHEN & THEN |
self.assertIsNone(self.attach_action_info._parameters)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' with open('rsd_lib/tests/unit/json_samples/v2_3/'

View File

@@ -92,8 +92,6 @@ class StoragePoolTestCase(testtools.TestCase):
self.storage_pool_inst._get_allocated_volumes_path) self.storage_pool_inst._get_allocated_volumes_path)
def test_allocated_volumes(self): def test_allocated_volumes(self):
# check for the underneath variable value
self.assertIsNone(self.storage_pool_inst._allocated_volumes)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'storage_pool.json', 'r') as f: 'storage_pool.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_pool_inst.refresh()
# | WHEN & THEN | self.storage_pool_inst.invalidate()
self.assertIsNone(self.storage_pool_inst._allocated_volumes) self.storage_pool_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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) self.storage_pool_inst._get_allocated_pools_path)
def test_allocated_pools(self): def test_allocated_pools(self):
# check for the underneath variable value
self.assertIsNone(self.storage_pool_inst._allocated_pools)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'storage_pool.json', 'r') as f: 'storage_pool.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_pool_inst.refresh()
# | WHEN & THEN | self.storage_pool_inst.invalidate()
self.assertIsNone(self.storage_pool_inst._allocated_pools) self.storage_pool_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' with open('rsd_lib/tests/unit/json_samples/v2_3/'

View File

@@ -49,7 +49,6 @@ class StorageServiceTestCase(testtools.TestCase):
self.assertEqual('Enabled', self.storage_service_inst.status.state) 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)
self.assertEqual('OK', self.storage_service_inst.status.health_rollup) self.assertEqual('OK', self.storage_service_inst.status.health_rollup)
self.assertIsNone(self.storage_service_inst._volumes)
def test__get_volume_collection_path(self): def test__get_volume_collection_path(self):
expected = '/redfish/v1/StorageServices/1/Volumes' expected = '/redfish/v1/StorageServices/1/Volumes'
@@ -63,8 +62,6 @@ class StorageServiceTestCase(testtools.TestCase):
self.storage_service_inst._get_volume_collection_path) self.storage_service_inst._get_volume_collection_path)
def test_volumes(self): def test_volumes(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._volumes)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._volumes) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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) self.storage_service_inst._get_storage_pool_collection_path)
def test_storage_pools(self): def test_storage_pools(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._storage_pools)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._storage_pools) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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) self.storage_service_inst._get_drive_collection_path)
def test_drives(self): def test_drives(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._drives)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_3/'
'storage_service.json', 'r') as f: 'storage_service.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._drives) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_3/' 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) self.storage_service_inst._get_endpoint_collection_path)
def test_endpoints(self): def test_endpoints(self):
# check for the underneath variable value
self.assertIsNone(self.storage_service_inst._endpoints)
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open('rsd_lib/tests/unit/json_samples/v2_1/' 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/' with open('rsd_lib/tests/unit/json_samples/v2_1/'
'fabric.json', 'r') as f: 'fabric.json', 'r') as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
self.storage_service_inst.refresh()
# | WHEN & THEN | self.storage_service_inst.invalidate()
self.assertIsNone(self.storage_service_inst._endpoints) self.storage_service_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open('rsd_lib/tests/unit/json_samples/v2_1/' with open('rsd_lib/tests/unit/json_samples/v2_1/'