MCPcopy Create free account
hub / github.com/apache/impala / connect

Method connect

tests/util/ssh_util.py:53–81  ·  view source on GitHub ↗

Connect to the host. 'kwargs' is the same as paramiko's connect() kwargs. By default user name and ssh key auto-detection will be the same as 'ssh' from the command line, except ~/.ssh/config will not be used.

(self, host_name, retries=3, **kwargs)

Source from the content-addressed store, hash-verified

51 self.connect_kwargs = None
52
53 def connect(self, host_name, retries=3, **kwargs):
54 """Connect to the host. 'kwargs' is the same as paramiko's connect() kwargs. By
55 default user name and ssh key auto-detection will be the same as 'ssh' from the
56 command line, except ~/.ssh/config will not be used.
57 """
58 self.host_name = host_name
59 if "timeout" not in kwargs:
60 kwargs["timeout"] = 5 * 60 # 5 min TCP timeout
61 self.connect_kwargs = kwargs
62
63 for retry in range(retries):
64 if retry:
65 time.sleep(3)
66 try:
67 super(SshClient, self).connect(host_name, **self.connect_kwargs)
68 break
69 except paramiko.ssh_exception.AuthenticationException:
70 raise
71 except Exception as e:
72 LOG.warn("Error connecting to %s" % host_name, exc_info=True)
73 if retry >= retries - 1:
74 LOG.error("Failed to ssh to %s" % host_name)
75 raise e
76
77 self.get_transport().set_keepalive(10)
78
79 # Work around https://github.com/paramiko/paramiko/issues/17 -- python doesn't
80 # shutdown properly if connections are open.
81 atexit.register(self.close)
82
83 def shell(self, cmd, cmd_prepend="set -euo pipefail\n", timeout_secs=None):
84 """Executes a command and returns its output. If the command's return code is

Callers 4

shellMethod · 0.95
cancel_queryMethod · 0.45
run_queryFunction · 0.45
client_factoryFunction · 0.45

Calls 4

rangeFunction · 0.85
warnMethod · 0.80
errorMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected