Created
August 15, 2016 11:46
-
-
Save tcuthbert/ee7003ab2ccda0c406ac2cc6231cf749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from time import sleep | |
from collections import deque | |
from twisted.internet.defer import Deferred | |
# from twisted.python import log | |
# log.startLogging(sys.stdout, setStdout=False) | |
from trigger.netdevices import NetDevices, NetDevice | |
# Open connection to two devices. | |
nd = NetDevices() | |
dev = nd.find('r1.demo.local') | |
dev2 = nd.find('arista-sw1.demo.local') | |
dev.open() | |
dev2.open() | |
# Pause due to timing inconsistencies experienced in some devices. | |
sleep(5) | |
# Execute some commands | |
print "Begin example" | |
r10 = dev2.run_channeled_commands(['show clock', 'show version']) | |
# Loop until the output of show version on arista-sw1 finishes | |
while "result" not in dir(r10): | |
sys.stdout.write("\rStill waiting on results") | |
sys.stdout.flush() | |
sys.stdout.write("\n") | |
# Print the output of show version which is the second vector in the results array. | |
print "Got results:" | |
print r10.result[1] | |
# Perform some action based on the output of arista-sw1's show version | |
if 'Software image version: 4.12.0-1244667' in r10.result[1]: | |
print "{} has eos version 4.12.0-1244667".format(dev2.nodeName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment