Skip to content

Commit 0c26f35

Browse files
Prasanna SanthanamPrasanna Santhanam
authored andcommitted
Add additional retries to the SSH client by default
1 parent d82158d commit 0c26f35

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

tools/marvin/marvin/TestCaseExecuteEngine.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
# limitations under the License.
1111
#
1212
# Automatically generated by addcopyright.py at 04/03/2012
13-
try:
14-
import unittest2 as unittest
15-
except ImportError:
16-
import unittest
1713

18-
from functools import partial
14+
import unittest
1915
import os
2016
import sys
2117
import logging
18+
from functools import partial
2219

2320
def testCaseLogger(message, logger=None):
2421
if logger is not None:

tools/marvin/marvin/cloudstackTestCase.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
#
1212
# Automatically generated by addcopyright.py at 04/03/2012
1313
from cloudstackAPI import *
14-
try:
15-
import unittest2 as unittest
16-
except ImportError:
17-
import unittest
14+
import unittest
1815
import cloudstackTestClient
1916

2017
#class UserName(object):

tools/marvin/marvin/remoteSSHClient.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,31 @@
1111
#
1212
# Automatically generated by addcopyright.py at 04/03/2012
1313
import paramiko
14+
import time
1415
import cloudstackException
16+
1517
class remoteSSHClient(object):
16-
def __init__(self, host, port, user, passwd):
18+
def __init__(self, host, port, user, passwd, retries = 10):
1719
self.host = host
1820
self.port = port
1921
self.user = user
2022
self.passwd = passwd
2123
self.ssh = paramiko.SSHClient()
2224
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
23-
try:
24-
self.ssh.connect(str(host),int(port), user, passwd)
25-
except paramiko.SSHException, sshex:
26-
raise cloudstackException.InvalidParameterException(repr(sshex))
25+
26+
retry_count = retries
27+
while True:
28+
try:
29+
self.ssh.connect(str(host),int(port), user, passwd)
30+
except paramiko.SSHException, sshex:
31+
if retry_count == 0:
32+
raise cloudstackException.InvalidParameterException(repr(sshex))
33+
retry_count = retry_count - 1
34+
time.sleep(5)
35+
except paramiko.AuthenticationException, authEx:
36+
raise cloudstackException.InvalidParameterException("Invalid credentials to login to %s on port %s"%(str(host), port))
37+
else:
38+
return
2739

2840
def execute(self, command):
2941
stdin, stdout, stderr = self.ssh.exec_command(command)

0 commit comments

Comments
 (0)