aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-05-12 13:26:45 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-06-02 13:05:05 -0400
commit3cbbd7df6f0700609eeef3210d7388298b9e0c21 (patch)
tree95f886e65cd9105bef0c7a69c0d9da08b7f67cd4
parent52e6b2ae17e128f17a84ee83b7718c2901bcd5bd (diff)
downloadsos-3cbbd7df6f0700609eeef3210d7388298b9e0c21.tar.gz
[sosnode] Allow clusters to set options only for master nodes
Adds a method the `Cluster` that allows a profile to set sos options specifically for master nodes. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/collector/clusters/__init__.py21
-rw-r--r--sos/collector/sosnode.py6
2 files changed, 27 insertions, 0 deletions
diff --git a/sos/collector/clusters/__init__.py b/sos/collector/clusters/__init__.py
index 5c002bae..bfa3aad3 100644
--- a/sos/collector/clusters/__init__.py
+++ b/sos/collector/clusters/__init__.py
@@ -137,6 +137,27 @@ class Cluster():
"""
self.cluster_ssh_key = key
+ def set_master_options(self, node):
+ """If there is a need to set specific options in the sos command being
+ run on the cluster's master nodes, override this method in the cluster
+ profile and do that here.
+
+ :param node: The master node
+ :type node: ``SoSNode``
+ """
+ pass
+
+ def check_node_is_master(self, node):
+ """In the event there are multiple masters, or if the collect command
+ is being run from a system that is technically capable of enumerating
+ nodes but the cluster profiles needs to specify master-specific options
+ for other nodes, override this method in the cluster profile
+
+ :param node: The node for the cluster to check
+ :type node: ``SoSNode``
+ """
+ return node.address == self.master.address
+
def exec_master_cmd(self, cmd, need_root=False):
"""Used to retrieve command output from a (master) node in a cluster
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index d1c11824..62666635 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -647,6 +647,10 @@ class SosNode():
self.cluster.sos_plugin_options[opt])
self.opts.plugin_options.append(option)
+ # set master-only options
+ if self.cluster.check_node_is_master(self):
+ self.cluster.set_master_options(self)
+
def finalize_sos_cmd(self):
"""Use host facts and compare to the cluster type to modify the sos
command if needed"""
@@ -707,6 +711,8 @@ class SosNode():
os.path.join(self.host.sos_bin_path, self.sos_bin)
)
+ self.update_cmd_from_cluster()
+
if self.opts.only_plugins:
plugs = [o for o in self.opts.only_plugins
if self._plugin_exists(o)]