aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/en/sos-collect.115
-rw-r--r--sos/collector/__init__.py6
-rw-r--r--sos/collector/clusters/__init__.py10
-rw-r--r--sos/collector/exceptions.py13
-rw-r--r--sos/collector/sosnode.py16
5 files changed, 58 insertions, 2 deletions
diff --git a/man/en/sos-collect.1 b/man/en/sos-collect.1
index e930023e..8ad4fe5e 100644
--- a/man/en/sos-collect.1
+++ b/man/en/sos-collect.1
@@ -43,6 +43,7 @@ sos collect \- Collect sosreports from multiple (cluster) nodes
[\-\-sos-cmd SOS_CMD]
[\-t|\-\-threads THREADS]
[\-\-timeout TIMEOUT]
+ [\-\-transport TRANSPORT]
[\-\-tmp\-dir TMP_DIR]
[\-v|\-\-verbose]
[\-\-verify]
@@ -351,6 +352,20 @@ runtime of sos collect via timeout*(number of nodes/jobs).
Default is 180 seconds.
.TP
+\fB\-\-transport\fR TRANSPORT
+Specify the type of remote transport to use to manage connections to remote nodes.
+
+\fBsos collect\fR uses locally installed binaries to connect to and interact with remote
+nodes, instead of directly establishing those connections. By default, OpenSSH's ControlPersist
+feature is preferred, however certain cluster types may have preferences of their own for how
+remote sessions should be established.
+
+The types of transports supported are currently as follows:
+
+ \fBauto\fR Allow the cluster type to determine the transport used
+ \fBcontrol_persist\fR Use OpenSSH's ControlPersist feature. This is the default behavior
+
+.TP
\fB\-\-tmp\-dir\fR TMP_DIR
Specify a temporary directory to save sos archives to. By default one will be created in
/tmp and then removed after sos collect has finished running.
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index da912655..fecfe6aa 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -98,6 +98,7 @@ class SoSCollector(SoSComponent):
'ssh_port': 22,
'ssh_user': 'root',
'timeout': 600,
+ 'transport': 'auto',
'verify': False,
'usernames': [],
'upload': False,
@@ -378,6 +379,8 @@ class SoSCollector(SoSComponent):
help='Specify an SSH user. Default root')
collect_grp.add_argument('--timeout', type=int, required=False,
help='Timeout for sosreport on each node.')
+ collect_grp.add_argument('--transport', default='auto', type=str,
+ help='Remote connection transport to use')
collect_grp.add_argument("--upload", action="store_true",
default=False,
help="Upload archive to a policy-default "
@@ -803,6 +806,8 @@ class SoSCollector(SoSComponent):
self.collect_md.add_field('cluster_type', self.cluster_type)
if self.cluster:
self.primary.cluster = self.cluster
+ if self.opts.transport == 'auto':
+ self.opts.transport = self.cluster.set_transport_type()
self.cluster.setup()
if self.cluster.cluster_ssh_key:
if not self.opts.ssh_key:
@@ -1041,6 +1046,7 @@ class SoSCollector(SoSComponent):
else:
client.disconnect()
except Exception:
+ # all exception logging is handled within SoSNode
pass
def intro(self):
diff --git a/sos/collector/clusters/__init__.py b/sos/collector/clusters/__init__.py
index 64ac2a44..cf1e7a0b 100644
--- a/sos/collector/clusters/__init__.py
+++ b/sos/collector/clusters/__init__.py
@@ -149,6 +149,16 @@ class Cluster():
"""
pass
+ def set_transport_type(self):
+ """The default connection type used by sos collect is to leverage the
+ local system's SSH installation using ControlPersist, however certain
+ cluster types may want to use something else.
+
+ Override this in a specific cluster profile to set the ``transport``
+ option according to what type of transport should be used.
+ """
+ return 'control_persist'
+
def set_primary_options(self, node):
"""If there is a need to set specific options in the sos command being
run on the cluster's primary nodes, override this method in the cluster
diff --git a/sos/collector/exceptions.py b/sos/collector/exceptions.py
index 1e44768b..2bb07e7b 100644
--- a/sos/collector/exceptions.py
+++ b/sos/collector/exceptions.py
@@ -94,6 +94,16 @@ class UnsupportedHostException(Exception):
super(UnsupportedHostException, self).__init__(message)
+class InvalidTransportException(Exception):
+ """Raised when a transport is requested but it does not exist or is
+ not supported locally"""
+
+ def __init__(self, transport=None):
+ message = ("Connection failed: unknown or unsupported transport %s"
+ % transport if transport else '')
+ super(InvalidTransportException, self).__init__(message)
+
+
__all__ = [
'AuthPermissionDeniedException',
'CommandTimeoutException',
@@ -104,5 +114,6 @@ __all__ = [
'InvalidPasswordException',
'PasswordRequestException',
'TimeoutPasswordAuthException',
- 'UnsupportedHostException'
+ 'UnsupportedHostException',
+ 'InvalidTransportException'
]
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index f79bd5ff..5c5c7201 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -22,7 +22,13 @@ from sos.collector.transports.control_persist import SSHControlPersist
from sos.collector.transports.local import LocalTransport
from sos.collector.exceptions import (CommandTimeoutException,
ConnectionException,
- UnsupportedHostException)
+ UnsupportedHostException,
+ InvalidTransportException)
+
+TRANSPORTS = {
+ 'local': LocalTransport,
+ 'control_persist': SSHControlPersist,
+}
class SosNode():
@@ -107,6 +113,14 @@ class SosNode():
if self.address in ['localhost', '127.0.0.1']:
self.local = True
return LocalTransport(self.address, commons)
+ elif self.opts.transport in TRANSPORTS.keys():
+ return TRANSPORTS[self.opts.transport](self.address, commons)
+ elif self.opts.transport != 'auto':
+ self.log_error(
+ "Connection failed: unknown or unsupported transport %s"
+ % self.opts.transport
+ )
+ raise InvalidTransportException(self.opts.transport)
return SSHControlPersist(self.address, commons)
def _fmt_msg(self, msg):