Bootstrap Client¶
- class ztps.bootstrap.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
- 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, the client will first request the metainformation for the resource from the server (in order to Check whether there is enogh disk space available).
Raises: ZtpError – resource cannot be retrieved: - metainformation cannot be retrieved from server OR - disk space on flash is insufficient OR - file cannot be written to disk Returns: startup-config path Return type: string