Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktbyers/netmiko
Multi-vendor library to simplify Paramiko SSH connections to network devices
https://github.com/ktbyers/netmiko
Last synced: 11 days ago
JSON representation
Multi-vendor library to simplify Paramiko SSH connections to network devices
- Host: GitHub
- URL: https://github.com/ktbyers/netmiko
- Owner: ktbyers
- License: mit
- Created: 2014-11-28T21:42:52.000Z (almost 10 years ago)
- Default Branch: develop
- Last Pushed: 2024-05-23T01:00:28.000Z (6 months ago)
- Last Synced: 2024-05-23T01:42:17.142Z (6 months ago)
- Language: Python
- Size: 7.86 MB
- Stars: 3,455
- Watchers: 194
- Forks: 1,259
- Open Issues: 175
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- best-of-python - GitHub - 8% open · ⏱️ 16.05.2024): (Infrastructure & DevOps)
- awesome-list - Netmiko - Multi-vendor library to simplify Paramiko SSH connections to network devices. (Web Development / C++/C Toolkit)
README
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/netmiko.svg)](https://img.shields.io/pypi/pyversions/netmiko)
[![PyPI](https://img.shields.io/pypi/v/netmiko.svg)](https://pypi.python.org/pypi/netmiko)
[![Downloads](https://static.pepy.tech/badge/netmiko)](https://static.pepy.tech/badge/netmiko)
[![GitHub contributors](https://img.shields.io/github/contributors/ktbyers/netmiko.svg)](https://GitHub.com/ktbyers/netmiko/graphs/contributors/)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)Netmiko
=======Multi-vendor library to simplify CLI connections to network devices
## Contributing to Netmiko
[CONTRIBUTING.md](https://github.com/ktbyers/netmiko/blob/develop/CONTRIBUTING.md)
## Why Netmiko?
Network automation to screen-scraping devices is primarily concerned with gathering output from show commands and with making configuration changes.Netmiko aims to accomplish both of these operations and to do it across a very broad set of platforms. It seeks to do this while abstracting away low-level state control (i.e. eliminate low-level regex pattern matching to the extent practical).
## Getting Started
- [Getting Started](#getting-started-1)
## Examples
*You really should look here.*- [Netmiko Examples](https://github.com/ktbyers/netmiko/blob/develop/EXAMPLES.md)
## Supported Platforms
[PLATFORMS](PLATFORMS.md)
## Installation
To install netmiko, simply use pip:
```
$ pip install netmiko
```
## API-Documentation
[API-Documentation](https://ktbyers.github.io/netmiko/docs/netmiko/index.html)
## Common Issues/FAQ
Answers to some [common questions](COMMON_ISSUES.md)
### Tutorials
- [Netmiko Overview](https://pynet.twb-tech.com/blog/automation/netmiko.html)
- [Secure Copy](https://pynet.twb-tech.com/blog/automation/netmiko-scp.html)
- [Netmiko through SSH Proxy](https://pynet.twb-tech.com/blog/automation/netmiko-proxy.html)
- [Netmiko and TextFSM](https://pynet.twb-tech.com/blog/automation/netmiko-textfsm.html)
- [Netmiko and what constitutes done](https://pynet.twb-tech.com/blog/automation/netmiko-what-is-done.html)
### Getting Started:
#### Create a dictionary representing the device.
Supported device_types can be found in [ssh_dispatcher.py](https://github.com/ktbyers/netmiko/blob/master/netmiko/ssh_dispatcher.py), see CLASS_MAPPER keys.
```py
from netmiko import ConnectHandlercisco_881 = {
'device_type': 'cisco_ios',
'host': '10.10.10.10',
'username': 'test',
'password': 'password',
'port' : 8022, # optional, defaults to 22
'secret': 'secret', # optional, defaults to ''
}```
#### Establish an SSH connection to the device by passing in the device dictionary.
```py
net_connect = ConnectHandler(**cisco_881)
```#### Execute show commands.
```py
output = net_connect.send_command('show ip int brief')
print(output)
```
```
Interface IP-Address OK? Method Status Protocol
FastEthernet0 unassigned YES unset down down
FastEthernet1 unassigned YES unset down down
FastEthernet2 unassigned YES unset down down
FastEthernet3 unassigned YES unset down down
FastEthernet4 10.10.10.10 YES manual up up
Vlan1 unassigned YES unset down down
```#### Execute configuration change commands (will automatically enter into config mode)
```py
config_commands = [ 'logging buffered 20000',
'logging buffered 20010',
'no logging console' ]
output = net_connect.send_config_set(config_commands)
print(output)
```
```
pynet-rtr1#config term
Enter configuration commands, one per line. End with CNTL/Z.
pynet-rtr1(config)#logging buffered 20000
pynet-rtr1(config)#logging buffered 20010
pynet-rtr1(config)#no logging console
pynet-rtr1(config)#end
pynet-rtr1#
```
## API-Documentation
Below are some of the particularly handy Classes/functions for easy reference:
- [Base Connection Object](https://ktbyers.github.io/netmiko/docs/netmiko/base_connection.html)
- [SSH Autodetect](https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.SSHDetect)
- [SSH Dispatcher](https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.ssh_dispatcher)
- [Redispatch](https://ktbyers.github.io/netmiko/docs/netmiko/index.html#netmiko.redispatch)
## Contributing
Contributors are welcome.
You can contribute to Netmiko in a variety of ways: answering questions on Slack (see below in Questions/Discussions), responding to issues, adding to the common issues, reporting/fixing bugs, or even adding your own device type.
Before contributing a new vendor/platform device type, remember that any code added needs to be supported in some fashion. To add a vendor/platform you can follow the outline [here](VENDOR.md). Once you've worked on your first pass of your driver and have it functional, you'll need to include test data in order for it to be merged into develop, you can see the general flow of how to do that [here](TESTING.md).
For all code contributions, please ensure that you have ran `black` against the code or your code will fail the Travis CI build.
## Questions/Discussion
If you find an issue with Netmiko, then you can open an issue on this projects issue page here: [https://github.com/ktbyers/netmiko/issues](https://github.com/ktbyers/netmiko/issues). Please make sure you've read through the common issues and examples prior to opening an issue. Please only open issues for bugs, feature requests, or other topics related to development of Netmiko. If you simply have a question, join us on Slack...
If you have questions or would like to discuss Netmiko, a #netmiko channel exists in [this Slack](https://pynet.slack.com) workspace. To join, use [this invitation](https://join.slack.com/t/pynet/shared_invite/zt-km2k3upf-AkWHY4YEx3sI1R5irMmc7Q). Once you have entered the workspace, then you can join the #netmiko channel.
---
Kirk Byers
Python for Network Engineers
https://pynet.twb-tech.com