bwks / netconnect

Connect to devices via telnet and ssh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

netconnect

Build Status Coverage Status

Overview

Connect to devices via ssh or telnet and run automated work flows.
netconnect utilizes pexpect to control telnet or ssh sessions.
netconnect has been designed with a focus on network device automation.
It is usefull for controlling terminal sessions where an API is not available or not yet enabled.

netconnect has a concept of drivers which are used to seperate out the differing terminal intricacies.
There is currently drivers for the following device models:

  • cisco: IOS, ASA, Viptela
  • juniper: Junos
  • arista: EOS
  • unix: Bash

A driver can be written for any terminal type that accepts telnet or SSH control.

Install

pip install https://github.com/bobthebutcher/netconnect/archive/master.zip

Usage

# Cisco device
from netconnect.cisco import CiscoDriver
dev = CiscoDriver(device='test-csr-01', username='test-user', password='password', enable_password='enable-pass')
dev.login()
commands = ['show version', 'show run']
results = dev.send_commands(commands)

# Juniper Device
from netconnect.juniper import JuniperDriver
dev = JuniperDriver(device='test-vmx-01', username='test-user', password='password')
dev.login()
dev.enable_api()

# Arista Device
from netconnect.arista import AristaDriver
dev = AristaDriver(device='test-eos-01', username='test-user', password='password')
dev.login()
dev.enable_api()

Enable debugging

from netconnect import helpers
helpers.DEBUG = True

Context Manager

The context manager will take care of logging in and also closing the connection automatically if there is a failure.

# Cisco device
from netconnect.cisco import CiscoDriver
with CiscoDriver('test-csr-01', 'test-user', 'password', 'enable-pass') as dev:
    commands = ['show version', 'show run']
    results = dev.send_commands(commands)

About

Connect to devices via telnet and ssh

License:GNU General Public License v3.0


Languages

Language:Python 100.0%