Skip to main content

RANCID Command Wrapper.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rancidcmd-0.1.12.tar.gz (67.6 kB view details)

Uploaded Source

File details

Details for the file rancidcmd-0.1.12.tar.gz.

File metadata

  • Download URL: rancidcmd-0.1.12.tar.gz
  • Upload date:
  • Size: 67.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rancidcmd-0.1.12.tar.gz
Algorithm Hash digest
SHA256 4e16fffe3637622de667220a2b82c99b14ed631ee6d494bf34d83791d6fbbe62
MD5 26c7bfd1d8192616f71edd55dd3bdcde
BLAKE2b-256 7e2f26def45b9ce29e980cbc99853e23a539177e23dbde88e3a02ce1a3e23922

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page