Python Script to find Cisco IOS facts

 Today I need that I should find one of the device Serial Number, Uptime, Vendor, Model & Hostname. I found Napalm module is the best and simplest way to connect device and get the IOS facts. I will work on all the Napalm modules and try to create some scripts and share it with everyone. 

Script

import json

from napalm import get_network_driver - Napalm Module

driver = get_network_driver('ios')

iosvl2 = driver('X.X.X.X', 'username', 'password')

iosvl2.open()


ios_output = iosvl2.get_facts()

print (json.dumps(ios_output, indent=4))


iosvl2.close()



Output

"uptime": 16750860,

    "vendor": "Cisco",

    "os_version": "ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.7, RELEASE SOFTWARE (fc2)",

    "serial_number": "FDO2152A0UZ",

    "model": "ISR4321/K9",

    "hostname": "AU-BRI-RV01",

    "fqdn": "AU-BRI-RV01.aurpac.radiometer.rmg",

    "interface_list": [

        "GigabitEthernet0/0/0",

        "GigabitEthernet0/0/1",

        "GigabitEthernet0",

        "Dialer1",

        "Loopback1",

        "Tunnel1",

        "Virtual-Access1",

        "Virtual-Access2"

Comments