Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <rpc>
  2. <get-xxx>
  3. </get-xxx>
  4. </rpc>
  5.  
  6. from ncclient import manager
  7.  
  8.  
  9. def connect(host, port, user, password):
  10. conn = manager.connect(host=host,
  11. port=port,
  12. username=user,
  13. password=password,
  14. timeout=10,
  15. device_params = {'name':'junos'},
  16. hostkey_verify=False)
  17.  
  18.  
  19. result = conn.get_chassis_inventory()
  20. print ("Chassis:", result.xpath('//chassis/description')[0].text)
  21. print ("Chassis Serial-Number:", result.xpath('//chassis/serial-number')[0].text)
  22.  
  23. result2 = conn.get_system_uptime_information()
  24. print(result2.xpath('//system-booted-time/date-time')[0].text)
  25.  
  26. if __name__ == '__main__':
  27. connect('192.168.250.254', 830, 'root', 'root123')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement