Utils¶
-
pyeapi.utils.
collapse_range
(arg, value_delimiter=', ', range_delimiter='-')[source]¶ Collapses a list of values into a range set
Parameters: - arg – The list of values to collapse
- value_delimiter – The delimiter that separates values
- range_delimiter – The delimiter that separates a value range
Returns: An array of collapsed string values
Return type: list
-
pyeapi.utils.
debug
(text)[source]¶ Log a message to syslog and stderr
Parameters: text (str) – The string object to print
-
pyeapi.utils.
expand_range
(arg, value_delimiter=', ', range_delimiter='-')[source]¶ Expands a delimited string of ranged integers into a list of strings
Parameters: - arg – The string range to expand
- value_delimiter – The delimiter that separates values
- range_delimiter – The delimiter that signifies a range of values
Returns: An array of expanded string values
Return type: list
-
pyeapi.utils.
import_module
(name)[source]¶ Imports a module into the current runtime environment
This function emulates the Python import system that allows for importing full path modules. It will break down the module and import each part (or skip if it is already loaded in cache).
Parameters: name (str) – The name of the module to import. This should be the full path of the module Returns: The module that was imported
-
pyeapi.utils.
islocalconnection
()[source]¶ Checks if running locally on EOS device or remotely
This function will return a boolean indicating if the current execution environment is running locally on an EOS device (True) or running remotely and communicating over HTTP/S (False)
Returns: - A boolean value that indicates whether or not the current
- thread is local or remote
-
pyeapi.utils.
load_module
(name)[source]¶ Attempts to load a module into the current environment
This function will load a module specified by name. The module name is first checked to see if it is already loaded and will return the module if it is. If the module hasn’t been previously loaded it will attempt to import it
Parameters: name (str) – Specifies the full name of the module. For instance pyeapi.api.vlans Returns: The module that has been imported or retrieved from the sys modules