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: PyU4VException

InvalidInputException.

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

Bases: 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: Exception

PyU4VException.

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

Bases: PyU4VException

ResourceNotFoundException.

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

Bases: PyU4VException

UnauthorizedRequestException.

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

Bases: 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, delimiter=',', quotechar='|')[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

  • delimiter – delimiter kwarg for csv DictReader object – str

  • quotechar – quotechar kwarg for csv DictReader object – str

Returns:

CSV parsed data – dict

PyU4V.utils.file_handler.write_binary_data_to_file(data, file_extension, file_name, dir_path=None)[source]

Write Unisphere binary data to file.

Parameters:
  • data – Unisphere REST response with data for writing – json response

  • file_extension – file extension used for writing to file – str

  • file_name – file name – str

  • dir_path – file write directory path – str

Returns:

file name and write directory – str

PyU4V.utils.file_handler.write_dict_to_csv_file(file_path, dictionary, delimiter=',', quotechar='|')[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

  • delimiter – delimiter kwarg for csv writer object – str

  • quotechar – quotechar kwarg for csv writer object – str

PyU4V.utils.file_handler.write_to_csv_file(file_name, data, delimiter=',', quotechar='|')[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

  • delimiter – delimiter kwarg for csv writer object – str

  • quotechar – quotechar kwarg for csv writer object – str

PyU4V.utils.time_handler

time_handler.py

PyU4V.utils.time_handler.format_time_input(time_in, return_seconds=False, return_milliseconds=False)[source]

Format timestamp as seconds/milliseconds for use in REST requests.

Parameters:
  • time_in – timestamp – int/float

  • return_seconds – return time in seconds – bool

  • return_milliseconds – return time in milliseconds – bool

Returns:

timestamp – int