Skip to main content

Rancidcmd is a utility tool for network operators. This module is wrapper of RANCID login commands.(like cloing, jlogin …) So if you use this module, then you have to install RANCID in some way. Why did I make this module? I wanted to do using without password of “.cloginrc”. This Rancidcmd makes temporary “.clgoinrc” from python code with each excecution. If already “.clgoinrc” is present, use “.clgoinrc” with priority.

https://secure.travis-ci.org/mtoshi/rancidcmd.svg?branch=master https://coveralls.io/repos/mtoshi/rancidcmd/badge.svg?branch=coverall Latest Version

Requirements

  • Python 2.7, 3.4, 3.5, PyPy

Installation

  1. Please install the RANCID in advance.

    For CentOS

    $ yum install rancid

    For Debian, Ubuntu

    $ apt-get install rancid

    For MacOS X(Port)

    $ port install rancid
  2. After RANCID, please install Rancidcmd

    $ pip install rancidcmd
    
    or
    
    $ git clone https://github.com/mtoshi/rancidcmd
    $ cd rancidcmd
    $ sudo python setup.py install
  • Care of “~/.cloginrc” existence is not necessary.

    If executed user doesn’t have “~/.cloginrc”, then Rancidcmd makes temporary “.cloginrc”. If already “.clgoinrc” is present, use “.clgoinrc” with priority.

Using example

Example for cisco(clogin).

>>> from rancidcmd import RancidCmd
>>> rancidcmd = RancidCmd(login='/usr/libexec/rancid/clogin',
...                       user='username',
...                       password='xxxx',
...                       enable_password='xxxx',
...                       address='192.168.1.1')
>>> rancidcmd.execute("show version")

Example for junos(jlogin).

>>> from rancidcmd import RancidCmd
>>> rancidcmd = RancidCmd(login='/usr/libexec/rancid/jlogin',
...                       user='username',
...                       password='xxxx',
...                       address='192.168.1.2')
>>> rancidcmd.execute("show version")

Example for Option (“-d” is enable debug mode and “-t 45” is timeout 45 seconds.).

>>> from rancidcmd import RancidCmd
>>> rancidcmd = RancidCmd(login='/usr/libexec/rancid/jlogin',
...                       user='username',
...                       password='xxxx',
...                       option='-d -t 45',
...                       address='192.168.1.2')
>>> rancidcmd.execute("show version")

Example for command confirmation (you can use “show” method).

>>> rancidcmd.show("show version")
/usr/libexec/rancid/clogin -u "username" -p "xxxx" -e "xxxx"  -c "show version" 192.168.1.1

# This show method will be useful for debug by hands.

RancidCmd() init args.

login (str): Login command is xlogin. (such as "clogin, jlogin")
address (str): Host name or ip address.
user (str): Login user name.
password (str): Login user password.
enable_password (str): Login user enable password.
                       Default is None.(**clogin is must.**)
option (str): Option is not must.
              Deafult is None.
              If you set this value to pass directly to clogin.
encoding (str): Encoding type.
                Default is 'utf-8'.

Output format.

{'rtn_code': int, 'std_err': str, 'std_out': str}

Output sucess sample.

{'rtn_code': 0,
 'std_err': '',
 'std_out': '... Copyright (c) 2002-2013, Cisco Systems, Inc. All ...'}

Output error sample. (Not found “clogin”)

{'rtn_code': 1,
 'std_err': '/bin/sh: clogin: command not fond\n',
 'std_out': ''}

Please see sample code.

If you want to use another settings(prompt, method, etc), please edit “.cloginrc” same with previus.

Recently almost network devices can use ssh login. If you use ssh to priority, then you should write below into “.cloginrc”.

# All targets first action is ssh.
add method * ssh telnet

or

# For specific targets.
add method 192.168.1.* ssh telnet

See also

Metadata

Release files for rancidcmd 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rancidcmd 0.1.12
File Size Uploaded
rancidcmd-0.1.12.tar.gz 67.6 kB Details

Release files / rancidcmd-0.1.12.tar.gz

Download URL rancidcmd-0.1.12.tar.gz
Size 67.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4e16fffe3637622de667220a2b82c99b14ed631ee6d494bf34d83791d6fbbe62
BLAKE2b-256 checksum
How to use checksums
7e2f26def45b9ce29e980cbc99853e23a539177e23dbde88e3a02ce1a3e23922
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.12 This release

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

2 release files

0.1.4

2 release files

0.1.3

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page