The sushy.resources.base Module¶
-
class
sushy.resources.base.AbstractJsonReader¶ Bases:
object-
abstract
get_json()¶ Based on data source get data and parse to JSON
-
set_connection(connector, path)¶ Sets mandatory connection parameters
- Parameters
connector – A Connector instance
path – path of the resource
-
abstract
-
class
sushy.resources.base.CompositeField(*args, **kwargs)¶ Bases:
collections.abc.Mapping,sushy.resources.base.FieldBase class for fields consisting of several sub-fields.
-
class
sushy.resources.base.DictionaryField(*args, **kwargs)¶ Bases:
sushy.resources.base.FieldBase class for fields consisting of dictionary of several sub-fields.
-
class
sushy.resources.base.Field(path, required=False, default=None, adapter=<function Field.<lambda>>)¶ Bases:
objectDefinition for fields fetched from JSON.
-
class
sushy.resources.base.JsonArchiveReader(archive_file)¶ Bases:
sushy.resources.base.AbstractJsonReaderGets the data from JSON file in archive
-
get_json()¶ Gets JSON file from archive. Currently supporting ZIP only
-
-
class
sushy.resources.base.JsonDataReader¶ Bases:
sushy.resources.base.AbstractJsonReaderGets the data from HTTP response given by path
-
get_json()¶ Gets JSON file from URI directly
-
-
class
sushy.resources.base.JsonPackagedFileReader(resource_package_name)¶ Bases:
sushy.resources.base.AbstractJsonReaderGets the data from packaged file given by path
-
get_json()¶ Gets JSON file from packaged file denoted by path
-
-
class
sushy.resources.base.JsonPublicFileReader¶ Bases:
sushy.resources.base.AbstractJsonReaderLoads the data from the Internet
-
get_json()¶ Get JSON file from full URI
-
-
class
sushy.resources.base.ListField(*args, **kwargs)¶ Bases:
sushy.resources.base.FieldBase class for fields consisting of a list of several sub-fields.
-
class
sushy.resources.base.MappedField(field, mapping, required=False, default=None)¶ Bases:
sushy.resources.base.FieldField taking real value from a mapping.
-
class
sushy.resources.base.MappedListField(field, mapping, required=False, default=None)¶ Bases:
sushy.resources.base.FieldField taking a list of values with a mapping for the values
Given JSON {‘field’:[‘xxx’, ‘yyy’]}, a sushy resource definition and mapping {‘xxx’:’a’, ‘yyy’:’b’}, the sushy object to come out will be like resource.field = [‘a’, ‘b’]
-
class
sushy.resources.base.ResourceBase(connector, path='', redfish_version=None, registries=None, reader=None)¶ Bases:
object-
clone_resource(new_resource, path='')¶ Instantiate given resource using existing BMC connection context
-
get_oem_extension(vendor)¶ Get the OEM extension instance for this resource by OEM vendor
- Parameters
vendor – the OEM vendor string which is the vendor-specific extensibility identifier. Examples are ‘Contoso’, ‘Hpe’. Possible value can be got from
oem_vendorsattribute.- Returns
the Redfish resource OEM extension instance.
- Raises
OEMExtensionNotFoundError
-
invalidate(force_refresh=False)¶ Mark the resource as stale, prompting refresh() before getting used.
If
force_refreshis set to True, then it invokesrefresh()on the resource.- Parameters
force_refresh – will invoke refresh on the resource, if set to True.
- Raises
ResourceNotFoundError
- Raises
ConnectionError
- Raises
HTTPError
-
property
json¶
-
oem_vendors= <sushy.resources.base.Field object>¶ The list of OEM extension names for this resource.
-
property
path¶
-
redfish_version= None¶ The Redfish version
-
refresh(force=True)¶ Refresh the resource
Freshly retrieves/fetches the resource attributes and invokes
_parse_attributes()method on successful retrieval. It is recommended not to override this method in concrete ResourceBase classes. Resource classes can place their refresh specific operations in_do_refresh()method, if needed. This method represents the template method in the paradigm of Template design pattern.- Parameters
force – if set to False, will only refresh if the resource is marked as stale, otherwise neither it nor its subresources will be refreshed.
- Raises
ResourceNotFoundError
- Raises
ConnectionError
- Raises
HTTPError
-
property
registries¶
-
property
resource_name¶
-
-
class
sushy.resources.base.ResourceCollectionBase(connector, path, redfish_version=None, registries=None)¶ Bases:
sushy.resources.base.ResourceBase-
get_member(identity)¶ Given the identity return a
_resource_typeobject- Parameters
identity – The identity of the
_resource_type- Returns
The
_resource_typeobject- Raises
ResourceNotFoundError
-
get_members()¶ Return a list of
_resource_typeobjects present in collection- Returns
A list of
_resource_typeobjects
-
members_identities= <sushy.resources.base.Field object>¶ A tuple with the members identities
-
name= <sushy.resources.base.Field object>¶ The name of the collection
-