sos.collector.clusters
— Cluster Interface¶
-
class
sos.collector.clusters.
Cluster
(commons)[source] Bases:
object
This is the class that cluster profiles should subclass in order to add support for different clustering technologies and environments to sos-collector.
A profile should at minimum define a package that indicates the node is configured for the type of cluster the profile is intended to serve and then additionally be able to return a list of enumerated nodes via the
get_nodes()
methodParameters: commons (
dict
) – The commons dict containing system information. The same as what is handed toPlugin()
Variables: - option_list (
list
oftuples
) – Options supported by the profile, and set by the –cluster-option cmdline arg - packages (
tuple
) – What package(s) should this profile enable on - sos_plugins (
list
) – Which plugins to forcibly enable for node reports - sos_plugin_options (
dict
) – Plugin options to forcibly set for nodes - sos_preset (
str
) – A SoSReport preset to forcibly enable on nodes - cluster_name (
str
) – The name of the cluster type
-
add_default_ssh_key
(key)[source] 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 primary node.
-
check_enabled
()[source] This may be overridden by clusters
This is called by sos collect on each cluster type that exists, and is meant to return True when the cluster type matches a criteria that indicates that is the cluster type is in use.
Only the first cluster type to determine a match is run
Returns: True
if the cluster profile should be used, orFalse
Return type: bool
-
check_node_is_primary
(node)[source] In the event there are multiple primaries, 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 primary-specific options for other nodes, override this method in the cluster profile
Parameters: node ( SoSNode
) – The node for the cluster to check
-
exec_primary_cmd
(cmd, need_root=False)[source] Used to retrieve command output from a (primary) node in a cluster
Parameters: - cmd (
str
) – The command to run - need_root (
bool
) – Does the command require root privileges
Returns: The output and status of cmd
Return type: dict
- cmd (
-
format_node_list
()[source] Format the returned list of nodes from a cluster into a known format. This being a list that contains no duplicates
Returns: A list of nodes, without extraneous entries from cmd output Return type: list
-
get_node_label
(node)[source] Used by
SosNode()
to retrieve the appropriate label from the cluster as set byset_node_label()
in the cluster profile.Parameters: node ( str
) – The name of the node to get a label forReturns: The label to use for the node’s report Return type: str
-
get_nodes
()[source] This MUST be overridden by a cluster profile subclassing this class
A cluster should use this method to return a list or string that contains all the nodes that a report should be collected from
Returns: A list of node FQDNs or IP addresses Return type: list
orNone
-
get_option
(option)[source] This is used to by clusters to check if a cluster option was supplied to sos collect
Parameters: option ( str
) – The name of the option to fetchReturns: The value of the requested option if it exists, or False
-
log_debug
(msg)[source] Used to print debug messages
-
log_error
(msg)[source] Used to print error messages
-
log_info
(msg)[source] Used to print info messages
-
log_warn
(msg)[source] Used to print warning messages
-
classmethod
name
()[source] Returns the cluster’s name as a string.
-
set_node_label
(node)[source] This may be overridden by clusters profiles subclassing this class
If there is a distinction between primaries and nodes, or types of nodes, then this can be used to label the sosreport archive differently
-
set_node_options
(node)[source] If there is a need to set specific options on ONLY the non-primary nodes in a collection, override this method in the cluster profile and do that here.
Parameters: node ( SoSNode
) – The non-primary node
-
set_primary_options
(node)[source] 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 profile and do that here.
Parameters: node ( SoSNode
) – The primary node
-
setup
()[source] This MAY be used by a cluster to do prep work in case there are extra commands to be run even if a node list is given by the user, and thus get_nodes() would not be called
- option_list (