PyU4V.utils

PyU4V.utils.config_handler

config_handler.py.

PyU4V.utils.config_handler.set_logger_and_config(file_path=None)[source]

Set logger and config file.

Parameters:file_path – path to PyU4V configuration file – str
Returns:config parser – obj

PyU4V.utils.console

console.py

PyU4V.utils.constants

constants.py.

PyU4V.utils.decorators

decorators.py

PyU4V.utils.decorators.deprecation_notice(func_class, start_version, end_version)[source]

Notify the user of function deprecation in a future version.

Parameters:
  • func_class – the class name for deprecated function – str
  • start_version – the start Unisphere version – float
  • end_version – the end Unisphere version – float
Returns:

decorated function – decorator

PyU4V.utils.decorators.refactoring_notice(func_class, path, start_version, end_version)[source]

Notify the user of function refactoring elsewhere in PyU4V.

Parameters:
  • func_class – the class name for deprecated function – str
  • path – path to the new function – str
  • start_version – the start Unisphere version – float
  • end_version – the end Unisphere version – float
Returns:

decorated function – decorator

PyU4V.utils.decorators.retry(exceptions, total_attempts=3, delay=3, backoff=2)[source]

Decorator for retrying function calls.

Parameters:
  • exceptions – expected exceptions to retry on – class or tuple
  • total_attempts – times to run function before failure. – int
  • delay – initial delay between retries in seconds. – int
  • backoff – delay multiplier between each attempt – int

PyU4V.utils.exception

exception.py

exception PyU4V.utils.exception.InvalidInputException(message=None, **kwargs)[source]

Bases: PyU4V.utils.exception.PyU4VException

InvalidInputException.

message = 'Invalid input received: %(data)s'
exception PyU4V.utils.exception.MissingConfigurationException(message=None, **kwargs)[source]

Bases: PyU4V.utils.exception.PyU4VException

MissingConfigurationFileException

message = 'PyU4V settings not be loaded, please check file location or univmax_conn input parameters.'
exception PyU4V.utils.exception.PyU4VException(message=None, **kwargs)[source]

Bases: exceptions.Exception

PyU4VException.

code = 500
headers = {}
message = 'An unknown exception occurred.'
safe = False
exception PyU4V.utils.exception.ResourceNotFoundException(message=None, **kwargs)[source]

Bases: PyU4V.utils.exception.PyU4VException

ResourceNotFoundException.

message = 'The requested resource was not found: %(data)s'
exception PyU4V.utils.exception.UnauthorizedRequestException(message=None, **kwargs)[source]

Bases: PyU4V.utils.exception.PyU4VException

UnauthorizedRequestException.

message = 'Unauthorized request - please check credentials'
exception PyU4V.utils.exception.VolumeBackendAPIException(message=None, **kwargs)[source]

Bases: PyU4V.utils.exception.PyU4VException

VolumeBackendAPIException.

message = 'Bad or unexpected response from the storage volume backend API: %(data)s'

PyU4V.utils.file_handler

file_handler.py

PyU4V.utils.file_handler.create_list_from_file(file_name)[source]

Given a file, create a list from its contents.

Parameters:file_name – the path to the file – str
Returns:file contents – list
PyU4V.utils.file_handler.read_csv_values(file_name, convert=False)[source]

Read any csv file with headers.

You can extract the multiple lists from the headers in the CSV file. In your own script, call this function and assign to data variable, then extract the lists to the variables. Example: data = fh.read_csv_values(mycsv.csv) sg_name_list = data[‘sgname’] policy_list = data[‘policy’]

Parameters:
  • file_name – path to CSV file – str
  • convert – convert strings to equivalent data type – bool
Returns:

CSV parsed data – dict

PyU4V.utils.file_handler.write_dict_to_csv_file(file_path, dictionary)[source]

Write dictionary data to CSV spreadsheet.

Parameters:
  • file_path – path including name of the file to be written to – str
  • dictionary – data to be written to file – dict
PyU4V.utils.file_handler.write_to_csv_file(file_name, data)[source]

Write list data to CSV spreadsheet.

Parameters:
  • file_name – name of the file to be written to – str
  • data – data to be written to file – list