"Want more expert insights and updates? Follow us on LinkedIn and explore our company page to connect with us directly. Don’t miss out - click the link and join the conversation!"
Follow us on LinkedIn / plexinor
Company Website Https://www.plexinor.com
since angle brackets are not allowed replaced them with a £ symbol, when testing your script please replace the £ back to angle brackets
lab@admin:~$ cat F2
from jnpr.junos import Device
from lxml import etree
import getpass
user = input('Device Username: ')
password = getpass.getpass('Device Password for: ')
with open('IP-LIST') as f:
devices = f.read().splitlines()
print (devices)
#Loop through each host specified on the command line.
for ip in devices:
dev = Device(host=ip, user=user, passwd=password)
print("Opening %s." % (ip))
dev.open()
data = dev.rpc.get_config(filter_xml=etree.XML("""£configuration£
£interfaces£
£interface£
£name£lo0£/name£
£/interface£
£/interfaces£
£/configuration£"""),
normalize=False,
options={'inherit':'inherit',
'database':'committed',
'format':'text'})
if data is not None:
print("Configuration:\n%s" % (data.text))
dev.close()
lab@admin:~$ cat F1
from jnpr.junos import Device
from lxml import etree
import getpass
user = input('Device Username: ')
password = getpass.getpass('Device Password for: ')
with open('IP-LIST') as f:
devices = f.read().splitlines()
print (devices)
#Loop through each host specified on the command line.
for ip in devices:
dev = Device(host=ip, user=user, passwd=password)
print("Opening %s." % (ip))
dev.open()
data = dev.rpc.get_config(filter_xml=etree.XML("""£configuration£
£protocols£
£bgp£
£/bgp£
£/protocols£
£interfaces£
£interface£
£name£lo0£/name£
£/interface£
£/interfaces£
£/configuration£"""),
normalize=False,
options={'inherit':'inherit',
'database':'committed',
'format':'text'})
if data is not None:
print("Configuration:\n%s" % (data.text))
dev.close()