oneview_redfish_toolkit package

Subpackages

Submodules

oneview_redfish_toolkit.app module

oneview_redfish_toolkit.util module

oneview_redfish_toolkit.util.configure_logging(log_file_path)[source]

Loads logging.conf file

Loads logging.conf file to create the logger configuration.

The logger configuration has two handlers, one of stream (show logs in the console) and other of file (save a log file) where you can choose one of it in [logger_root : handlers]. In it you can choose the logger level as well.

CRITICAL: 50 ERROR: 40 WARNING: 30 INFO: 20 DEBUG: 10 NOTSET: 00 ———————

How to use: import logging and logging.exception(‘message’)

Parameters:log_file_path – logging.conf path.
Exception:
Exception: if logging.conf file not found.
oneview_redfish_toolkit.util.generate_certificate(dir_name, file_name, key_length, key_type='rsa')[source]

Create self-signed cert and key files

Parameters:
  • dir_name – name of the directory to store the files
  • file_name – name of the files that will be created. It will append .crt to certificate file and .key to key file
  • key_length – key length in bits
  • key_type – crypto type: RSA or DSA; defaults to RSA
Returns:

Nothing

Exceptions:
Raise exceptions on error
oneview_redfish_toolkit.util.get_ip()[source]

Tries to detect default route IP Address

oneview_redfish_toolkit.util.get_oneview_client(session_id=None, is_service_root=False)[source]

Establishes a OneView connection to be used in the module

Establishes a OV connection if one does not exists. If one exists, do a single OV access to check if its sill valid. If not tries to establish a new connection. Sets the connection on the ov_conn global var

Parameters:
  • session_id – The ID of a valid authenticated session, if the
  • is session. Defaults to None. (authentication_mode) –
  • is_service_root – Informs if who is calling this function is the
  • blueprint. If true, even if authentication_mode is (ServiceRoot) –
  • to session it will use the information on the conf file to (set) –
  • a connection. This is a workaround to allow ServiceRoot (return) –
  • retrieve the appliance UUID before user logs in. (to) –
Returns:

OneViewClient object

Exceptions:
HPOneViewException if can’t connect or reconnect to OV
oneview_redfish_toolkit.util.load_conf(conf_file)[source]

Loads and parses conf file

Loads and parses the module conf file

Parameters:conf_file – string with the conf file name
Returns:ConfigParser object with conf_file configs
Exception:
OneViewRedfishResourceNotFoundError:
  • if conf file not found
oneview_redfish_toolkit.util.load_config(conf_file)[source]

Loads redfish.conf file

Loads and parsers the system conf file into config global var Loads json schemas into schemas_dict global var Established a connection with OneView and sets in as ov_conn global var

Parameters:conf_file – string with the conf file name
Returns:None
Exception:
OneViewRedfishResourceNotFoundError:
  • if conf file not found
  • if any of the schemas files are not found
  • if the schema directory is not found
OneViewRedFishResourceNotAccessibleError:
  • if can’t access schema’s directory
HPOneViewException:
  • if fails to connect to oneview
oneview_redfish_toolkit.util.load_event_service_info()[source]

Loads Event Service information

Loads DeliveryRetryAttempts and DeliveryRetryIntervalSeconds from CONFIG file and store it in a global var.

Exceptions:
OneViewRedfishError: DeliveryRetryAttempts and DeliveryRetryIntervalSeconds must be integers greater than zero.
oneview_redfish_toolkit.util.load_registry(registry_dir, registries)[source]

Loads Registries

Loads all registries listed in the config file using registry_dir directory

Parameters:
  • registry_dir – string with the directory to load registries from
  • registries – dict with registry name as key and registry file_name as value. The key will also be the key in the returning dict.
Returns:

A dict containing ‘RegistryName’: registry_obj

Return type:

OrderedDict

Exceptions:
OneviewRedfishResourceNotFoundError:
  • if registry_dir is not found
  • any of json files is not found
OneviewRedfishResourceNotAccessible:
  • if registry_dir is can’t be accessed
oneview_redfish_toolkit.util.store_schemas(schema_dir)[source]

Stores all DMTF JSON Schemas

Stores all schemas listed in schemas searching schema_dir directory.

Parameters:schema_dir – String with the directory to load schemas from.
Returns:
A dict containing (‘http://redfish.dmtf.org/schemas/
v1/<schema_file_name>’: schema_obj) pairs
Return type:Dictionary

Module contents