Welcome to rancidcmd’s documentation!

Contents:

RancidCmd.

class rancidcmd.RancidCmd(**kwargs)[source]

Class RancidCmd.

Attributes:

login (str):RANCID login command(clogin, jlogin, etc).
user (str):Login username.
password (str):Login password.
address (str):Host name or ip address.
enable_password (str, optional):
 Enable password for clogin. Default is None.
option(int, optional):
 Option example: ‘-d -x “commands.txt”’. Default is None.
encoding(str, optional):
 Encoding type. Default is ‘utf-8’.

Using example:

check_native_cloginrc()[source]

Check native settings file. Note:

If RANCID settings file is not exists or empty, then make temporary cloginrc file. So this method is for check cloginrc file.
Returns:
str:RANCID settings file text.
cmd_exec(command)[source]

Login and command execution.

Args:

command (str):Command for execution.

Returns:

dict:Example is below.
{
‘std_err’: ‘’, ‘std_out’: ‘’, ‘rtn_code’: ‘’,

}

decode_bytes(byte_data)[source]

Change string with encoding setting.

Args:

byte_data (bytes):
 Popen output.
execute(command)[source]

Command execution.

Args:

command (str):Example is “show version”.

Returns:

dict:Example is below.
{
‘std_err’: ‘’, ‘std_out’: ‘’, ‘rtn_code’: ‘’,

}

generate_cmd(command)[source]

Generate command.

Args:

command (str):Example is “show version”.

Returns:

str:Return the command string.

If there is the “enable_password”.

'xlogin -u admin -c "show version"'
static get_home_path()[source]

Get home directory path. Returns:

str:User home directory path.
is_option_x()[source]

Check -x option.

“-c” gets commands from command-line. “-x” gets commnads from file.

These are for command option and exclusive. If “-x” option is specified, then “-c” command is ignored.

make_cloginrc(cloginrc_config)[source]

Check rancid settings file.

Note:

If RANCID settings file is not exists, then make temporary settings file.

Returns:

NamedTemporaryFile:
 RANCID settings tempfile object.
static make_default_native_cloginrc_path(name='.cloginrc')[source]

Make native settings file.

show_command(command)[source]

Execute command string check.

Args:

command (str):Example is “show version”.

Returns:

str:Return the command string.
show_config()[source]

cloginrc string check.

Returns:

str:Return cloginrc config string.

Indices and tables