diff options
-rw-r--r-- | sos/collector/__init__.py | 6 | ||||
-rw-r--r-- | sos/collector/clusters/__init__.py | 12 | ||||
-rw-r--r-- | sos/collector/clusters/ovirt.py | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 708a6e47..46f61d63 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -621,7 +621,6 @@ class SoSCollector(SoSComponent): try: self.master = SosNode('localhost', self.commons) except Exception as err: - print(err) self.log_debug("Unable to determine local installation: %s" % err) self._exit('Unable to determine local installation. Use the ' @@ -645,6 +644,11 @@ class SoSCollector(SoSComponent): if self.cluster: self.master.cluster = self.cluster self.cluster.setup() + if self.cluster.cluster_ssh_key: + if not self.opts.ssh_key: + self.log_debug("Updating SSH key to %s per cluster" + % self.cluster.cluster_ssh_key) + self.opts.ssh_key = self.cluster.cluster_ssh_key self.get_nodes() if self.opts.save_group: diff --git a/sos/collector/clusters/__init__.py b/sos/collector/clusters/__init__.py index 2f84845f..d66cb139 100644 --- a/sos/collector/clusters/__init__.py +++ b/sos/collector/clusters/__init__.py @@ -33,6 +33,7 @@ class Cluster(): ''' self.master = None + self.cluster_ssh_key = None self.tmpdir = commons['tmpdir'] self.opts = commons['opts'] self.cluster_type = [self.__class__.__name__] @@ -94,6 +95,17 @@ class Cluster(): return opt.value return False + def add_default_ssh_key(self, key): + """Some clusters generate and/or deploy well-known and consistent + SSH keys across environments. If this is the case, the cluster profile + may call this command so that subsequent node connections will use that + key rather than prompting the user for one or a password. + + Note this will only function if collector is being run locally on the + master node. + """ + self.cluster_ssh_key = key + def exec_master_cmd(self, cmd, need_root=False): '''Used to retrieve output from a (master) node in a cluster''' res = self.master.run_command(cmd, get_pty=True, need_root=need_root) diff --git a/sos/collector/clusters/ovirt.py b/sos/collector/clusters/ovirt.py index 16f99bca..bdce8cf7 100644 --- a/sos/collector/clusters/ovirt.py +++ b/sos/collector/clusters/ovirt.py @@ -66,7 +66,7 @@ class ovirt(Cluster): if not any([self.opts.ssh_key, self.opts.password, self.opts.password_per_node]): if self.master.file_exists(ENGINE_KEY): - self.opts.ssh_key = ENGINE_KEY + self.add_default_ssh_key(ENGINE_KEY) self.log_debug("Found engine SSH key. User command line" " does not specify a key or password, using" " engine key.") |