Make message registries available to all resources

This patch makes parsed message registries accessible to all sushy
resource objects for consumption. Prior to that, only System resource
had access to message registries what proved insufficient.

Change-Id: Ib1e24ea0b2ab81a4dad207ef8f76f1cef3a799c3
Co-Authored-By: Richard.Pioso@dell.com
This commit is contained in:
Ilya Etingof 2019-07-12 16:58:45 +02:00
parent 83c1a332f2
commit 9351999582
32 changed files with 278 additions and 184 deletions

View File

@ -138,12 +138,12 @@ class Sushy(base.ResourceBase):
super(Sushy, self).__init__(
connector or sushy_connector.Connector(base_url, verify=verify),
path=self._root_prefix)
self._public_connector = public_connector or requests
self._language = language
self._base_url = base_url
self._auth = auth
self._auth.set_context(self, self._conn)
self._auth.authenticate()
self._public_connector = public_connector or requests
self._language = language
def __del__(self):
if self._auth:
@ -170,8 +170,10 @@ class Sushy(base.ResourceBase):
raise exceptions.MissingAttributeError(
attribute='Systems/@odata.id', resource=self._path)
return system.SystemCollection(self._conn, self._systems_path,
redfish_version=self.redfish_version)
return system.SystemCollection(
self._conn, self._systems_path,
redfish_version=self.redfish_version,
registries=self.registries)
def get_system(self, identity):
"""Given the identity return a System object
@ -181,7 +183,7 @@ class Sushy(base.ResourceBase):
"""
return system.System(self._conn, identity,
redfish_version=self.redfish_version,
registries=self._get_message_registries())
registries=self.registries)
def get_chassis_collection(self):
"""Get the ChassisCollection object
@ -195,7 +197,8 @@ class Sushy(base.ResourceBase):
attribute='Chassis/@odata.id', resource=self._path)
return chassis.ChassisCollection(self._conn, self._chassis_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_chassis(self, identity):
"""Given the identity return a Chassis object
@ -204,7 +207,8 @@ class Sushy(base.ResourceBase):
:returns: The Chassis object
"""
return chassis.Chassis(self._conn, identity,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_fabric_collection(self):
"""Get the FabricCollection object
@ -218,7 +222,8 @@ class Sushy(base.ResourceBase):
attribute='Fabrics/@odata.id', resource=self._path)
return fabric.FabricCollection(self._conn, self._fabrics_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_fabric(self, identity):
"""Given the identity return a Fabric object
@ -227,7 +232,8 @@ class Sushy(base.ResourceBase):
:returns: The Fabric object
"""
return fabric.Fabric(self._conn, identity,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_manager_collection(self):
"""Get the ManagerCollection object
@ -241,7 +247,8 @@ class Sushy(base.ResourceBase):
attribute='Managers/@odata.id', resource=self._path)
return manager.ManagerCollection(self._conn, self._managers_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_manager(self, identity):
"""Given the identity return a Manager object
@ -250,7 +257,8 @@ class Sushy(base.ResourceBase):
:returns: The Manager object
"""
return manager.Manager(self._conn, identity,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def get_session_service(self):
"""Get the SessionService object
@ -273,8 +281,9 @@ class Sushy(base.ResourceBase):
:param identity: The identity of the session resource
:returns: The Session object
"""
return session.Session(self._conn, identity,
redfish_version=self.redfish_version)
return session.Session(
self._conn, identity,
redfish_version=self.redfish_version, registries=self.registries)
def get_update_service(self):
"""Get the UpdateService object
@ -287,7 +296,8 @@ class Sushy(base.ResourceBase):
return updateservice.UpdateService(
self._conn, self._update_service_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def _get_registry_collection(self):
"""Get MessageRegistryFileCollection object
@ -315,9 +325,11 @@ class Sushy(base.ResourceBase):
raise exceptions.MissingAttributeError(
attribute='CompositionService/@odata.id',
resource=self._path)
return compositionservice.CompositionService(
self._conn, self._composition_service_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
def _get_standard_message_registry_collection(self):
"""Load packaged standard message registries
@ -337,26 +349,33 @@ class Sushy(base.ResourceBase):
return message_registries
def _get_message_registries(self):
@property
def registries(self):
"""Gets and combines all message registries together
Fetches all registries if any provided by Redfish service
and combines together with packaged standard registries.
:returns: dict of combined message registries where key is
Registry_name.Major_version.Minor_version and value is registry
itself.
Registry_name.Major_version.Minor_version and value is registry
itself.
"""
if self._registries is None:
standard = self._get_standard_message_registry_collection()
registries = {r.registry_prefix + '.' +
r.registry_version.rsplit('.', 1)[0]: r
for r in standard if r.language == self._language}
registry_col = self._get_registry_collection()
if registry_col:
provided = registry_col.get_members()
registries.update({r.registry: r.get_message_registry(
self._language,
self._public_connector) for r in provided})
standard = self._get_standard_message_registry_collection()
return registries
registries = {r.registry_prefix + '.' +
r.registry_version.rsplit('.', 1)[0]: r
for r in standard if r.language == self._language}
registry_col = self._get_registry_collection()
if registry_col:
provided = registry_col.get_members()
registries.update({r.registry: r.get_message_registry(
self._language,
self._public_connector) for r in provided})
self._registries = registries
return self._registries

View File

@ -349,6 +349,7 @@ class ResourceBase(object):
connector,
path='',
redfish_version=None,
registries=None,
reader=None):
"""A class representing the base of any Redfish resource
@ -358,12 +359,15 @@ class ResourceBase(object):
:param path: sub-URI path to the resource.
:param redfish_version: The version of Redfish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
:param reader: Reader to use to fetch JSON data.
"""
self._conn = connector
self._path = path
self._json = None
self.redfish_version = redfish_version
self._registries = registries
# Note(deray): Indicates if the resource holds stale data or not.
# Starting off with True and eventually gets set to False when
# attribute values are fetched.
@ -477,6 +481,10 @@ class ResourceBase(object):
return oem.get_resource_extension_by_vendor(
self.resource_name, vendor, self)
@property
def registries(self):
return self._registries
@six.add_metaclass(abc.ABCMeta)
class ResourceCollectionBase(ResourceBase):
@ -488,7 +496,7 @@ class ResourceCollectionBase(ResourceBase):
adapter=utils.get_members_identities)
"""A tuple with the members identities"""
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing the base of any Redfish resource collection
It gets inherited from ``ResourceBase`` and invokes the base class
@ -497,9 +505,11 @@ class ResourceCollectionBase(ResourceBase):
:param path: sub-URI path to the resource collection.
:param redfish_version: The version of Redfish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages.
"""
super(ResourceCollectionBase, self).__init__(connector, path,
redfish_version)
super(ResourceCollectionBase, self).__init__(
connector, path, redfish_version, registries)
LOG.debug('Received %(count)d member(s) for %(type)s %(path)s',
{'count': len(self.members_identities),
'type': self.__class__.__name__, 'path': self._path})
@ -520,8 +530,8 @@ class ResourceCollectionBase(ResourceBase):
:returns: The ``_resource_type`` object
:raises: ResourceNotFoundError
"""
return self._resource_type(self._conn, identity,
redfish_version=self.redfish_version)
return self._resource_type(
self._conn, identity, self.redfish_version, self.registries)
@utils.cache_it
def get_members(self):

View File

@ -143,15 +143,19 @@ class Chassis(base.ResourceBase):
_actions = ActionsField('Actions')
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a Chassis
:param connector: A Connector instance
:param identity: The identity of the Chassis resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(Chassis, self).__init__(connector, identity, redfish_version)
super(Chassis, self).__init__(
connector, identity, redfish_version, registries)
def _get_reset_action_element(self):
reset_action = self._actions.reset
@ -233,7 +237,7 @@ class Chassis(base.ResourceBase):
self, ["Links", "ManagedBy"], is_collection=True)
return [manager.Manager(self._conn, path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
for path in paths]
@property
@ -252,7 +256,7 @@ class Chassis(base.ResourceBase):
from sushy.resources.system import system
return [system.System(self._conn, path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
for path in paths]
@property
@ -267,7 +271,7 @@ class Chassis(base.ResourceBase):
return power.Power(
self._conn,
utils.get_sub_resource_path_by(self, 'Power'),
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
@property
@utils.cache_it
@ -281,7 +285,7 @@ class Chassis(base.ResourceBase):
return thermal.Thermal(
self._conn,
utils.get_sub_resource_path_by(self, 'Thermal'),
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
class ChassisCollection(base.ResourceCollectionBase):
@ -290,13 +294,15 @@ class ChassisCollection(base.ResourceCollectionBase):
def _resource_type(self):
return Chassis
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a ChassisCollection
:param connector: A Connector instance
:param path: The canonical path to the Chassis collection resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ChassisCollection, self).__init__(connector, path,
redfish_version)
super(ChassisCollection, self).__init__(
connector, path, redfish_version, registries)

View File

@ -50,18 +50,19 @@ class CompositionService(base.ResourceBase):
service_enabled = base.Field('ServiceEnabled')
"""The status of composition service is enabled"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a CompositionService
:param connector: A connector instance
:param identity: The identity of the CompositionService resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(CompositionService, self).__init__(
connector,
identity,
redfish_version)
connector, identity, redfish_version, registries)
def _get_resource_blocks_collection_path(self):
"""Helper function to find the ResourceBlockCollections path"""
@ -85,7 +86,7 @@ class CompositionService(base.ResourceBase):
"""Property to reference `ResourceBlockCollection` instance"""
return resourceblock.ResourceBlockCollection(
self.conn, self._get_resource_blocks_collection_path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
@property
@utils.cache_it
@ -93,4 +94,4 @@ class CompositionService(base.ResourceBase):
"""Property to reference `ResourceZoneCollection` instance"""
return resourcezone.ResourceZoneCollection(
self.conn, self._get_resource_zones_collection_path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)

View File

@ -74,18 +74,19 @@ class ResourceBlock(base.ResourceBase):
status = common.StatusField('Status')
"""The status of resource block"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a ResourceBlock
:param connector: A Connector instance
:param identity: The identity of the ResourceBlock resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ResourceBlock, self).__init__(
connector,
identity,
redfish_version)
connector, identity, redfish_version, registries)
class ResourceBlockCollection(base.ResourceCollectionBase):
@ -100,13 +101,16 @@ class ResourceBlockCollection(base.ResourceCollectionBase):
def _resource_type(self):
return ResourceBlock
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a ResourceBlockCollection
:param connector: A Connector instance
:param identity: A identity of the ResourceBlock resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ResourceBlockCollection, self).__init__(
connector, identity, redfish_version)
connector, identity, redfish_version, registries)

