Napalm script to display device hsotname, serial number and os version

This program displays the hostname, serial number, and OS version of a device. The “get_facts” command includes all of these details. We need to modify the parameters so that it displays the result as per our requirements.

Complete program for displaying hostname, serial number and os version

from napalm import get_network_driver
import json
driver = get_network_driver('ios')
with driver('','developer','C1sco12345') as device:
     output = json.dumps(device.get_facts())
     result = json.loads(output)
     print('Serial Number : ',result['serial_number'])
     print('Hostname : ',result['hostname'])
     print('OS version : ',result['os_version'])


Serial Number :  9ESGOBARV9D
Hostname :  csr1000v-1
OS version :  Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 17.3.1a, RELEASE SOFTWARE (fc3)

Process finished with exit code 0

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s