Guest User

Untitled

a guest
Apr 17th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def check_rancid_for_vlan():
  2. vlans = get_vlans()
  3.  
  4. client = paramiko.SSHClient()
  5. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  6. client.connect(rancid_host, username=username, password=password)
  7.  
  8. results = {}
  9. for i in vlans:
  10. stdin, stdout, stderr = client.exec_command('cd /var/home/configs; device q Vlan{}'.format(i))
  11.  
  12. for line in stdout:
  13. if "no" not in line:
  14. device = line.split(":")[0]
  15. if i in results:
  16. results[device].append(i)
  17. else:
  18. results[device] = [i]
  19.  
  20. for key, val in results.iteritems():
  21. for i in val:
  22. print(key,i)
  23.  
  24. client.close()
  25.  
  26. (u'switch1', 1001)
  27. (u'switch2', 1002)
  28. (u'switch3', 1003)
  29. (u'switch4', 1004)
  30.  
  31. parse.find_objects_w_child(r"interface", vlan)
Add Comment
Please, Sign In to add comment