View File

@ -54,18 +54,19 @@ class ResourceZone(base.ResourceBase):
status = common.StatusField('Status')
"""The resource zone status"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a ResourceZone
:param connector: A Connector instance
:param identity: The identity of the ResourceZone resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ResourceZone, self).__init__(
connector,
identity,
redfish_version)
connector, identity, redfish_version, registries)
class ResourceZoneCollection(base.ResourceCollectionBase):
@ -80,13 +81,16 @@ class ResourceZoneCollection(base.ResourceCollectionBase):
def _resource_type(self):
return ResourceZone
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a ResourceZoneCollection
:param connector: A Connector instance
:param identity: The identity of the ResourceZone resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ResourceZoneCollection, self).__init__(
connector, identity, redfish_version)
connector, identity, redfish_version, registries)

View File

@ -50,22 +50,26 @@ class Fabric(base.ResourceBase):
res_maps.PROTOCOL_TYPE_VALUE_MAP)
"""The protocol being sent over this fabric"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a Fabric
:param connector: A Connector instance
:param identity: The identity of the Fabric resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(Fabric, self).__init__(connector, identity, redfish_version)
super(Fabric, self).__init__(
connector, identity, redfish_version, registries)
@property
@utils.cache_it
def endpoints(self):
return fab_endpoint.EndpointCollection(
self._conn, utils.get_sub_resource_path_by(self, 'Endpoints'),
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
class FabricCollection(base.ResourceCollectionBase):
@ -74,13 +78,15 @@ class FabricCollection(base.ResourceCollectionBase):
def _resource_type(self):
return Fabric
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a FabricCollection
:param connector: A Connector instance
:param path: The canonical path to the Fabric collection resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(FabricCollection, self).__init__(connector, path,
redfish_version)
super(FabricCollection, self).__init__(
connector, path, redfish_version, registries)

View File

@ -84,15 +84,19 @@ class Manager(base.ResourceBase):
_actions = ActionsField('Actions')
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a Manager
:param connector: A Connector instance
:param identity: The identity of the Manager resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(Manager, self).__init__(connector, identity, redfish_version)
super(Manager, self).__init__(
connector, identity, redfish_version, registries)
def get_supported_graphical_console_types(self):
"""Get the supported values for Graphical Console connection types.
@ -193,7 +197,7 @@ class Manager(base.ResourceBase):
def virtual_media(self):
return virtual_media.VirtualMediaCollection(
self._conn, utils.get_sub_resource_path_by(self, 'VirtualMedia'),
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
@property
@utils.cache_it
@ -211,7 +215,7 @@ class Manager(base.ResourceBase):
from sushy.resources.system import system
return [system.System(self._conn, path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
for path in paths]
@property
@ -230,7 +234,7 @@ class Manager(base.ResourceBase):
from sushy.resources.chassis import chassis
return [chassis.Chassis(self._conn, path,
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
for path in paths]
@ -240,13 +244,15 @@ class ManagerCollection(base.ResourceCollectionBase):
def _resource_type(self):
return Manager
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a ManagerCollection
:param connector: A Connector instance
:param path: The canonical path to the Manager collection resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ManagerCollection, self).__init__(connector, path,
redfish_version)
super(ManagerCollection, self).__init__(
connector, path, redfish_version, registries)

View File

@ -37,15 +37,19 @@ class Session(base.ResourceBase):
username = base.Field('UserName')
"""The UserName for the account for this session."""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a Session
:param connector: A Connector instance
:param identity: The identity of the Session resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(Session, self).__init__(connector, identity, redfish_version)
super(Session, self).__init__(
connector, identity, redfish_version, registries)
def delete(self):
"""Method for deleting a Session.
@ -67,13 +71,16 @@ class SessionCollection(base.ResourceCollectionBase):
def _resource_type(self):
return Session
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a SessionCollection
:param connector: A Connector instance
:param identity: The identity of the Session resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(SessionCollection, self).__init__(
connector, identity, redfish_version)
connector, identity, redfish_version, registries)

View File

@ -43,17 +43,21 @@ class SessionService(base.ResourceBase):
session_timeout = base.Field('SessionTimeout')
"""The session service timeout"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a SessionService
:param connector: A Connector instance
:param identity: The identity of the SessionService resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
try:
super(SessionService, self).__init__(
connector, identity, redfish_version)
connector, identity, redfish_version, registries)
except exceptions.AccessError as ae:
LOG.warning('Received access error "%(ae)s". '
'Unable to refresh SessionService.',
@ -77,7 +81,7 @@ class SessionService(base.ResourceBase):
"""
return session.SessionCollection(
self._conn, self._get_sessions_collection_path(),
redfish_version=self.redfish_version)
self.redfish_version, self.registries)
def close_session(self, session_uri):
"""This function is for closing a session based on its id.

View File

@ -31,9 +31,7 @@ class ActionsField(base.CompositeField):
class Bios(base.ResourceBase):
def __init__(self, connector, path, registries, *args, **kwargs):
super(Bios, self).__init__(connector, path, *args, **kwargs)
self._registries = registries
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a Bios
:param connector: A Connector instance
@ -41,6 +39,8 @@ class Bios(base.ResourceBase):
:param registries: Dict of message registries to be used when
parsing messages of attribute update status
"""
super(Bios, self).__init__(
connector, path, redfish_version, registries)
identity = base.Field('Id', required=True)
"""The Bios resource identity string"""

View File

@ -92,15 +92,19 @@ class Processor(base.ResourceBase):
total_threads = base.Field('TotalThreads', adapter=utils.int_or_none)
"""The total number of execution threads supported by this processor"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a Processor
:param connector: A Connector instance
:param identity: The identity of the processor
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(Processor, self).__init__(connector, identity, redfish_version)
super(Processor, self).__init__(
connector, identity, redfish_version, registries)
def _get_processor_collection_path(self):
"""Helper function to find the ProcessorCollection path"""
@ -152,13 +156,15 @@ class ProcessorCollection(base.ResourceCollectionBase):
return ProcessorSummary(count=count, architecture=architecture)
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a ProcessorCollection
:param connector: A Connector instance
:param path: The canonical path to the Processor collection resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(ProcessorCollection, self).__init__(connector, path,
redfish_version)
super(ProcessorCollection, self).__init__(
connector, path, redfish_version, registries)

View File

@ -81,7 +81,8 @@ class Storage(base.ResourceBase):
:raises: ResourceNotFoundError
"""
return drive.Drive(self._conn, drive_identity,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
@property
@utils.cache_it

View File

@ -144,10 +144,10 @@ class System(base.ResourceBase):
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of registries to be used in any resource
that needs registries to parse messages
that needs registries to parse messages.
"""
super(System, self).__init__(connector, identity, redfish_version)
self._registries = registries
super(System, self).__init__(
connector, identity, redfish_version, registries)
def _get_reset_action_element(self):
reset_action = self._actions.reset
@ -291,7 +291,8 @@ class System(base.ResourceBase):
"""
return processor.ProcessorCollection(
self._conn, self._get_processor_collection_path(),
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
@property
@utils.cache_it
@ -305,7 +306,8 @@ class System(base.ResourceBase):
return ethernet_interface.EthernetInterfaceCollection(
self._conn,
utils.get_sub_resource_path_by(self, "EthernetInterfaces"),
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
@property
@utils.cache_it
@ -320,7 +322,7 @@ class System(base.ResourceBase):
self._conn,
utils.get_sub_resource_path_by(self, 'Bios'),
redfish_version=self.redfish_version,
registries=self._registries)
registries=self.registries)
@property
@utils.cache_it
@ -341,7 +343,8 @@ class System(base.ResourceBase):
"""
return sys_simple_storage.SimpleStorageCollection(
self._conn, utils.get_sub_resource_path_by(self, "SimpleStorage"),
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
@property
@utils.cache_it
@ -363,7 +366,8 @@ class System(base.ResourceBase):
"""
return sys_storage.StorageCollection(
self._conn, utils.get_sub_resource_path_by(self, "Storage"),
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
@property
@utils.cache_it
@ -380,7 +384,8 @@ class System(base.ResourceBase):
self, ["Links", "ManagedBy"], is_collection=True)
return [manager.Manager(self._conn, path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
for path in paths]
@property
@ -398,7 +403,8 @@ class System(base.ResourceBase):
self, ["Links", "Chassis"], is_collection=True)
return [chassis.Chassis(self._conn, path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version,
registries=self.registries)
for path in paths]
@ -408,13 +414,15 @@ class SystemCollection(base.ResourceCollectionBase):
def _resource_type(self):
return System
def __init__(self, connector, path, redfish_version=None):
def __init__(self, connector, path, redfish_version=None, registries=None):
"""A class representing a ComputerSystemCollection
:param connector: A Connector instance
:param path: The canonical path to the System collection resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(SystemCollection, self).__init__(connector, path,
redfish_version)
super(SystemCollection, self).__init__(
connector, path, redfish_version, registries)

View File

@ -58,18 +58,19 @@ class SoftwareInventory(base.ResourceBase):
version = base.Field('Version')
"""The version of the software"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity,
redfish_version=None, registries=None):
"""A class representing a SoftwareInventory
:param connector: A Connector instance
:param identity: The identity of the SoftwareInventory resources
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(SoftwareInventory, self).__init__(
connector,
identity,
redfish_version)
connector, identity, redfish_version, registries)
class SoftwareInventoryCollection(base.ResourceCollectionBase):
@ -84,13 +85,16 @@ class SoftwareInventoryCollection(base.ResourceCollectionBase):
def _resource_type(self):
return SoftwareInventory
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity,
redfish_version=None, registries=None):
"""A class representing a SoftwareInventoryCollection
:param connector: A Connector instance
:param identity: The identity of SoftwareInventory resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(SoftwareInventoryCollection, self).__init__(
connector, identity, redfish_version)
connector, identity, redfish_version, registries)

View File

@ -60,18 +60,19 @@ class UpdateService(base.ResourceBase):
_actions = ActionsField('Actions', required=True)
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""A class representing a UpdateService
:param connector: A Connector instance
:param identity: The identity of the UpdateService resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of given version
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages
"""
super(UpdateService, self).__init__(
connector,
identity,
redfish_version)
connector, identity, redfish_version, registries)
def _get_simple_update_element(self):
simple_update_action = self._actions.simple_update
@ -155,7 +156,7 @@ class UpdateService(base.ResourceBase):
"""Property to reference SoftwareInventoryCollection instance"""
return softwareinventory.SoftwareInventoryCollection(
self._conn, self._get_software_inventory_collection_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version, registries=self.registries)
@property
@utils.cache_it
@ -163,4 +164,4 @@ class UpdateService(base.ResourceBase):
"""Property to reference SoftwareInventoryCollection instance"""
return softwareinventory.SoftwareInventoryCollection(
self._conn, self._get_software_inventory_collection_path,
redfish_version=self.redfish_version)
redfish_version=self.redfish_version, registries=self.registries)

View File

@ -176,22 +176,22 @@ class ChassisCollectionTestCase(base.TestCase):
self.chassis.get_member('/redfish/v1/Chassis/MultiBladeEncl')
chassis_mock.assert_called_once_with(
self.chassis._conn, '/redfish/v1/Chassis/MultiBladeEncl',
redfish_version=self.chassis.redfish_version)
self.chassis.redfish_version, None)
@mock.patch.object(chassis, 'Chassis', autospec=True)
def test_get_members(self, chassis_mock):
members = self.chassis.get_members()
calls = [
mock.call(self.chassis._conn, '/redfish/v1/Chassis/MultiBladeEncl',
redfish_version=self.chassis.redfish_version),
self.chassis.redfish_version, None),
mock.call(self.chassis._conn, '/redfish/v1/Chassis/Blade1',
redfish_version=self.chassis.redfish_version),
self.chassis.redfish_version, None),
mock.call(self.chassis._conn, '/redfish/v1/Chassis/Blade2',
redfish_version=self.chassis.redfish_version),
self.chassis.redfish_version, None),
mock.call(self.chassis._conn, '/redfish/v1/Chassis/Blade3',
redfish_version=self.chassis.redfish_version),
self.chassis.redfish_version, None),
mock.call(self.chassis._conn, '/redfish/v1/Chassis/Blade4',
redfish_version=self.chassis.redfish_version)
self.chassis.redfish_version, None)
]
chassis_mock.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -77,7 +77,7 @@ class ResourceBlockCollectionTestCase(base.TestCase):
self.res_block_col = resourceblock.ResourceBlockCollection(
self.conn, '/redfish/v1/CompositionService/ResourceBlocks',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
path = '/redfish/v1/CompositionService/ResourceBlocks/ComputeBlock1'
@ -94,7 +94,7 @@ class ResourceBlockCollectionTestCase(base.TestCase):
self.res_block_col.get_member(path)
mock_resourceblock.assert_called_once_with(
self.res_block_col._conn, path,
redfish_version=self.res_block_col.redfish_version)
self.res_block_col.redfish_version, None)
@mock.patch.object(resourceblock, 'ResourceBlock', autospec=True)
def test_get_members(self, mock_resourceblock):
@ -102,6 +102,6 @@ class ResourceBlockCollectionTestCase(base.TestCase):
members = self.res_block_col.get_members()
mock_resourceblock.assert_called_once_with(
self.res_block_col._conn, path,
redfish_version=self.res_block_col.redfish_version)
self.res_block_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -65,7 +65,7 @@ class ResourceZoneCollectionTestCase(base.TestCase):
self.res_zone_col = resourcezone.ResourceZoneCollection(
self.conn, '/redfish/v1/CompositionService/ResourceZones',
redfish_version='1.0.2')
'1.0.2', None)
def test__parse_attributes(self):
path = '/redfish/v1/CompositionService/ResourceZones/1'
@ -80,7 +80,7 @@ class ResourceZoneCollectionTestCase(base.TestCase):
self.res_zone_col.get_member(path)
mock_resourcezone.assert_called_once_with(
self.res_zone_col._conn, path,
redfish_version=self.res_zone_col.redfish_version)
self.res_zone_col.redfish_version, None)
@mock.patch.object(resourcezone, 'ResourceZone', autospec=True)
def test_get_members(self, mock_resourcezone):
@ -88,6 +88,6 @@ class ResourceZoneCollectionTestCase(base.TestCase):
members = self.res_zone_col.get_members()
mock_resourcezone.assert_called_once_with(
self.res_zone_col._conn, path,
redfish_version=self.res_zone_col.redfish_version)
self.res_zone_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -114,23 +114,23 @@ class FabricCollectionTestCase(base.TestCase):
'fabric_collection.json') as f:
self.conn.get.return_value.json.return_value = json.load(f)
self.fabric = fabric.FabricCollection(
self.conn, '/redfish/v1/Fabrics', redfish_version='1.0.3')
self.conn, '/redfish/v1/Fabrics', '1.0.3', None)
@mock.patch.object(fabric, 'Fabric', autospec=True)
def test_get_member(self, fabric_mock):
self.fabric.get_member('/redfish/v1/Fabrics/SAS1')
fabric_mock.assert_called_once_with(
self.fabric._conn, '/redfish/v1/Fabrics/SAS1',
redfish_version=self.fabric.redfish_version)
self.fabric.redfish_version, None)
@mock.patch.object(fabric, 'Fabric', autospec=True)
def test_get_members(self, fabric_mock):
members = self.fabric.get_members()
calls = [
mock.call(self.fabric._conn, '/redfish/v1/Fabrics/SAS1',
redfish_version=self.fabric.redfish_version),
self.fabric.redfish_version, None),
mock.call(self.fabric._conn, '/redfish/v1/Fabrics/SAS2',
redfish_version=self.fabric.redfish_version)
self.fabric.redfish_version, None)
]
fabric_mock.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -309,13 +309,13 @@ class ManagerCollectionTestCase(base.TestCase):
self.managers.get_member('/redfish/v1/Managers/BMC')
Manager_mock.assert_called_once_with(
self.managers._conn, '/redfish/v1/Managers/BMC',
redfish_version=self.managers.redfish_version)
self.managers.redfish_version, None)
@mock.patch.object(manager, 'Manager', autospec=True)
def test_get_members(self, Manager_mock):
members = self.managers.get_members()
Manager_mock.assert_called_once_with(
self.managers._conn, '/redfish/v1/Managers/BMC',
redfish_version=self.managers.redfish_version)
self.managers.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -87,7 +87,7 @@ class SessionCollectionTestCase(base.TestCase):
self.sess_col.get_member(path)
mock_session.assert_called_once_with(
self.sess_col._conn, path,
redfish_version=self.sess_col.redfish_version)
self.sess_col.redfish_version, None)
@mock.patch.object(session, 'Session', autospec=True)
def test_get_members(self, mock_session):
@ -95,6 +95,6 @@ class SessionCollectionTestCase(base.TestCase):
members = self.sess_col.get_members()
mock_session.assert_called_once_with(
self.sess_col._conn, path,
redfish_version=self.sess_col.redfish_version)
self.sess_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -72,7 +72,7 @@ class SessionServiceTestCase(base.TestCase):
mock_sess_col.assert_called_once_with(
self.sess_serv_inst._conn,
'/redfish/v1/SessionService/Sessions',
redfish_version=self.sess_serv_inst.redfish_version)
self.sess_serv_inst.redfish_version, None)
def test_create_session(self):
with open('sushy/tests/unit/json_samples/'

View File

@ -79,16 +79,16 @@ class StorageTestCase(base.TestCase):
calls = [
mock.call(self.storage._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/35D38F11ACEF7BD3', # noqa
redfish_version=self.storage.redfish_version),
self.storage.redfish_version, None),
mock.call(self.storage._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/3F5A8C54207B7233', # noqa
redfish_version=self.storage.redfish_version),
self.storage.redfish_version, None),
mock.call(self.storage._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/32ADF365C6C1B7BD', # noqa
redfish_version=self.storage.redfish_version),
self.storage.redfish_version, None),
mock.call(self.storage._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Drives/3D58ECBC375FD9F2', # noqa
redfish_version=self.storage.redfish_version)
self.storage.redfish_version, None)
]
Drive_mock.assert_has_calls(calls)
self.assertIsInstance(all_drives, list)
@ -249,7 +249,7 @@ class StorageCollectionTestCase(base.TestCase):
Storage_mock.assert_called_once_with(
self.stor_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1',
redfish_version=self.stor_col.redfish_version)
self.stor_col.redfish_version, None)
@mock.patch.object(storage, 'Storage', autospec=True)
def test_get_members(self, Storage_mock):
@ -257,7 +257,7 @@ class StorageCollectionTestCase(base.TestCase):
Storage_mock.assert_called_once_with(
self.stor_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1',
redfish_version=self.stor_col.redfish_version)
self.stor_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -116,7 +116,7 @@ class VolumeCollectionTestCase(base.TestCase):
Volume_mock.assert_called_once_with(
self.stor_vol_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/1',
redfish_version=self.stor_vol_col.redfish_version)
self.stor_vol_col.redfish_version, None)
@mock.patch.object(volume, 'Volume', autospec=True)
def test_get_members(self, Volume_mock):
@ -124,13 +124,13 @@ class VolumeCollectionTestCase(base.TestCase):
calls = [
mock.call(self.stor_vol_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/1',
redfish_version=self.stor_vol_col.redfish_version),
self.stor_vol_col.redfish_version, None),
mock.call(self.stor_vol_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/2',
redfish_version=self.stor_vol_col.redfish_version),
self.stor_vol_col.redfish_version, None),
mock.call(self.stor_vol_col._conn,
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes/3',
redfish_version=self.stor_vol_col.redfish_version),
self.stor_vol_col.redfish_version, None),
]
Volume_mock.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -77,7 +77,7 @@ class EthernetInterfaceCollectionTestCase(base.TestCase):
self.sys_eth_col._conn,
('/redfish/v1/Systems/437XR1138R2/EthernetInterfaces/'
'12446A3B0411'),
redfish_version=self.sys_eth_col.redfish_version)
self.sys_eth_col.redfish_version, None)
@mock.patch.object(ethernet_interface, 'EthernetInterface', autospec=True)
def test_get_members(self, mock_eth):
@ -86,7 +86,7 @@ class EthernetInterfaceCollectionTestCase(base.TestCase):
"12446A3B0411")
calls = [
mock.call(self.sys_eth_col._conn, eth_path,
redfish_version=self.sys_eth_col.redfish_version),
self.sys_eth_col.redfish_version, None),
]
mock_eth.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -102,7 +102,7 @@ class ProcessorCollectionTestCase(base.TestCase):
mock_processor.assert_called_once_with(
self.sys_processor_col._conn,
'/redfish/v1/Systems/437XR1138R2/Processors/CPU1',
redfish_version=self.sys_processor_col.redfish_version)
self.sys_processor_col.redfish_version, None)
@mock.patch.object(processor, 'Processor', autospec=True)
def test_get_members(self, mock_processor):
@ -110,10 +110,10 @@ class ProcessorCollectionTestCase(base.TestCase):
calls = [
mock.call(self.sys_processor_col._conn,
'/redfish/v1/Systems/437XR1138R2/Processors/CPU1',
redfish_version=self.sys_processor_col.redfish_version),
self.sys_processor_col.redfish_version, None),
mock.call(self.sys_processor_col._conn,
'/redfish/v1/Systems/437XR1138R2/Processors/CPU2',
redfish_version=self.sys_processor_col.redfish_version)
self.sys_processor_col.redfish_version, None)
]
mock_processor.assert_has_calls(calls)
self.assertIsInstance(members, list)

View File

@ -74,7 +74,7 @@ class SimpleStorageCollectionTestCase(base.TestCase):
SimpleStorage_mock.assert_called_once_with(
self.simpl_stor_col._conn,
'/redfish/v1/Systems/437XR1138R2/SimpleStorage/1',
redfish_version=self.simpl_stor_col.redfish_version)
self.simpl_stor_col.redfish_version, None)
@mock.patch.object(simple_storage, 'SimpleStorage', autospec=True)
def test_get_members(self, SimpleStorage_mock):
@ -82,7 +82,7 @@ class SimpleStorageCollectionTestCase(base.TestCase):
SimpleStorage_mock.assert_called_once_with(
self.simpl_stor_col._conn,
'/redfish/v1/Systems/437XR1138R2/SimpleStorage/1',
redfish_version=self.simpl_stor_col.redfish_version)
self.simpl_stor_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -582,13 +582,13 @@ class SystemCollectionTestCase(base.TestCase):
self.sys_col.get_member('/redfish/v1/Systems/437XR1138R2')
mock_system.assert_called_once_with(
self.sys_col._conn, '/redfish/v1/Systems/437XR1138R2',
redfish_version=self.sys_col.redfish_version)
self.sys_col.redfish_version, None)
@mock.patch.object(system, 'System', autospec=True)
def test_get_members(self, mock_system):
members = self.sys_col.get_members()
mock_system.assert_called_once_with(
self.sys_col._conn, '/redfish/v1/Systems/437XR1138R2',
redfish_version=self.sys_col.redfish_version)
self.sys_col.redfish_version, None)
self.assertIsInstance(members, list)
self.assertEqual(1, len(members))

View File

@ -167,16 +167,19 @@ class ResourceBaseTestCase(base.TestCase):
class TestResource(resource_base.ResourceBase):
"""A concrete Test Resource to test against"""
def __init__(self, connector, identity, redfish_version=None):
def __init__(self, connector, identity, redfish_version=None,
registries=None):
"""Ctor of TestResource
:param connector: A Connector instance
:param identity: The id of the Resource
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages.
"""
super(TestResource, self).__init__(connector, 'Fakes/%s' % identity,
redfish_version)
redfish_version, registries)
self.identity = identity
def _parse_attributes(self):
@ -190,15 +193,17 @@ class TestResourceCollection(resource_base.ResourceCollectionBase):
def _resource_type(self):
return TestResource
def __init__(self, connector, redfish_version=None):
def __init__(self, connector, redfish_version=None, registries=None):
"""Ctor of TestResourceCollection
:param connector: A Connector instance
:param redfish_version: The version of RedFish. Used to construct
the object according to schema of the given version.
:param registries: Dict of Redfish Message Registry objects to be
used in any resource that needs registries to parse messages.
"""
super(TestResourceCollection, self).__init__(connector, 'Fakes',
redfish_version)
super(TestResourceCollection, self).__init__(
connector, 'Fakes', redfish_version, registries)
class ResourceCollectionBaseTestCase(base.TestCase):
@ -207,7 +212,7 @@ class ResourceCollectionBaseTestCase(base.TestCase):
super(ResourceCollectionBaseTestCase, self).setUp()
self.conn = mock.MagicMock()
self.test_resource_collection = TestResourceCollection(
self.conn, redfish_version='1.0.x')
self.conn, redfish_version='1.0.x', registries=None)
self.conn.reset_mock()
def test_get_member(self):

View File

@ -87,4 +87,4 @@ class SoftwareInventoryCollectionTestCase(base.TestCase):
self.soft_inv_col.get_member(path)
mock_softwareinventory.assert_called_once_with(
self.soft_inv_col._conn, path,
redfish_version=self.soft_inv_col.redfish_version)
self.soft_inv_col.redfish_version, None)

View File

@ -93,86 +93,89 @@ class MainTestCase(base.TestCase):
self.assertFalse(mock_Sushy_Connector.called)
@mock.patch.object(system, 'SystemCollection', autospec=True)
def test_get_system_collection(self, mock_system_collection):
@mock.patch('sushy.Sushy.registries', autospec=True)
def test_get_system_collection(
self, mock_registries, mock_system_collection):
self.root._standard_message_registries_path = None
self.root.get_system_collection()
mock_system_collection.assert_called_once_with(
self.root._conn, '/redfish/v1/Systems',
redfish_version=self.root.redfish_version)
redfish_version=self.root.redfish_version,
registries=mock_registries
)
@mock.patch.object(system, 'System', autospec=True)
@mock.patch('sushy.Sushy._get_message_registries', autospec=True)
@mock.patch('sushy.Sushy.registries', autospec=True)
def test_get_system(self, mock_registries, mock_system):
mock_registry = mock.Mock()
mock_registries.return_value = [mock_registry]
self.root._standard_message_registries_path = None
self.root.get_system('fake-system-id')
mock_system.assert_called_once_with(
self.root._conn, 'fake-system-id',
redfish_version=self.root.redfish_version,
registries=[mock_registry])
registries=mock_registries)
@mock.patch.object(chassis, 'Chassis', autospec=True)
def test_get_chassis(self, mock_chassis):
self.root.get_chassis('fake-chassis-id')
mock_chassis.assert_called_once_with(
self.root._conn, 'fake-chassis-id',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(chassis, 'ChassisCollection', autospec=True)
def test_get_chassis_collection(self, chassis_collection_mock):
self.root.get_chassis_collection()
chassis_collection_mock.assert_called_once_with(
self.root._conn, '/redfish/v1/Chassis',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(fabric, 'Fabric', autospec=True)
def test_get_fabric(self, mock_fabric):
self.root.get_fabric('fake-fabric-id')
mock_fabric.assert_called_once_with(
self.root._conn, 'fake-fabric-id',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(fabric, 'FabricCollection', autospec=True)
def test_get_fabric_collection(self, fabric_collection_mock):
self.root.get_fabric_collection()
fabric_collection_mock.assert_called_once_with(
self.root._conn, '/redfish/v1/Fabrics',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(manager, 'ManagerCollection', autospec=True)
def test_get_manager_collection(self, ManagerCollection_mock):
self.root.get_manager_collection()
ManagerCollection_mock.assert_called_once_with(
self.root._conn, '/redfish/v1/Managers',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(manager, 'Manager', autospec=True)
def test_get_manager(self, Manager_mock):
self.root.get_manager('fake-manager-id')
Manager_mock.assert_called_once_with(
self.root._conn, 'fake-manager-id',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(sessionservice, 'SessionService', autospec=True)
def test_get_sessionservice(self, mock_sess_serv):
self.root.get_session_service()
mock_sess_serv.assert_called_once_with(
self.root._conn, '/redfish/v1/SessionService',
redfish_version=self.root.redfish_version)
self.root.redfish_version)
@mock.patch.object(session, 'Session', autospec=True)
def test_get_session(self, mock_sess):
self.root.get_session('asdf')
mock_sess.assert_called_once_with(
self.root._conn, 'asdf',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(updateservice, 'UpdateService', autospec=True)
def test_get_update_service(self, mock_upd_serv):
self.root.get_update_service()
mock_upd_serv.assert_called_once_with(
self.root._conn, '/redfish/v1/UpdateService',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
@mock.patch.object(message_registry_file,
'MessageRegistryFileCollection',
@ -182,7 +185,7 @@ class MainTestCase(base.TestCase):
self.root._get_registry_collection()
MessageRegistryFileCollection_mock.assert_called_once_with(
self.root._conn, '/redfish/v1/Registries',
redfish_version=self.root.redfish_version)
self.root.redfish_version)
@mock.patch.object(
compositionservice, 'CompositionService', autospec=True)
@ -190,7 +193,7 @@ class MainTestCase(base.TestCase):
self.root.get_composition_service()
mock_comp_ser.assert_called_once_with(
self.root._conn, '/redfish/v1/CompositionService',
redfish_version=self.root.redfish_version)
self.root.redfish_version, self.root.registries)
def test__get_standard_message_registry_collection(self):
registries = self.root._get_standard_message_registry_collection()
@ -216,15 +219,14 @@ class MainTestCase(base.TestCase):
mock_msg_reg_file.get_message_registry.return_value = mock_msg_reg2
mock_col.return_value.get_members.return_value = [mock_msg_reg_file]
registries = self.root._get_message_registries()
registries = self.root.registries
self.assertEqual({'RegistryA.2.0': mock_msg_reg1,
'RegistryB.1.0': mock_msg_reg2}, registries)
@mock.patch('sushy.Sushy._get_standard_message_registry_collection',
autospec=True)
@mock.patch('sushy.Sushy._get_registry_collection', autospec=True)
def test__get_message_registries_provided_empty(self, mock_col,
mock_st_col):
def test_registries_provided_empty(self, mock_col, mock_st_col):
mock_msg_reg1 = mock.Mock()
mock_msg_reg1.registry_prefix = 'RegistryA'
mock_msg_reg1.registry_version = '2.0.0'
@ -232,7 +234,7 @@ class MainTestCase(base.TestCase):
mock_st_col.return_value = [mock_msg_reg1]
mock_col.return_value = None
registries = self.root._get_message_registries()
registries = self.root.registries
self.assertEqual({'RegistryA.2.0': mock_msg_reg1}, registries)