Bootstrap Client¶
- class Node(server)[source]¶
- Node object which can be used by actions via:
- attributes.get(‘NODE’)
- client¶
jsonrpclib.Server
jsonrpclib connect to Command API engine
- api_config_cmds(cmds)[source]¶
Run CLI commands via Command API, starting from config mode.
Commands are ran in order.
Parameters: cmds (list) – List of CLI commands. Returns: List of Command API results corresponding to the input commands. Return type: list
- api_enable_cmds(cmds, text_format=False)[source]¶
Run CLI commands via Command API, starting from enable mode.
Commands are ran in order.
Parameters: - cmds (list) – List of CLI commands.
- text_format (bool, optional) – If true, Command API request will run in text mode (instead of JSON).
Returns: List of Command API results corresponding to the input commands.
Return type: list
- append_rc_eos_lines(lines)[source]¶
Add lines to rc.eos.
Parameters: lines (list) – List of bash commands
- append_startup_config_lines(lines)[source]¶
Add lines to startup-config.
Parameters: lines (list) – List of CLI commands
- classmethod bash_cmds(cmds)[source]¶
Executes bash commands in order - stops on first failure.
Parameters: cmds – list of bash commands Returns: first failing command (None otherwise) code: exit code for first failing command (None otherwise) out: stdout for first failing command (None otherwise) err: stderr for first failing command (None otherwise) Return type: cmd
- details()[source]¶
Get details.
Returns: System details Format:
{'model': <MODEL>, 'version': <EOS_VERSION>, 'systemmac': <SYSTEM_MAC>, 'serialnumber': <SERIAL_NUMBER>, 'neighbors': <NEIGHBORS> # see neighbors() }
Return type: dict
- has_startup_config()[source]¶
Check whether startup-config is configured or not.
Returns: True is startup-config is configured; false otherwise. Return type: bool
- log_msg(msg, error=False)[source]¶
Log message via configured syslog/XMPP.
Parameters: - msg (string) – Message
- error (bool, optional) – True if msg is an error; false otherwise.
- neighbors()[source]¶
Get neighbors.
Returns: LLDP neighbor Format:
{'neighbors': {<LOCAL_PORT>: [{'device': <REMOTE_DEVICE>, 'port': <REMOTE_PORT>}, ...], ...}}
Return type: dict
- retrieve_url(url, path)[source]¶
Download resource from server.
If ‘path’ is somewhere on flash and ‘url’ points back to SERVER, then the client will request the metadata for the resource from the server (in order to check whether there is enogh disk space available). If ‘url’ points to a different server, then the ‘content-length’ header will be used for the disk space checks.
Raises: ZtpError – resource cannot be retrieved: - metadata cannot be retrieved from server OR - metadata is inconsistent with request OR - disk space on flash is insufficient OR - file cannot be written to disk Returns: startup-config path Return type: string
- classmethod server_address()[source]¶
Get ZTP Server URL.
Returns: ZTP Server URL. Return type: string
- classmethod substitute(template, substitutions, strict=True)[source]¶
Perform variable substitution on a config template.
Parameters: - template (string) – EOS configuration template
- substitutions (dict) – set of substitutions for the template
- strict (bool, optional) – If true, method will raise Exception when template variables are missing from ‘substitutions’.
Returns: template string with variable substitution
Return type: string