Fix issue with the connect expect logic caused when running teston then the test instead of running both from one command
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 9db8f6f..6c537e6 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -53,31 +53,31 @@
self.handle =pexpect.spawn('ssh -X '+self.user_name+'@'+self.ip_address,maxread=50000)
self.handle.logfile = self.logfile_handler
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'>|#|\$'],120)
-
- if i==0:
- main.log.info("ssh key confirmation received, send yes")
- self.handle.sendline('yes')
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
- if i==1:
- main.log.info("ssh connection asked for password, gave password")
- self.handle.sendline(self.pwd)
- self.handle.expect('>|#|\$')
-
- elif i==2:
- main.log.error("Connection timeout")
- return main.FALSE
- elif i==3: #timeout
- main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
- return main.FALSE
- elif i==4:
- main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
- return main.FALSE
- elif i==5:
- main.log.info("Password not required logged in")
+ i = 5
+ while i == 5:
+ i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'teston>','>|#|\$'],120)
+ if i==0:
+ main.log.info("ssh key confirmation received, send yes")
+ self.handle.sendline('yes')
+ i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF])
+ if i==1:
+ main.log.info("ssh connection asked for password, gave password")
+ self.handle.sendline(self.pwd)
+ self.handle.expect('>|#|\$')
+ elif i==2:
+ main.log.error("Connection timeout")
+ return main.FALSE
+ elif i==3: #timeout
+ main.log.error("No route to the Host "+self.user_name+"@"+self.ip_address)
+ return main.FALSE
+ elif i==4:
+ main.log.error("ssh: connect to host "+self.ip_address+" port 22: Connection refused")
+ return main.FALSE
+ elif i==6:
+ main.log.info("Password not required logged in")
self.handle.sendline("\n")
- self.handle.expect('>|#|\$', 2)
+ self.handle.expect('>|#|\$')
return self.handle
@@ -99,7 +99,7 @@
'''
result = super(CLI, self).execute(self)
- defaultPrompt = '.*[\$>\#]'
+ defaultPrompt = '.*[\$|>|#]'
args = utilities.parse_args(["CMD", "TIMEOUT", "PROMPT", "MORE"], **execparams)
expectPrompt = args["PROMPT"] if args["PROMPT"] else defaultPrompt
self.LASTRSP = ""