31 March, 2019

#1 - Basic Python - Netmiko scripts to automate Network Tasks


#!/usr/bin/python

import netmiko
import json

connection = netmiko.ConnectHandler(ip="10.0.10.105", device_type="cisco_ios", username="admin", password="cisco")

connection
print("-"*50)
print(connection.send_command("show running-config | in hostname"))
print(connection.send_command("show clock"))
print(connection.send_command("show ip interface brief"))
print("-"*50)
connection.disconnect

Result :

python@python:~$ ./command.py
--------------------------------------------------
hostname ZXYNR0801
*14:22:46.559 UTC Sun Mar 31 2019
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down
GigabitEthernet1/0         10.0.10.105     YES manual up                    up
--------------------------------------------------