Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3.  
  4. import logging
  5.  
  6. from ncclient import manager
  7.  
  8.  
  9. def connect(host, port, username, password):
  10. conn = manager.connect(host=host,
  11. port=port,
  12. username=username,
  13. password=password,
  14. timeout=60,
  15. device_params={'name': 'junos'},
  16. hostkey_verify=False)
  17.  
  18. logging.info('show chassis cluster status')
  19. logging.info('*' * 30)
  20. result = conn.rpc("<command format=\"json\">show chassis cluster status</command>")
  21. logging.info(result)
  22.  
  23.  
  24. if __name__ == '__main__':
  25. LOG_FORMAT = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(message)s'
  26. logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=LOG_FORMAT)
  27.  
  28. host = "<changeme>"
  29. username = "<changeme>"
  30. password = "<changeme>"
  31. port = "<changeme>"
  32. connect(host=host, port=port, username=username, password=password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement