Advertisement
Guest User

Untitled

a guest
May 3rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. from jnpr.junos.utils.config import Config
  2. from jnpr.junos import Device
  3. from lxml import etree as ET
  4.  
  5. # pull info about the device itself
  6. def Factoids():
  7.     target = Device(host='192.168.150.220', user='labmin', password='Labmin')
  8.     target.open()
  9.     tfacts = target.facts
  10.     # just some random info as a demo
  11.     print("*********************************************",'\n',
  12.           "Target hostname is: ", tfacts['hostname'], ".", tfacts['domain'], sep='')
  13.  
  14. #Factoids()
  15.  
  16. # lock 'n load
  17. # target = Config(host='192.168.150.220', user='labmin', password='Labmin')
  18. # target.lock()
  19.  
  20. target = Device(host='192.168.150.220', user='labmin', password='Labmin', gather_facts=False)
  21. target.open()
  22. # info = target.rpc.get_config(filter_xml="interfaces/interface/[description='Test Trunk']", model='ietf')
  23. info = target.rpc.get_config(filter_xml="<configuration><interfaces><interface><name>ge-0/0/0</name></interface></interfaces></configuration>")
  24. print(info.__class__)
  25. print(info.findtext('vlan-id'))
  26. print(info.findtext('unit'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement