-
-
Save johnfzc/b36a99ba573f7f6670c0 to your computer and use it in GitHub Desktop.
This file contains 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
S8_Test_CPE#reload in 5 | |
Reload scheduled for 15:30:08 DST Sat Apr 11 2015 (in 5 minutes) by deploy on vty1 (10.171.0.22) | |
Reload reason: Reload Command | |
Proceed with reload? [confirm] | |
S8_Test_CPE# | |
*** | |
*** --- SHUTDOWN in 0:05:00 --- | |
*** | |
S8_Test_CPE# | |
S8_Test_CPE# | |
S8_Test_CPE#reload cancel | |
S8_Test_CPE# | |
*** | |
*** --- SHUTDOWN ABORTED --- | |
*** | |
S8_Test_CPE# | |
S8_Test_CPE# | |
Explained: | |
All the newlines in this are output by the router, ter mon is off. | |
This is the direct output, using openssh, of issuing reload in 5. The prompt follows the confirm, then the shutdown in 5 is output. | |
S8_Test_CPE#reload in 5 | |
Reload scheduled for 09:29:51 DST Sun Apr 12 2015 (in 5 minutes) by johnf on vty0 (10.171.0.22) | |
Reload reason: Reload Command | |
Proceed with reload? [confirm] | |
S8_Test_CPE# | |
*** | |
*** --- SHUTDOWN in 0:05:00 --- | |
*** | |
I now press enter a few times for a fresh prompt, then issue reload cancel. The same behaviour is observed; reload cancel immediately returns a prompt, then the shutdown aborted text is output. | |
S8_Test_CPE#reload cancel | |
S8_Test_CPE# | |
*** | |
*** --- SHUTDOWN ABORTED --- | |
*** | |
It looks like two leading new lines, followed by the message, then one trailing newline. No new prompt is issued after the output. |
This file contains 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
johnf@pstanadm1:~/TriggerTest$ ./TriggerBasic.py | |
2015-04-11 15:27:19-0400 [-] Log opened. | |
2015-04-11 15:27:19-0400 [-] Adding r1 | |
2015-04-11 15:27:19-0400 [-] connections: 1 | |
2015-04-11 15:27:19-0400 [-] Adding work to queue... | |
2015-04-11 15:27:19-0400 [-] Sending ['reload in 5', 'y', 'reload cancel', 'show ver'] to r1 | |
2015-04-11 15:27:19-0400 [-] execute_ioslike: SSH ENABLED for r1 | |
2015-04-11 15:27:19-0400 [-] Creds not valid, fetching from .tacacsrc... | |
2015-04-11 15:27:19-0400 [-] Using GPG method: False | |
2015-04-11 15:27:19-0400 [-] Got username: 'johnf' | |
2015-04-11 15:27:19-0400 [-] skipping '# Saved by trigger.tacacsrc at 2015-01-03 21:43:54 EST' | |
2015-04-11 15:27:19-0400 [-] skipping '' | |
2015-04-11 15:27:19-0400 [-] INITIAL COMMANDS: [] | |
2015-04-11 15:27:19-0400 [-] Trying Async PTY SSH to r1:22 | |
2015-04-11 15:27:19-0400 [-] Starting factory <trigger.twister.TriggerSSHChannelFactory object at 0x7ff26c767850> | |
2015-04-11 15:27:19-0400 [-] Reactor running? False | |
2015-04-11 15:27:19-0400 [-] No work left. | |
2015-04-11 15:27:19-0400 [-] starting reactor | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] kex alg, key alg: diffie-hellman-group-exchange-sha1 ssh-rsa | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] outgoing: aes256-cbc hmac-sha1 none | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] incoming: aes256-cbc hmac-sha1 none | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] REVERSE | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] NEW KEYS | |
2015-04-11 15:27:19-0400 [TriggerSSHTransport,client] starting service ssh-userauth | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Previous method: 'none' | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Previous method failed, skipping it... | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Can continue with: ['password', 'keyboard-interactive', 'publickey'] | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Already tried: ['none'] | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] trying to auth with password | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Performing password authentication | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] starting service ssh-connection | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] channel = <class 'trigger.twister.TriggerSSHAsyncPtyChannel'> | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Connection success. | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] Connection information: <trigger.twister.TriggerSSHTransport object at 0x7ff26c77e050> | |
2015-04-11 15:27:19-0400 [SSHService ssh-userauth on TriggerSSHTransport,client] opening channel 0 with 131072 32768 | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] COMMANDS: ['reload in 5', 'y', 'reload cancel', 'show ver'] | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] My startup commands: ['terminal length 0'] | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] sending request pty-req | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] sending request shell | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] Got channel request response! | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '\r\nS8_Test_CPE#' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] STATE: prompt 'S8_Test_CPE#' | |
2015-04-11 15:27:19-0400 [-] [r1] Not initialized; sending startup commands | |
2015-04-11 15:27:19-0400 [-] [r1] Sending initialize command: 'terminal length 0' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 't' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'e' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'r' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'm' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'i' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'n' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'a' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'l' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: ' ' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'l' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'e' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'n' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'g' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 't' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'h' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: ' ' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '0' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '\r\n' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'S8_Test_CPE#' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] STATE: prompt 'S8_Test_CPE#' | |
2015-04-11 15:27:19-0400 [-] [r1] Not initialized; sending startup commands | |
2015-04-11 15:27:19-0400 [-] [r1] Successfully initialized for command execution | |
2015-04-11 15:27:19-0400 [-] [r1] Sending SSH command 'reload in 5' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'r' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'e' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'l' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'o' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'a' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'd' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: ' ' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'i' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'n' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: ' ' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '5' | |
2015-04-11 15:27:19-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '\r\n' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'Reload scheduled for 15:32:19 DST Sat Apr 11 2015 (in 5 minutes) by deploy on vty1 (10.171.0.22)\r\nReload reason: Reload Command\r\nProceed with reload? [confirm]' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] Got confirmation prompt: 'reload in 5\r\nReload scheduled for 15:32:19 DST Sat Apr 11 2015 (in 5 minutes) by deploy on vty1 (10.171.0.22)\r\nReload reason: Reload Command\r\nProceed with reload? [confirm]' | |
2015-04-11 15:27:20-0400 [-] [r1] Sending SSH command 'y' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'y\r\nS8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] STATE: prompt 'S8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [-] [r1] Sending SSH command 'reload cancel' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '\r\n' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'S8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] STATE: prompt 'S8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [-] [r1] Sending SSH command 'show ver' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'r' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'e' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'l' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'o' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'a' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'd' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: ' ' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'c' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'a' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'n' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'c' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'e' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'l' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: '\r\n' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] BYTES: 'S8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [SSHChannel session (0) on SSHService ssh-connection on TriggerSSHTransport,client] [r1] STATE: prompt 'S8_Test_CPE#' | |
2015-04-11 15:27:20-0400 [-] [r1] CHANNEL: out of commands, closing connection... | |
2015-04-11 15:27:20-0400 [-] [r1] Forcefully closing transport connection | |
2015-04-11 15:27:20-0400 [-] Got disconnect request, reason: 10, desc: 'user closed connection' | |
2015-04-11 15:27:20-0400 [-] Disconnecting with error, code 10 | |
reason: user closed connection | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Forcefully closing transport connection! | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Got disconnect request, reason: 10, desc: 'user closed connection' | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Disconnecting with error, code 10 | |
reason: user closed connection | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] connection lost | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Transport connection lost: Connection was closed cleanly. | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Client connection lost. Reason: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly. | |
] | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Got results: ['', '', '', ''] | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Received ['', '', '', ''] from r1 | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Storing results for 'r1': {'y': '', 'reload in 5': '', 'show ver': '', 'reload cancel': ''} | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Reactor running? True | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] stopping reactor | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] Stopping factory <trigger.twister.TriggerSSHChannelFactory object at 0x7ff26c767850> | |
2015-04-11 15:27:20-0400 [TriggerSSHTransport,client] All done! | |
2015-04-11 15:27:20-0400 [-] Main loop terminated. | |
{'r1': {'y': '', 'reload in 5': '', 'show ver': '', 'reload cancel': ''}} |
This file contains 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/python | |
from trigger.netdevices import NetDevices | |
from trigger.cmds import Commando | |
from trigger.cmds import ReactorlessCommando | |
import time | |
from twisted.python import log | |
import sys | |
nd = NetDevices() | |
log.startLogging(sys.stdout, setStdout=False) | |
# Print Count of devices | |
# print len(nd) | |
class ShowClock(Commando): | |
"""Execute 'show clock' on a list of Cisco devices.""" | |
vendors = ['cisco'] | |
commands = ['reload in 5','y','reload cancel','show ver'] | |
if __name__ == '__main__': | |
device_list = ['r1'] | |
showclock = ShowClock(devices=device_list) | |
showclock.run() # Commando exposes this to start the event loop | |
print showclock.results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment