Merge "Set keepalive interval for paramiko SSHClient"
diff --git a/tcp_tests/managers/underlay_ssh_manager.py b/tcp_tests/managers/underlay_ssh_manager.py
index 5f919ce..44c8830 100644
--- a/tcp_tests/managers/underlay_ssh_manager.py
+++ b/tcp_tests/managers/underlay_ssh_manager.py
@@ -23,6 +23,7 @@
import yaml
from tcp_tests import logger
+from tcp_tests import settings
from tcp_tests.helpers import ext
from tcp_tests.helpers import utils
@@ -255,10 +256,14 @@
keys=[rsakey.RSAKey(file_obj=StringIO.StringIO(key))
for key in ssh_data['keys']])
- return ssh_client.SSHClient(
+ client = ssh_client.SSHClient(
host=ssh_data['host'],
port=ssh_data['port'] or 22,
auth=ssh_auth)
+ client._ssh.get_transport().set_keepalive(
+ settings.SSH_SERVER_ALIVE_INTERVAL)
+
+ return client
def local(self):
"""Get Subprocess instance for local operations like:
diff --git a/tcp_tests/settings.py b/tcp_tests/settings.py
index d45cd13..6fc6504 100644
--- a/tcp_tests/settings.py
+++ b/tcp_tests/settings.py
@@ -41,6 +41,15 @@
SSH_NODE_CREDENTIALS = {"login": SSH_LOGIN,
"password": SSH_PASSWORD}
+# http://docs.paramiko.org/en/2.4/api/transport.html\
+# #paramiko.transport.Transport.set_keepalive
+# If this is set, after interval seconds without sending any data over the
+# connection, a "keepalive" packet will be sent (and ignored by the remote
+# host). Similar to ServerAliveInterval for ssh_config.
+# '0' to disable keepalives.
+SSH_SERVER_ALIVE_INTERVAL = int(
+ os.environ.get('SSH_SERVER_ALIVE_INTERVAL', 60))
+
# public_iface = IFACES[0]
# private_iface = IFACES[1]
IFACES = [
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index cad0222..b042a01 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -722,7 +722,7 @@
-C 'I@salt:master' state.sls openssh &&
salt --hard-crash --state-output=mixed --state-verbose=False
-C 'I@salt:master' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
- yes/' /etc/ssh/sshd_config && sed -i 's/ClientAliveInterval 300/ClientAliveInterval 18000/' /etc/ssh/sshd_config && service ssh reload"
+ yes/' /etc/ssh/sshd_config && service ssh reload"
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 3, delay: 5}
skip_fail: false
@@ -895,7 +895,7 @@
cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@linux:system and not cfg01*' state.sls openssh &&
salt --hard-crash --state-output=mixed --state-verbose=False
-C 'I@linux:system and not cfg01*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
- yes/' /etc/ssh/sshd_config && sed -i 's/ClientAliveInterval 300/ClientAliveInterval 18000/' /etc/ssh/sshd_config && service ssh reload"
+ yes/' /etc/ssh/sshd_config && service ssh reload"
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 5}
skip_fail: false