updates for terminating program after fatal SSH Errors
This commit is contained in:
@@ -83,10 +83,13 @@ class openair(core):
|
|||||||
return (stdout, stderr)
|
return (stdout, stderr)
|
||||||
|
|
||||||
def connect(self, username, password, prompt='PEXPECT_OAI'):
|
def connect(self, username, password, prompt='PEXPECT_OAI'):
|
||||||
while True:
|
max_retries=100
|
||||||
|
i=0
|
||||||
|
while i <= max_retries:
|
||||||
self.prompt1 = prompt
|
self.prompt1 = prompt
|
||||||
self.prompt2 = prompt
|
self.prompt2 = prompt
|
||||||
self.password = ''
|
self.password = ''
|
||||||
|
i=i+1
|
||||||
# WE do not store the password when sending commands for secuirity reasons. The password might be accidentally logged in such cases.
|
# WE do not store the password when sending commands for secuirity reasons. The password might be accidentally logged in such cases.
|
||||||
#The password is used only to make ssh connections. In case user wants to run programs with sudo, then he/she needs to add following line in /etc/sudoers
|
#The password is used only to make ssh connections. In case user wants to run programs with sudo, then he/she needs to add following line in /etc/sudoers
|
||||||
# your_user_name ALL=(ALL:ALL) NOPASSWD: ALL
|
# your_user_name ALL=(ALL:ALL) NOPASSWD: ALL
|
||||||
@@ -113,7 +116,9 @@ class openair(core):
|
|||||||
print error
|
print error
|
||||||
print "Retrying again in 1 seconds"
|
print "Retrying again in 1 seconds"
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
#sys.exit(1)
|
if i==max_retries:
|
||||||
|
print "Fatal Error: Terminating the program now..."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def connect2(self, username, password, prompt='$'):
|
def connect2(self, username, password, prompt='$'):
|
||||||
self.prompt1 = prompt
|
self.prompt1 = prompt
|
||||||
|
|||||||
@@ -273,9 +273,12 @@ def SSHSessionWrapper(machine, username, key_file, password, logdir_remote_testc
|
|||||||
error = error + '\n username = ' + username + '\n machine = ' + machine + '\n logdir_remote = ' + logdir_remote_testcase + '\n logdir_local_base = ' + logdir_local_base
|
error = error + '\n username = ' + username + '\n machine = ' + machine + '\n logdir_remote = ' + logdir_remote_testcase + '\n logdir_local_base = ' + logdir_local_base
|
||||||
error = error + traceback.format_exc()
|
error = error + traceback.format_exc()
|
||||||
print error
|
print error
|
||||||
print " Trying again in 1 seconds"
|
print " Retrying again in 1 seconds"
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print "Continuing ..."
|
print "Continuing ..."
|
||||||
|
if i ==max_tries:
|
||||||
|
print "Fatal Error: Max no of retries reached. Exiting now..."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user