Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_rancid_for_vlan():
- vlans = get_vlans()
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(rancid_host, username=username, password=password)
- results = {}
- for i in vlans:
- stdin, stdout, stderr = client.exec_command('cd /var/home/configs; device q Vlan{}'.format(i))
- for line in stdout:
- if "no" not in line:
- device = line.split(":")[0]
- if i in results:
- results[device].append(i)
- else:
- results[device] = [i]
- for key, val in results.iteritems():
- for i in val:
- print(key,i)
- client.close()
- (u'switch1', 1001)
- (u'switch2', 1002)
- (u'switch3', 1003)
- (u'switch4', 1004)
- parse.find_objects_w_child(r"interface", vlan)
Add Comment
Please, Sign In to add comment