Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactorNotRestartable error when running both Commando and CommandRunner #311

Open
adhirchakravarti opened this issue Feb 6, 2017 · 1 comment
Labels

Comments

@adhirchakravarti
Copy link

Hello,

Let me start by saying thanks for creating trigger! I'm new to both trigger and python, so if this is the wrong place to post this issue, please let me know so that I may post it elsewhere.

I've just started using trigger am trying to accomplish a simple task of sending configuration commands to a Cisco router using the CommandRunner object, followed by sending verification commands using Commando to retrieve and print output. If I use only 1 instance (either Commando or CommandRunner), there are no issues and the code executes well. However using both causes that error.

Am I missing something?

Error:

ubuntu@ubuntu-VirtualBox:~/MyFiles/Cisco$ ls 
Commando_Cisco.py  CommandRunner2_Cisco.py  CommandRunner_Cisco.py  commands1.txt  verification1.txt
ubuntu@ubuntu-VirtualBox:~/MyFiles/Cisco$ python CommandRunner2_Cisco.py 

Enter devices separated by comma: 172.16.1.11

Enter files separated by comma. Example: /home/ubuntu/cmd1.txt: commands1.txt

Commands executed successfully on all devices.

Traceback (most recent call last):
  File "CommandRunner2_Cisco.py", line 58, in <module>
    cmd2.run()
  File "/usr/local/lib/python2.7/dist-packages/trigger-1.5.9-py2.7.egg/trigger/cmds.py", line 596, in run
  File "/usr/local/lib/python2.7/dist-packages/trigger-1.5.9-py2.7.egg/trigger/cmds.py", line 584, in _start
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 1193, in run
    self.startRunning(installSignalHandlers=installSignalHandlers)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 1173, in startRunning
    ReactorBase.startRunning(self)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 684, in startRunning
    raise error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable
ubuntu@ubuntu-VirtualBox:~/MyFiles/Cisco$ 

Here is the code within the script (CommandRunner2_Cisco.py):

#Importing the necessary modules.
from trigger.cmds import Commando
from trigger.contrib.docommand import CommandRunner
import time

try:
	devices = raw_input('\nEnter devices separated by comma: ')
	cmd_files = raw_input('\nEnter files separated by comma. Example: /home/ubuntu/cmd1.txt: ')
	#verf_file_name = raw_input('\nEnter file containing verification commands: ')
	
	#Splitting the devices/commands entered by the user.
	devices_list = devices.split(',')
	cmd_files_list = cmd_files.split(',')
	
	
	#f = open(verf_file_name, 'r')
	#lines = f.readlines()
	#f.close()
	
	verf_cmds = []
	#for line in lines:
		#line = line.rstrip('\n')
		#print line
		#verf_cmds.append(line)
	
	#print "verification commands: ", verf_cmds
	
	ver_cmds = ['sh run | in username','sh run | in ip domain name']
	
	#Running all commands from all the given files on all given devices.
	cmd = CommandRunner(devices = devices_list, files = cmd_files_list)
		
	#Executing all the work in real time.
	cmd.run()

	print '\nCommands executed successfully on all devices.\n'
	
	#time.sleep(2)
	
	cmd2 = Commando(devices = devices_list, commands = ver_cmds)
	
	cmd2.run()
	
	output = cmd2.results
	
	for device in devices_list:
		print output[device]
		print "\n"	
	
#Raise exception in case one file does not exist. IP addresses are already verified by Trigger.
except IOError, reason:
	print '\nError! Reason: ' + str(reason) + '.\n'
	print 'Please check the file(s) and paths. Redirecting back to prompt...\n'

#End Of Program

@jathanism
Copy link
Member

Unfortunately this is a known issue w/ trigger.contrib.docommand that we have yet to rectify!

See: #152

Thanks for reporting this.

@jathanism jathanism added the bug label Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants