MCPcopy Create free account
hub / github.com/apache/cloudstack / __init__

Method __init__

tools/marvin/marvin/sshClient.py:51–81  ·  view source on GitHub ↗
(self, host, port, user, passwd, retries=60, delay=10,
                 log_lvl=logging.DEBUG, keyPairFiles=None, timeout=10.0)

Source from the content-addressed store, hash-verified

49 '''
50
51 def __init__(self, host, port, user, passwd, retries=60, delay=10,
52 log_lvl=logging.DEBUG, keyPairFiles=None, timeout=10.0):
53 self.host = None
54 self.port = 22
55 self.user = user
56 self.passwd = passwd
57 self.keyPairFiles = keyPairFiles
58 self.ssh = SSHClient()
59 self.ssh.set_missing_host_key_policy(AutoAddPolicy())
60 self.logger = logging.getLogger('sshClient')
61 self.retryCnt = 0
62 self.delay = 0
63 self.timeout = 3.0
64 self.ch = logging.StreamHandler()
65 self.ch.setLevel(log_lvl)
66 self.logger.addHandler(self.ch)
67
68 # Check invalid host value and raise exception
69 # Atleast host is required for connection
70 if host is not None and host != '':
71 self.host = host
72 if retries is not None and retries > 0:
73 self.retryCnt = retries
74 if delay is not None and delay > 0:
75 self.delay = delay
76 if timeout is not None and timeout > 0:
77 self.timeout = timeout
78 if port is not None and port >= 0:
79 self.port = port
80 if self.createConnection() == FAILED:
81 raise internalError("SSH Connection Failed")
82
83 def execute(self, command):
84 stdin, stdout, stderr = self.ssh.exec_command(command)

Callers

nothing calls this directly

Calls 4

createConnectionMethod · 0.95
internalErrorClass · 0.90
getLoggerMethod · 0.45
setLevelMethod · 0.45

Tested by

no test coverage detected