Bootstrap Client

class Node(server)[source]
Node object which can be used by actions via:

jsonrpclib.Server – jsonrpclib connect to Command API engine


Run CLI commands via Command API, starting from config mode.

Commands are ran in order.

Parameters:cmds (list) – List of CLI commands.
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.

  • cmds (list) – List of CLI commands.
  • text_format (bool, optional) – If true, Command API request will run in text mode (instead of JSON).

List of Command API results corresponding to the

input commands.

Return type:



Add lines to rc.eos.

Parameters:lines (list) – List of bash commands

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
create_user(user, group, passwd, root='/persist/local/', ssh_keys=None)[source]

Create a local user on the bootstrapped node. If ‘ssh_keys’ are provided, they will be copied to $HOME/.ssh/authorized_keys. Also, rc.eos will be modified to add this user on every boot. If the user provided already exists, the function will continue and install the ssh_keys (if necessary). The $HOME/.ssh directory will be assigned 0700 permissions and the $HOME/.ssh/authorized_keys file will be assigned 0600 permissions in accord with SSH best practices.

  • user (-) – the username
  • group (-) – the group assigned to the user
  • passwd (-) – cleartext password
  • root (-) – the path where the user’s home directory will reside
  • ssh_keys (-) – (optional) public keys that will be copied to ~$HOME/.ssh/authorized_keys
  • ZtpError
  • - missing argument – user, group, passwd
    • useradd fails, return the error
    • ssh_keys cannot be written to ‘authorized_keys’
    • files cannot change ownership or permissions

True if user created; False if otherwise

Return type:



Get details.

Returns:System details


{'model':        <MODEL>,
 'version':      <EOS_VERSION>,
 'systemmac':    <SYSTEM_MAC>,
 'serialnumber': <SERIAL_NUMBER>,
 'neighbors':    <NEIGHBORS>        # see neighbors()
Return type:dict

Get flash path.

Returns:flash path
Return type:string

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.

  • msg (string) – Message
  • error (bool, optional) – True if msg is an error; false otherwise.

Get neighbors.

Returns:LLDP neighbor


{'neighbors': {<LOCAL_PORT>:
 [{'device': <REMOTE_DEVICE>,
   'port': <REMOTE_PORT>}, ...],
Return type:dict

Get rc.eos path.

Returns:rc.eos path
Return type:string
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

Get startup-config path.

Returns:startup-config path
Return type:string
classmethod substitute(template, substitutions, strict=True)[source]

Perform variable substitution on a config template.

  • 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’.

template string with variable substitution

Return type:



Get system information.

Returns:System information


{'model':        <MODEL>,
 'version':      <EOS_VERSION>,
 'systemmac':    <SYSTEM_MAC>,
 'serialnumber': <SERIAL_NUMBER>}
Return type:dict