%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/sos/collector/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/sos/collector/__pycache__/__init__.cpython-312.pyc

�

i��d�����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
ddlmZddl
m
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZddlmZddlmZdd
lm Z dZ!Gd�de�Z"y)�N)�datetime)�ThreadPoolExecutor)�getpass)�Path)�quote)�fill)�
SoSCleaner)�SosNode)�
ClusterOption�str_to_bool)�SoSComponent)�bold)�__version__z/etc/sos/groups.dc���eZdZdZdZidd�dd�dd�dd�dd�d	d
�dd�dg�d
d�dd
�dg�dg�dg�dd�dd�dd�dd�idd�dd�dd�dg�dd�d d�d!d�d"d�d#d�d$d�d%d&�d'd�d(d�d)g�d*d�d+d�d,d��id-d�d.d�d/g�d0d�d1d�d2g�d3d�d4d�d5d�d6d�d7d�d8d�d9d�d:d�d;g�d<g�d=g��dd>d?d@d
dgdddddd
dd
dA��Z�fdB�ZdC�ZedD��Z	edE��Z
edF��ZdG�ZedH��Z
edI��ZdkdJ�ZdK�ZdL�ZdM�ZdN�ZdO�ZdP�ZdQ�ZdR�ZdS�ZdT�ZdU�ZdV�ZdW�ZdX�ZdY�ZdZ�Zd[�Z d\�Z!d]�Z"d^�Z#d_�Z$d`�Z%da�Z&db�Z'dc�Z(dd�Z)de�Z*df�Z+dg�Z,dh�Z-di�Z.dj�Z/�xZ0S)l�SoSCollectora�
    sos collect, or SoS Collector, is the formerly standalone sos-collector
    project, brought into sos natively in 4.0 and later.

    It is meant to collect sos reports from an arbitrary number of remote
    nodes, as well as the localhost, at the same time. These nodes may be
    either user defined, defined by some clustering software, or both.

    For cluster defined lists of nodes, cluster profiles exist that not only
    define how these node lists are generated but may also influence the
    sos report command run on nodes depending upon their role within the
    cluster.

    Nodes are connected to via a 'transport' which defaults to the use of
    OpenSSH's Control Persist feature. Other transport types are available, and
    may be specifically linked to use with a certain cluster profile (or, at
    minimum, a node within a certain cluster type even if that profile is not
    used).

    sos collect may be run from either a node within the cluster that is
    capable of enumerating/discovering the other cluster nodes, or may be run
    from a user's workstation and instructed to first connect to such a node
    via the --primary option. If run in the latter manner, users will likely
    want to use the --no-local option, as by default sos collect will also
    collect an sos report locally.

    Users should expect this command to result in a tarball containing one or
    more sos report archives on the system that sos collect was executed on.
    z8Collect an sos report from multiple nodes simultaneously�all_logsF�
alloptions�allow_system_changes�become_root�case_id�chroot�auto�clean�cluster_options�cluster_typeN�container_runtime�domains�disable_parsers�enable_plugins�encrypt_key��encrypt_pass�group�image�force_pull_imageT�jobs��journal_sizer�keywords�keyword_file�keep_binary_files�label�list_options�log_size�low_priority�map_file� /etc/sos/cleaner/default_mapping�primary�
namespaces�nodes�no_env_vars�no_local�
nopasswd_sudo�no_pkg_check�	no_update�only_plugins�password�password_per_node�plugopts�plugin_timeout�cmd_timeout�preset�
registry_user�registry_password�registry_authfile�
save_group�since�
skip_commands�
skip_files�skip_plugins��rootiX)�ssh_key�ssh_port�ssh_user�timeout�	transport�verify�	usernames�upload�
upload_url�upload_directory�upload_user�upload_pass�
upload_method�upload_no_ssl_verify�upload_protocolc	���tt|�|||�tjd�g|_g|_d|_d|_d|_	d|_
|jjjd�|jjj|_|jj!dd�|jj#d�t%|j&dd�t)j*�|_	t/t1t)j2t)j*�d�D�cgc]
}|d	d��c}��|_|j;�|j=�|_|j&j@s�	|jC�|jE�|jGdd
jId�tJjLD��z�|jGd|j>jO�z�|jQ�yycc}w#t6$r|j9d
�dg|_Y��wxYw#tR$r|jUdd�Yyt6$r�wxYw)N�?r�collectr�none�	node_list�sudo_pwr!r'zkCould not get a list of IP addresses from this hostnamne. This may indicate a DNS issue in your environmentz	127.0.0.1zExecuting %s� c3� K�|]}|���y�w�N�)�.0�ss  �8/usr/lib/python3/dist-packages/sos/collector/__init__.py�	<genexpr>z(SoSCollector.__init__.<locals>.<genexpr>�s����8M�q��8M���zFound cluster profiles: %s�Exiting on user cancel�)+�superr�__init__�os�umask�client_listr^r2�	retrieved�clusterr�manifest�
components�add_sectionr\�
collect_md�	add_field�add_list�setattr�opts�socket�gethostname�hostname�list�set�getaddrinfo�ip_addrs�	Exception�	log_error�_parse_options�
load_clusters�clustersr-�parse_node_strings�parse_cluster_options�	log_debug�join�sys�argv�keys�verify_cluster_options�KeyboardInterrupt�exit)�self�parser�parsed_args�cmdline_args�i�	__class__s     �rfrlzSoSCollector.__init__�s���
�l�D�*�6�;��M�
�������������������� ���	
�
�
� � �,�,�Y�7��-�-�2�2�:�:������!�!�.�&�9���� � ��-�	��	�	�9�b�)��*�*�,��
�	*� ��!'�!3�!3�F�4F�4F�4H�$�!O�&���!��Q��&�"��D�M�	
�����*�*�,��
��y�y�%�%�
��'�'�)��*�*�,����~����8M�C�H�H�8M�0M�M�N����;�!%���!3�!3�!5� 6�7��+�+�-�&��&���	*�
�N�N�D�
�)�M�D�M�	*��*%�
9��	�	�2�C�8��
��
�s7�4H2�<H-�H2�BI�-H2�2"I�I�J�7
Jc��ddl}|jj}i}|j|d�}|D]}|d|j�||d<�|S)zmLoads all cluster types supported by the local installation for
        future comparison and/or use
        rNr��)�sos.collector.clusters�	collectorr��
_load_modules�commons)r��sos�package�supported_clustersr�rqs      rfr�zSoSCollector.load_clusters�sc��	&��-�-�(�(�����%�%�g�z�:���	F�G�-7�W�Q�Z����-E��w�q�z�*�	F�!�!�c��g}|jD]C}tjj|�s�#|j	|j||���E|S)z'Helper to import cluster and host types)�__path__rm�path�isdir�extend�_find_modules_in_path)�clsr��submod�modulesr�s     rfr�zSoSCollector._load_modules�sP�����$�$�	H�D��w�w�}�}�T�"����s�8�8��v�F�G�	H��r�c�P�g}tjj|�r�ttj|��D]c}|jd�s�d|vr�tjj
|�\}}d|�d|��}|j|j|���e|S)aXGiven a path and a module name, find everything that can be imported
        and then import it

            path - the filesystem path of the package
            modulename - the name of the module in the package

        E.G. a path of 'clusters', and a modulename of 'ovirt' equates to
        importing sos.collector.clusters.ovirt
        z.py�__zsos.collector.�.)	rmr��exists�sorted�listdir�endswith�splitextr��_import_modules)r�r��
modulenamer��pyfile�fname�ext�modnames        rfr�z"SoSCollector._find_modules_in_path�s�����
�7�7�>�>�$�� ����D�!1�2�
=�����u�-���6�>���W�W�-�-�f�5�
��s�3=�u�E�����s�2�2�7�;�<�
=��r�c���|jd�d}t|t�t�|g�}t	j
|tj�}|D]}|ddvs�|j|��|S)z/Import and return all found classes in a moduler��r)�SosHost�Cluster)�split�
__import__�globals�locals�inspect�
getmembers�isclass�remove)r�r��mod_short_name�moduler��mods      rfr�zSoSCollector._import_modules�ss��!���s�+�A�.���G�W�Y���>�:J�K���$�$�V�W�_�_�=���	$�C��1�v�/�/����s�#�	$��r�c���|jjsyg}t|jjt�s&|jjg|j_|jjD]�}t	|�D��cgc]
\}}|dk(s�|��}}}|jt
|��d}d}|D]]}	|}|||}	tjtj|	��d|	vrd|	vr�<|j|	jd��|}�_|t
|�k7s��|j||dzd���||j_ycc}}w#tj$rY��wxYw)arParses the given --nodes option(s) to properly format the regex
        list that we use. We cannot blindly split on ',' chars since it is a
        valid regex character, so we need to scan along the given strings and
        check at each comma if we should use the preceeding string by itself
        or not, based on if there is a valid regex at that index.
        N�,r�[�]r�)ryr4�
isinstancer}�	enumerate�append�len�re�compile�escape�lstrip�error)
r�r4�noder��m�idxs�start�pos�idx�regs
          rfr�zSoSCollector.parse_node_strings�s@���y�y�������$�)�)�/�/�4�0�#�y�y���/�D�I�I�O��I�I�O�O�	+�D�"+�D�/�>�$�!�Q�Q�#�X�A�>�D�>��K�K��D�	�"��E��C��
��
��C��u�S�/�C��J�J�r�y�y��~�.��c�z�c��n� ��L�L����C��1��E�
��c�$�i�����T�#�a�%�&�\�*�%	+�& ��	�	���%?���x�x����s$�
E�E�7E �<"E � E6�5E6c	�4�|jdd�}|jdddd��|jddd	��|jd
ddd�
�|jddgd�d��|jddd��|jdddd��|jdtdd��|jdd d!dd"d#�$�|jd%dtd&�'�|jd(ddd)�
�|jd*d+dd,��|jd-d.dgd/�
�|jd0dd1��|jd2ddd3�
�|jd4tdd5��|jd6tdd7��|jd8dd9��|jd:gdd;d<�=�|jd>gdd?d@�=�|jdAddB��|jdCdD�}|jdEdFddGdH�$�|jdIdJ�K�|jdLdM�K�|jdNdOdPdQdR�S�|jdTddU��|jdVddW��|jdXdY�K�|jdZd[d\d]td^�_�|jd`dda��|jdbddc��|jdddde��|jdfdgdh�K�|jdidjdktdl�'�|jdmdnddo��|jdpdq�K�|jdrdsdtduddv�w�|jdxddy��|jdzdQd{��|jd|dd}��|jd~dd��|jd�d�td����|jd�ddd��
�|jd�ddd��
�|jd�ddd����|jd�d��K�|jd�tdd����|jd�dtd��'�|jd�ddd��
�|jd�dd���|jd�dd���|jd�dd���|jd�dd���|jd�dgd��d���|jd�ddd����|jd�dgd��d���|jd�d��}|jd�d�d�d�ddd����|jd�ddd�d��=�|jd�d�gdd����|jd�dgd�d����|jd�dgd�d����|jd�dd�d����|jd�ddd�d����|jd�d�d�dĬw�|jd�d�gddǬ��y)�NzReport Passthru Optionsz0These options control how report is run on nodesz-az--alloptions�
store_truezEnable all sos report options)�action�helpz
--all-logszCollect logs regardless of sizez--allow-system-changesFz;Allow sosreport to run commands that may alter system state)r��defaultr�z--chrootr!)r�always�neverz#chroot executed commands to SYSROOT)r��choicesr�z--container-runtimerzLDefault container runtime to use for collections. 'auto' for policy control.)r�r�z-ez--enable-pluginsr�z%Enable specific plugins for sosreportz--journal-sizerz!Limit the size of journals in MiB)�typer�r�z-kz--plugin-optionz
--plugoptsr=z&Plugin option as plugname.option=value)r��destr�z
--log-sizez7Limit the size of individual logs (not journals) in MiB)r�r�r�z--low-priorityzRun reports as low priorityz-nz--skip-pluginszSkip these pluginsz-oz--only-pluginszRun these plugins onlyz--namespaceszDlimit number of namespaces to collect output for - 0 means unlimitedz
--no-env-varsz%Do not collect env vars in sosreportsz--plugin-timeoutz#Set the global plugin timeout valuez
--cmd-timeoutz$Set the global command timeout valuez--sincezbEscapes archived files older than date. This will also affect --all-logs. Format: YYYYMMDD[HHMMSS]z--skip-commandsrFzdo not execute these commands)r�r�r�r�z--skip-filesrGzdo not collect these filesz--verifyz*perform pkg verification during collectionzCollector Optionsz.These options control how collect runs locallyz-bz--becomerzBecome root on the remote nodesz	--case-idzSpecify case number)r�z--cluster-typez!Specify a type of cluster profilez-cz--cluster-optionrr�zVSpecify a cluster options used by a profile and takes the form of cluster.option=value)r�r�r�z--groupz Use a predefined group JSON filez--save-groupz%Save a resulting node list to a groupz--imagez;Specify the container image to use for containerized hosts.z--force-pull-imagez--pullT)TFzDForce pull the container image even if it already exists on the host)r�r�r�r�z--registry-userzBUsername to authenticate to the registry with for pulling an imagez--registry-passwordzBPassword to authenticate to the registry with for pulling an imagez--registry-authfilezJUse this authfile to provide registry authentication when pulling an imagez-iz	--ssh-keyzSpecify an ssh keyz-jz--jobsr'z%Number of concurrent nodes to collectz-lz--list-optionsz#List options available for profilesz--labelzAssign a label to the archivesz	--primaryz	--managerz--controllerr2z.Specify a primary node for cluster enumeration)r�r�r�z--nopasswd-sudozUse passwordless sudo on nodesz--nodeszDProvide a comma delimited list of nodes, or a regex to match againstz--no-pkg-checkz^Do not run package checks. Use this with --cluster-type if there are rpm or apt issues on nodez
--no-localz&Do not collect a report from localhostz-pz
--ssh-portzSpecify SSH port for all nodes)r�r�z
--passwordz"Prompt for user password for nodesz--password-per-nodez!Prompt for password for each nodez--presetzSpecify a sos preset to use)r��requiredr�z
--ssh-userz!Specify an SSH user. Default rootz	--timeoutz#Timeout for sosreport on each node.)r�r�r�z--transportz"Remote connection transport to usez--uploadz+Upload archive to a policy-default locationz--upload-urlz&Upload the archive to specified serverz--upload-directoryz$Specify upload directory for archivez
--upload-userzUsername to authenticate withz
--upload-passzPassword to authenticate withz--upload-method)r�put�postz HTTP method to use for uploadingz--upload-no-ssl-verifyz'Disable SSL verification for upload url)r�r�r�z--upload-protocol)r�https�ftp�sftpz$Manually specify the upload protocolzCleaner/Masking Optionsz7These options control how data obfuscation is performedz--cleanz	--cleanerz--maskrzObfuscate sensitive information)r�r�r�r�z--keep-binary-filesr+zGKeep unprocessable binary files in the archive instead of removing themz	--domainsrz$Additional domain names to obfuscatez--disable-parsersrzCDisable specific parsers, so that those elements are not obfuscated)r�r�r�r�z
--keywordsr)zList of keywords to obfuscatez--keyword-filer*z&Provide a file a keywords to obfuscate)r�r�r�z--no-updater9z%Do not update the default cleaner mapz
--map-filer0r1z;Provide a previously generated mapping file for obfuscationz--usernamesrQzList of usernames to obfuscate)�add_argument_group�add_argument�intr�str)r�r��sos_grp�collect_grp�cleaner_grps     rf�add_parser_optionszSoSCollector.add_parser_optionss��
�+�+�%�>�
��	���T�>�,�"A�	�	C����\�,�"C�	�	E����5�l�%*�$8�	�	:�	���Z��%@�"G�	�	I�	���2�F�#L�	�	M�	���T�#5�h�"I�	�	K����-�C��"E�	�	G����T�#4�l�$,�:�"J�	�	L�	���\�1�3�#:�	�	;�	���-�l�%*�1N�	�	P����T�#3�H�"6�	�	8����T�#3�H�%'�":�	�	<�	���^�T�#C�	�	D�	���_�\�%*�"I�	�	K�	���/�c�4�"G�	�	I����_�3��"H�	�	J����Y��$>�	�	@�	���.��8�"1�"A�	�	C�	���^�R��".�">�	�	@�	���Z��"N�	�	P�
�/�/��<�
��	� � ��z�,�&3�&G�	!�	I�	� � ��3H� �I�� � �!1�&I�	!�	K�� � ��'9�&7��(>�	!�	@�
	� � ��D�&H�	!�	J�� � ���&M�	!�	O�� � ��(?�	!�	A�	� � �!5�x�)-�}�&1�'F�	!�	G�
	� � �!2�D�'K�	!�	L�	� � �!6��'K�	!�	L�	� � �!6��'M�	!�	N�	� � ��{�9M� �N�� � ��x���&M�	!�	O�� � ��'7��&K�	!�	M�� � ��&F�	!�	H�� � ��k�>�&/��'4�	!�	5�	� � �!2�<�&F�	!�	H�� � ��8�(L�	!�	N�	� � �!1�,�(?�	!�	A�	� � ��l�&N�	!�	P�� � ��|�#�&F�	!�	H�� � ��l�).�&J�	!�	L�	� � �!6�|�).�&I�	!�	K�	� � ��R�%�&C�	!�	E�� � ��&I�	!�	K�� � ��3��&K�	!�	M�� � ���S�&J�	!�	L�� � ��L�).�'1�	!�	2�	� � ���&N�	!�	P�� � �!5�t�&L�	!�	N�� � ��$�&E�	!�	G�� � ��$�&E�	!�	G�� � �!2�F�)@�&H�	!�	J�	� � �!9�5�(4�&O�	!�	#�	� � �!4�f�)I�&L�	!�	N�
�/�/�%�E�
��	� � ��K��&-�).�|�&G�	!�	I�	� � �!6��(4�;N�'I�	!�	J�	� � ��9�b�(0�&L�	!�	N�	� � �!4�X�)+�2C�(K�	!�	M�	� � ��h��&0�&E�	!�	G�	� � �!1�4�&4�&N�	!�	P�	� � ��|�).�[�&M�	!�	O�	� � ��J�)K�(?�	!�	A�	� � ��[�"�(0�&F�	!�	Hr�c	��|jd�|j|j�ddddd�}|jd�|D]2}|jdjd	t	|�||�d
���4y)NzSoS Collect Detailed HelpzInformation on cluster profileszSpecific profile informationz'Information on how connections are madezSpecific transport information)zcollect.clusterszcollect.clusters.$clusterzcollect.transportszcollect.transports.$transportz8The following help sections may be of further interest:
z{:>8}{:<40}{:<30}r`F)�newline)�	set_title�add_text�__doc__�formatr)r��section�	hsections�hsecs    rf�display_helpzSoSCollector.display_help�s������5�6�������%�!B�)G�"K�-M�	
�	�	���G�	
��	�D����#�*�*�3��T�
�I�d�O�L��
�
�	r�c�:�|jr|jj�|r|j|�	|j�|dk7r|j�|stj|�ytj|�y#t$rY�NwxYw)a�Used to terminate and ensure all cleanup is done, setting the exit
        code as specified if required.

        :param msg:     Log the provided message as an error
        :type msg:      ``str``

        :param error:   The exit code to use when terminating
        :type error:    ``int``

        :param force:   Use os.exit() to break out of nested threads if needed
        :type force:    ``bool``
        rjN)	rq�cleanupr��close_all_connectionsr�r�r�rm�_exit)r��msgr��forces    rfr�zSoSCollector.exit�s|���<�<��L�L� � �"���N�N�3��	��&�&�(��C�<�
�L�L�N���H�H�U�O��H�H�U�O���	��	�s�B�	B�Bc	��|j|jjdk7rdnd|jtt	|jj
�t	|j��|jd�|_y)zxFrom commandline options, defaults, etc... build a set of commons
        to hand to other collector mechanisms
        rJTF)�cmdlineopts�	need_sudo�tmpdir�hostlen�policyN)	ryrMr�maxr�r2r|rr��r�s rfr�zSoSCollector._parse_optionssZ��
 �9�9�!%���!3�!3�v�!=��5��k�k��3�t�y�y�0�0�1�3�t�}�}�3E�F��k�k�
��r�c	�P�g}t|jjt�s&|jjg|j_|jjr�|jjD]�}|j	d�d}|j	d�dj	d�d}	|j	d�dj	�d}|j
t|||j|����||j_y#t
$rd}Y�HwxYw)Nr�rr��=�True)	r�ryrr}r��
IndexErrorr�rr�)r�ry�optionrq�name�values      rfr�z"SoSCollector.parse_cluster_optionss������$�)�)�3�3�T�:�)-���)B�)B�(C�D�I�I�%��9�9�$�$��)�)�3�3�

�� �,�,�s�+�A�.���|�|�C�(��+�1�1�#�6�q�9��#�#�L�L��-�a�0�6�6�8��;�E�
���!�$��u����H��

�%)��	�	�!��"�#�"�E�#�s�7%D�D%�$D%c��|jjr�|jjD]w}d}|jD]d}|j|jD]F}|j|jk(s�|j
|k(s�-d}|j
||�|_�d�f�ys-|jdj
�d|j��d�yyy)z+Verify that requested cluster options existFTz!Unknown cluster option provided: r�r�N)	ryrr��optionsrrq�_validate_optionrr�)r��opt�match�clustrs     rfr�z#SoSCollector.verify_cluster_options2s����9�9�$�$��y�y�0�0�
"����!�]�]�"�E�"&�-�-��"6�">�">�"���8�8�v�{�{�2�s�{�{�e�7K�$(�E�(,�(=�(=�f�c�(J�C�I�!�	"�"�
"���	�	� �[�[�#�(�(�4�56�8��%r�c�n�|jtk(s]|j|jk(s8d}|j||j|j|jfzd�|jS|jj�}|dvr"d}|j||jzd�y|dvryy)	aCChecks to make sure that the option given on the CLI is valid.
        Valid in this sense means that the type of value given matches what a
        cluster profile expects (str for str, bool for bool, etc).

        For bool options, this will also convert the string equivalent to an
        actual boolean value
        z.Invalid option type for %s. Expected %s got %sr�)�true�on�yes�false�off�nozUInvalid value for %s. Accepted values are: 'true', 'false', 'on', 'off', 'yes', 'no'.)rrrTFN)�opt_type�boolr�rr�lower)r�r��clir�vals     rfrzSoSCollector._validate_optionAs������4�'��#�#�s�|�|�3�F���	�	�#����7�+;�+;�S�\�\� J�J�A�N��9�9���)�)�/�/�#�C��E�E�<���	�	�#����.�!�,��/�/�� r�c�:�|jj|�y)z.Log info messages to both console and log fileN)�soslog�info�r�rs  rf�log_infozSoSCollector.log_infoZs��������r�c�:�|jj|�y)z.Log warn messages to both console and log fileN)r$�warningr&s  rf�log_warnzSoSCollector.log_warn^s�������C� r�c�:�|jj|�y)z/Log error messages to both console and log fileN)r$r�r&s  rfr�zSoSCollector.log_errorbs�������#�r�c�~�tj�dd}d|�d|��}|jj|�y)z.Log debug message to both console and log filer��z[sos_collector:z] N)r��stackr$�debug)r�r�callers   rfr�zSoSCollector.log_debugfs3�������#�A�&��)/��5�������#�r�c	����tjjd�tjjd�t|j�D]H}tjjdj||j|j���Ji�|jD]�}|j|jD]�}|j�j�vr|�|j<�/|jD]F}|�|jjvs��|jjj|��H����tjjd�tjjdjdddd	d
��t��fd���D]�}�|}d
jdjd�t|j�D��|j|jjt|j �|j"�}tjj|���tjjd�y)z&Display options for available clustersz;
The following clusters are supported by this installation
z@Use the short name with --cluster-type or cluster options (-c)

z {:<15} {:30}
z/
The following cluster options are available:

z {:25} {:15} {:<10} {:10} {:<}
r�zOption Name�Type�Default�Descriptionc�"���|jSrb)rq)�x�_optss �rf�<lambda>z+SoSCollector.list_options.<locals>.<lambda>�s����a��0@�0@�r���keyz" {:25} {:15} {:<10} {:<10} {:<10}
z, c3� K�|]}|���y�wrbrc)rd�cs  rfrgz,SoSCollector.list_options.<locals>.<genexpr>�s����9��!�9�rhzh
Options take the form of cluster.name=value
E.G. "ovirt.no-database=True" or "pacemaker.offline=False"
N)r��stdout�writer�r�r��cluster_namerrr�rqr�r�r�__name__r�r�description)r�rq�_clusterrr�_opt�optlnr7s       @rfr-zSoSCollector.list_optionsls
���	�
�
���*�	+��
�
���,�	-��d�m�m�,�	F�G��J�J���.�5�5� '� $�
�
�g� 6� C� C�E�
F�	F�
���
�
�	B�H��}�}�X�.�6�6�
B���8�8�5�:�:�<�/�&)�E�#�(�(�O�!$���B�� ��c�h�h��(?�(?�?�!�#�(�(�O�3�3�:�:�5�A�B�	
B�	B�	�
�
���M�N��
�
���;�B�B������
�	��5�&@�A�	$�D���+�C�9�@�@��	�	�9�V�C�K�K�%8�9�9�������%�%��C�I�I�����!�E�
�J�J���U�#�	$�	�
�
���7�	8r�c�B�tj|j�y)z7Removes the temp directory and all collected sosreportsN)�shutil�rmtreerr	s rf�delete_tmp_dirzSoSCollector.delete_tmp_dir�s���
�
�d�k�k�"r�c���d}|jjr|d|jjzz
}|jjr|d|jjzz
}tjtj
�d�}	tjt_djd�td�D��}|�d|�d|��S#t$rY�6wxYw)z(Generates a name for the tarball archivez
sos-collectorz-%sz%Y-%m-%dr!c3�bK�|]'}tjtj����)y�wrb)�random�choice�string�	lowercase)rdr6s  rfrgz1SoSCollector._get_archive_name.<locals>.<genexpr>�s����I�1�v�}�}�V�%5�%5�6�I�s�-/��-)ryr,rr�strftime�nowrM�ascii_lowercaserN�	NameErrorr��range)r��nstr�dt�rands    rf�_get_archive_namezSoSCollector._get_archive_name�s������9�9�?�?��E�D�I�I�O�O�+�+�D��9�9����E�D�I�I�-�-�-�-�D�
�
�
�x�|�|�~�z�
:��	�%�5�5�F���w�w�I��a��I�I��!�2�t�,�,��	�	��	�s�C�	C �C c�t�|j�|_d}|jdz|jzdz|zS)zuReturns the path, including filename, of the tarball we build
        that contains the collected sosreports
        �gz�/z.tar.)rY�arc_namer)r��comprs  rf�_get_archive_pathzSoSCollector._get_archive_path�s;���.�.�0��
����{�{�S� �4�=�=�0�7�:�U�B�Br�c�`�d}d}|j�D]}|t||d��zdz}�|S)N�Pr!F)�replace_whitespace�
)�
splitlinesr)r�r�width�_fmt�lines     rf�_fmt_msgzSoSCollector._fmt_msg�sA�������N�N�$�	M�D��$�t�U�u�E�E��L�D�	M��r�c	��|jj}|tjj	tj�d|z�tjj	t|�g}d}|D]%}tjj|�s�#|}n|�td|z��|jd|z�t|d�5}tj|�}dD]=}||s�	|jd|�d||�d	��t|j|||��?|d
r?|jd|d
z�|jjj!|d
�ddd�y#1swYyxYw)a�
        Attempts to load the host group specified on the command line.
        Host groups are defined via JSON files, typically saved under
        /etc/sos/groups.d/, although users can specify a full filepath
        on the commandline to point to one existing anywhere on the system

        Host groups define a list of nodes and/or regexes and optionally the
        primary and cluster-type options.
        z.config/sos/groups.d/%sNzno group definition for %szLoading host group %s�r)r2rzSetting option 'z' to 'z' per host groupr4zAdding %s to node list)ryr#rmr�r�r�home�COLLECTOR_CONFIG_DIRr��OSErrorr��open�json�loadrxr4r�)r��grp�pathsr�r��hf�_groupr:s        rf�_load_group_configzSoSCollector._load_group_config�sO���i�i�o�o����G�G�L�L�����&?�#�&E�F��G�G�L�L�-�s�3�
�����	�D��w�w�~�~�d�#����	��=��6��<�=�=����.��6�7�
�%��
�		8���Y�Y�r�]�F�2�
9���#�;��N�N�&)�6�#�;�$8�9��D�I�I�s�F�3�K�8�	
9�
�g�����7�&��/�I�J��	�	���&�&�v�g��7�		8�		8�		8�s�
 E2�.A;E2�2E;c�z�|jj|jj|jjd|j
D�cgc]}|��c}d�}t
j�dk7rJtjjtj�d�}t
j|d��nt}tjj||d�}t|d�5}tj ||�ddd�t
j"|d	�|Scc}w#1swY�&xYw)
a
        Saves the results of this run of sos-collector to a host group file
        on the system so it can be used later on.

        The host group will save the options primary, cluster_type, and nodes
        as determined by sos-collector prior to execution of sosreports.
        r)rr2rr4z.config/sos/groups.dT)�exist_okr�wNi�)ryrDr2rqrr^rm�getuidr�r�rrk�makedirsrlrnro�dump�chmod)r��n�cfg�
group_pathr�rss      rf�write_host_groupzSoSCollector.write_host_group�s����I�I�(�(��y�y�(�(� �L�L�5�5�a�8�!%���0�A�a�0�	
���9�9�;�!�������d�i�i�k�3I�J�J��K�K�
�T�2�-�J������Z��V��5��
�%��
�	���I�I�c�2��	�
���������1�	�	�s�	D,
�5D1�1D:c��|jj|j�|jjsS|jj
s=|j
d�d}|jj|j|��	|jjs,|jj
rq|jjr[|jjsE|j
d�d|jjz}t|��|j_|jdr�|jjs�|jjs�|jjs\|jj
sF|j
d�d|jjz}t|��|j_n;|jjs%|jj|j_|jj$r�|jjdk(s|jjrd}|j#|d
�|j
d�d|jjz}t|��|j_d|jd<n"|j)d�d|j_|jj*r	|j-�	|jj1�|jjr"|j3�d|j_n�	d}d}d}|jj4s�t7j8�dk7r�|jjs�|jjsCd}t|�}|dk(r_|jj|�d}d|j_d}n.|jj|�d}d|j_t;d|j||��|_
|j<j?d|jj@�|j<jCd�|j<jDjC|jj@�|jjGtI|j<jD|jj@��|jjJr�|jjJd k(r|jLd!|_'nC|jL|jjJ|_'|jjJ|_%|j|jN_
n|jQ�|jN�+|jjDsd"}|j#|d
�nN|jN�B|jjDr,|j)d#�|jLd!|_'d |_%|j<j?d$|jJ�|jNr�|jN|j_'|jjRd%k(r)|jNjU�|j_)|jNjW�|jNjXrc|jjZsM|j
d&|jNjXz�|jNjX|j_-|j]�|jj^r?|jj^}	|ja�}|j)d'|�d(|���yy#t $r|j#d	d
�Y���wxYw#t.$r9}d|jj*�d|��}|j#|d
�Yd}~��2d}~wwxYw#t $r|j#dd
�Y��=wxYw#t.$r1}|j
d|z�|j#dd
�Yd}~��Od}~wwxYw#t.$r!}|jcd)|�d|���Yd}~yd}~wwxYw)*Nz)password not specified, assuming SSH keyszisos-collector ASSUMES that SSH keys are installed on all nodes unless the --password option is provided.
z&password specified, not using SSH keysz&Provide the SSH password for user %s: )�promptrz3non-root user specified, will request sudo passwordzQA non-root user has been provided. Provide sudo password for %s on remote nodes: z
Exiting on user cancel
rjrJzkCannot become root without obtaining root password. Do not use --batch if you need to become root remotely.r�z,non-root user asking to become root remotelyz<User %s will attempt to become root. Provide root password: FzSOption to become root but ssh user is root. Ignoring request to change user on nodezCould not load specified group �: �Exiting on user cancel
Tz�Local sos report generation forcibly skipped due to lack of root privileges.
Either use --nopasswd-sudo, run as root, or do not use --batch so that you will be prompted for a password
rz8Enter local sudo password to generate local sos report: r!�	localhost)�
local_sudo�
load_factsz*Unable to determine local installation: %szsUnable to determine local installation. Use the --no-local option if localhost should not be included.
Aborting...
r2r4r]�jbonzFCluster type could not be determined and no nodes provided
Aborting...zCluster type could not be determined, but --nodes is provided. Attempting to continue using JBON cluster type and the node listrrz"Updating SSH key to %s per clusterz
Wrote group 'z' to zCould not save group )2r�set_commonsr�ryr;r<r��ui_logr%rhr2�batchrMrr7r_r�r�r�
root_passwordr'r#rur��pre_work�connect_to_primaryr6rmryr
rurv�addressrtr4�set_node_manifest�getattrrr�rq�determine_clusterrO�set_transport_type�setup�cluster_ssh_keyrK�	get_nodesrDr�r�)r�r�err�
can_run_localr��skip_local_msg�gnamer�s        rf�prepzSoSCollector.prep�s�����������-��	�	�"�"��	�	�+�+��N�N�F�G�G�C��K�K���T�]�]�3�/�0�	9����#�#��	�	�(C�(C�(,�	�	�(9�(9� �I�I�O�O����G�H�?����+�+�,��%,�C�%8��	�	�"����k�*�4�9�9�3J�3J� �I�I�O�O��y�y�)�)�$�)�)�2M�2M��N�N�$3�4�?�!�Y�Y�/�/�0�C�)0�s�(;�D�I�I�%��9�9�2�2�,0�I�I�,>�,>��	�	�)��9�9� � ��9�9�%�%��/��9�9�?�?�6�C��I�I�c�1�%����M�N�1�37�9�9�3E�3E�F��*1��*=��	�	�'�,1����[�)��
�
�I�J�(-��	�	�%��9�9�?�?�
"��'�'�)�	7��K�K� � �"��9�9����#�#�%�!%�D�I�I�� 
9� $�
�!�
�0���	�	�*�*��	�	��q�0@�04�	�	�0G�0G��9�9�?�?� .��%,�S�\�
�%��+� �K�K�,�,�^�<�,1�M�15�D�I�I�.�)-�J����(�(��8�(-�
�-1��	�	�*�&�{�D�L�L�2<�2?� A���	
���!�!�)�T�\�\�-A�-A�B����#�#�G�,������)�)�$�,�,�*>�*>�?����&�&�w�t���/D�/D�/3�|�|�/C�/C�(E�	F��9�9�!�!��y�y�%�%��/�#�}�}�V�4���#�}�}�T�Y�Y�-C�-C�D���$(�I�I�$:�$:��!�#'�<�<�D�L�L� �
�"�"�$��<�<���	�	���#�C��I�I�c�1��
�\�\�
!�d�i�i�o�o��M�M�;�
<� �=�=��0�D�L� &�D�����!�!�.�$�2C�2C�D��<�<�#'�<�<�D�L�L� ��y�y�"�"�f�,�&*�l�l�&E�&E�&G��	�	�#��L�L��� ��|�|�+�+��y�y�(�(��N�N�#G�%)�\�\�%A�%A�$B�C�(,���(D�(D�D�I�I�%������9�9����I�I�(�(�E�
M��-�-�/���
�
�%��G�H�	 ��]!�	9��I�I�2�C�8�	9��.�
"��)�)�/�/�3�0���	�	�#�q�!�!��
"��!�	7��I�I�0�#�6�	7��D�
9����K�"� #�$��	�	�5�67�9�9��
9��f�
M�����s�K�L�L��
M�sn�F_�<`�
a� C.a(�6'b%�_>�=_>�	a�
.`>�>a�a%�$a%�(	b"�1&b�b"�%	c�.c
�
cc��|jjd�|js(|jjs|jdd�|jjd�|jjr�|jj��|jjr|jjsW|jjsA|jjd|jd|jjfz�t|j�D]/}|jjd|jd|fz��1|jjd�|jjs(	td�|jjd�yy#t $r|jd	d
�Yyt"$r%}|jt%|�d�Yd}~yd}~wwxYw)zuPrints a list of nodes to collect from, if available. If no nodes
        are discovered or provided, abort.
        r!zGNo nodes were detected, or nodes do not have sos installed.
Aborting...r�z1The following is a list of nodes to collect from:Nz	%-*srzC
Press ENTER to continue with these nodes, or press CTRL-C to quit
rirj)r�r%r^r2�	connectedr�r|�localryr6rq�strict_node_listr�r�r��inputr�r��repr)r�r��es   rf�
display_nodeszSoSCollector.display_nodes�s���	
��������~�~�d�l�l�&<�&<��I�I�0�12�
4�	
�����L�M��<�<�!�!�d�l�l�&;�&;�&G��\�\�'�'�D�I�I�,>�,>��|�|�4�4���� � ��T�\�\�)�-D�-1�\�\�-B�-B�-D�"D�E��4�>�>�*�	I�D��K�K���X����i�)@�$�(G�G�H�	I�	
��������y�y���
&��)�*���� � ��$�	��
%�
9��	�	�2�C�8��
&��	�	�$�q�'�1�%�%��
&�s�&F;�;H�H� H�Hc��d}i}|jjr"t|jj�|d<|jjrd|d<|jjrd|d<|jj
rd|d<|jjr+tt|jj��|d<|jjr"t|jj�|d<|jjr"t|jj�|d	<|jjd
k7r"t|jj�|d<|j�D]\}}|d|�d
|�d
�z
}�|j�}|jd|���d|jd<||jd<|jj!d|�y)z9Configures the sosreport command that is run on the nodeszsosreport --batch zcase-idr!rzall-logsrPzlog-size�sysrootrrzcompression-typez--r`zInitial sos cmd set to �sos_cmd�sos_options�initial_sos_cmdN)ryrrrrrPr.r�r�r�compression_type�items�rstripr�r�rurv)r�r�r��k�vs     rf�configure_sos_cmdzSoSCollector.configure_sos_cmd�s���&�����9�9���%*�4�9�9�+<�+<�%=�K�	�"��9�9���(*�K��%��9�9���&(�K�
�#��9�9���$&�K��!��9�9���&+�C��	�	�0B�0B�,C�&D�K�
�#��9�9���%*�4�9�9�+<�+<�%=�K�	�"��9�9���$)�$�)�)�*:�*:�$;�K��!��9�9�%�%��/�.3�D�I�I�4N�4N�.O�K�*�+��%�%�'�	%�D�A�q���A�3�a��s�!�}�$�G�	%��.�.�"�����0��	�:�;�"6����Y��&1����]�#����!�!�"3�W�=r�c�@�	t|jj|j�|_|jjd|jjz�y#t$r0}|jd|z�|jdd�Yd}~yd}~wwxYw)zgIf run with --primary, we will run cluster checks again that
        instead of the localhost.
        z,Connected to %s, determining cluster type...z%Failed to connect to primary node: %sz.Could not connect to primary node. Aborting...r�N)	r
ryr2r�r�r%r�r�r�)r�r�s  rfr�zSoSCollector.connect_to_primary�s���	K�"�4�9�9�#4�#4�d�l�l�C�D�L��K�K���K�#�y�y�0�0�1�
2���	K��N�N�B�Q�F�G��I�I�F��J�J��	K�s�A!A$�$	B�-&B�Bc	��t|jj��}|jj�D�]L}|j|�|j|_|j�s�7|jj}|jd|z�|D]�}t|j|j�s�$|jj}|jd|z�|j|_|j�s�p|jd|�d|�d��|}n||_
|j�|_|j|jd<|jjd|jz�yy)	a@This sets the cluster type and loads that cluster's cluster.

        If no cluster type is matched and no list of nodes is provided by
        the user, then we abort.

        If a list of nodes is given, this is not run, however the cluster
        can still be run if the user sets a --cluster-type manually
        z6Installation matches %s, checking for layered profilesz/Layered profile %s found. Checking installationz*Installation matches both layered profile z and base profile z), setting cluster type to layered profilerqzCluster type set to %sN)r}r��valuesr�r2�
check_enabledr�r@r��
issubclassrqrrr�r�r%)r��checksrq�cname�	remaining�rnames      rfr�zSoSCollector.determine_cluster�s^���d�m�m�*�*�,�-���}�}�+�+�-�	�G��M�M�'�"�"�l�l�G�O��$�$�&��)�)�2�2����� *�,1� 2�3�!'�
"�I�!�)�"5�"5�w�7H�7H�I� )� 3� 3� <� <�����(?�).�(/�0�-1�L�L�	�)�$�2�2�4� �N�N�9>�u�,F�G�'0�G�!�
"� '���$+�L�L�N��!�*.�,�,����Y�'���� � �,�t�/@�/@�@�B��5	r�c�~�|jr0|jj�}|jd|z�|SgS)z>Collects the list of nodes from the determined cluster clusterz
Node list: %s)rrq�
_get_nodesr�)r�r4s  rf�get_nodes_from_clusterz#SoSCollector.get_nodes_from_clusters8������L�L�+�+�-�E��N�N�?�U�2�3��L��	r�c�*�|j|jvr;|jjr%|jj	|j�|j
js;|jD],}||jvs�|jj	|��.|j�u|j
js_|jD]P}||jjk(s||jjk(s�6|jj	|��Rttd�|jD���|_|jd|jz�|jjd|j�y)zSReduce duplicate entries of the localhost and/or primary node
        if applicableNc3�&K�|]	}|s�|���y�wrbrc)rdr}s  rfrgz0SoSCollector.reduce_node_list.<locals>.<genexpr>s����!A��q�!�!A�s��zNode list reduced to %sr^)r|r^ryr6r�rqr�r�r2r}r~r�rurw)r�r�r}s   rf�reduce_node_listzSoSCollector.reduce_node_lists��
�M�M�T�^�^�+��	�	�0B�0B��N�N�!�!�$�-�-�0��|�|�,�,��]�]�
-������&��N�N�)�)�!�,�
-�
�<�<�#�D�L�L�,I�,I��^�^�
-������-�-�-��d�i�i�6G�6G�1G��N�N�)�)�!�,�
-��c�!A�T�^�^�!A�A�B������0�4�>�>�A�B���� � ��d�n�n�=r�c��|jjD]0}	tj|�}t	j
||�ry�2y#tj$r#}d}|j||||fz�Yd}~�ed}~wwxYw)z�Compares a discovered node name to a provided list of nodes from
        the user. If there is not a match, the node is removed from the listTz0Error comparing %s to provided node regex %s: %sNF)ryr4�fnmatch�	translater�rr�r�)r�r��regexr�rs     rf�compare_node_to_regexz"SoSCollector.compare_node_to_regexs����Y�Y�_�_�	9�E�
9��)�)�%�0���8�8�E�4�(��)�	9����8�8�
9�H�����s�d�E�3�%7�7�8�8��
9�s�+A�B�A<�<Bc���|js |jsd}|j|d�	|j�}|jj
r5|D]/�|j
��s�|jj���1n||_|jj
rn|jj
D]U�t�fd�d	D��r��|jvs�'|jd
�z�|jj���W|js�|jjd�d}|jD]5�|�jd�dk(s�|jj���7|jjs%|jj|j�|j!�	t#t%|jt"�
��}t%||j&d�|j&d<y#t$r�}|jd|z�|jd�|jj
|_|jD]2�t�fd�dD��s�|jj���4Yd}~��d}~wwxYw#t(t*f$rYywxYw)z3 Sets the list of nodes to collect sosreports from zaCould not determine a cluster type and no list of nodes or primary node was provided.
Aborting...r�zError parsing node list: %sz#Setting node list to --nodes optionc3�&�K�|]}|�v���
y�wrbrc�rdr�r�s  �rfrgz)SoSCollector.get_nodes.<locals>.<genexpr>=s�����J�Q�q�D�y�J���)�*�\�?�(�)r\Nc3�&�K�|]}|�v���
y�wrbrcr�s  �rfrgz)SoSCollector.get_nodes.<locals>.<genexpr>Cs�����6�Q�q�D�y�6�r�z*\?()/[]zForce adding %s to node listr�rr9r)r2rqr�r�ryr4r�r^r�r�r��anyr�r|r�r�r�r�rr��	TypeError�
ValueError)r�rr4r��host�	_node_maxr�s      @rfr�zSoSCollector.get_nodes(s4����|�|�D�L�L�F�C�
�I�I�c�1��	0��/�/�1�E��y�y���!�4�D��1�1�$�7����-�-�d�3�4�"'����9�9�?�?��	�	���
0���6�+�6�6���t�~�~�-��N�N�#A�D�#H�I��N�N�)�)�$�/�
0��|�|��=�=�&�&�s�+�A�.�D����
0���4�:�:�c�?�1�-�-��N�N�)�)�$�/�
0��<�<�0�0����%�%�d�m�m�4�����	��C����C�8�9�I�&)�)�T�\�\�)�5L�&M�D�L�L��#��9�	0��N�N�8�1�<�=��N�N�@�A�!�Y�Y�_�_�D�N����
0���J�*I�J�J��N�N�)�)�$�/�
0��		0��:�:�&�	��	�s7�<H�,%H�A
J2�	J/�#A#J*�J*�*J/�2K�Kc��	t|d|j|d��}|j|j�|jrv|j
j
|�|jjj|d�|jt|jj|d��y|j�y#t$rYywxYw)z�Try to connect to the node, and if we can add to the client list to
        run sosreport on

        Positional arguments
            node - a tuple specifying (address, password). If no password, set
                   to None
        rr�)r;N)r
r��set_clusterrqr�ror�rur4rtr�r��
disconnectr�)r�r��clients   rf�_connect_to_nodezSoSCollector._connect_to_nodeXs���	��T�!�W�d�l�l�T�!�W�E�F����t�|�|�,����� � �'�'��/����%�%�1�1�$�q�'�:��(�(�����1F�1F�15�a��*:�;��!�!�#���	��	�s�B:C�=C�	C�Cc���d}|jjdtz�|j||jz�}|jj|�d}|j
js(	t|�|jjd�yy#t$r|jdd�Yyt$r}|j|d�Yd}~yd}~wwxYw)	zmPrint the intro message and prompts for a case ID if one is not
        provided on the command line
        ahThis utility is used to collect sos reports from multiple nodes simultaneously. Remote connections are made and/or maintained to those nodes via well-known transport protocols such as SSH.

An archive of sos report tarballs collected from the nodes will be generated in %s and may be provided to an appropriate support representative.

The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No configuration changes will be made to the system running this utility or remote systems that it connects to.
z
sos-collector (version %s)
z,
Press ENTER to continue, or CTRL-C to quit
r!rirjr�N)r�r%rrhrryr�r�r�r�r�)r��
disclaimer�	intro_msgr�r�s     rf�introzSoSCollector.introns����
�	
�����9�K�G�H��M�M�*�t�{�{�":�;�	�������#�A���y�y���
 ��f�
���� � ��$���%�
9��	�	�2�C�8��
 ��	�	�!�Q����
 �s�7&B�C �<C �C�C c��|jjr |j�|j�|j�|j	�|j�|j
�|j�|_|j|j��|jj�|_|jjdd�|j�|j�y)N)r�sos_logsi�)ryr-r�r�r�r�r�rY�archive_name�
setup_archive�archive�get_archive_path�archive_pathrzr\r	s rf�executezSoSCollector.execute�s����9�9�!�!������I�I�K��
�
����� ��	�	������ �2�2�4������� 1� 1��2� �L�L�9�9�;��������j�%�0������	�	�r�c�4
�t|jj|jjg�}|jjr_|jt|j��s|jjs%|jj|j�|jjd�|jD�cgc]}||vs�|df��
}}|jjrLg}|D]C}d|jj�d|d�d�}t!|�}|j|d|f��E|}	t#|jj$�}|j'|j(|d��|j+d	�
�|jj,r7|jdjdk(r|jj/d�t1|j�|_|j2dk(r|j5dd�n=|j2dk(r.|jdjdk(r|j5d
d�|jjd|j2�d|jj$�d��t#|jj$�}	|	j'|j6|jd��|	j+d	�
�t#|jj$�}|j'|j8|jd��|j+d	�
�t?|jd�rR|jjd�|jjA�}|r|jjC|�d}|jE||jF|j2fz�|jI�|jFdkDr|jK�}nd}|j5|d�|jjLrS|jNjQ�r8	|jNjS�|jjd�yyycc}w#t:$r|j5ddd	��Y��gt<$r$}
d|
z}|j5|dd	��Yd}
~
���d}
~
wwxYw#t<$r(}
|jjUd|
z�Yd}
~
yd}
~
wwxYw)zX For each node, start a collection thread and then tar all
        collected sosreports z
Connecting to nodes...NzPlease enter the password for �@rr�r�)�	chunksizeT)�waitr�zNo nodes connected. Aborting...z�Collection would only gather from localhost due to failure to either enumerate or connect to cluster nodes. Assuming single collection from localhost is not desired.
Aborting...z)
Beginning collection of sosreports from z  nodes, collecting a maximum of z concurrently
r�rj)rzCould not connect to nodes: %s�
run_extra_cmdz/Collecting additional data from primary node...z*
Successfully captured %s of %s sosreportsz3No sosreports were collected, nothing to archive...zUploaded archive successfullyzUpload attempt failed: %s)+r~r2r�r|r��intersectionr^rqr�ror�r�r%ryr<rMrrr&�mapr��shutdownr6�popr��
report_numr��_finalize_sos_cmd�_collectr�r��hasattr�_run_extra_cmd�collect_extra_cmdr'rpr��create_cluster_archiverRr�get_upload_url�upload_archiver�)
r��filtersr}r4�_nodesr�r�node_pwd�pool�npoolr��filesr]s
             rfr\zSoSCollector.collect�s���t�|�|�+�+�T�\�\�-B�-B�C�D���<�<�!�!��%�%�c�$�.�.�&9�:��\�\�2�2����#�#�D�L�L�1������3�4�$(�N�N�G�q�a�w�6F�!�T��G��G��9�9�&�&��F��
3���)�)�,�,�d�1�g�7��"�3�<���
�
�t�A�w��1�2�	
3�
�E�'	*�%�d�i�i�n�n�5�D��H�H�T�*�*�E�Q�H�?��M�M�t�M�$��	�	�"�"��$�$�Q�'�/�/�;�>�� � �$�$�Q�'�!�$�"2�"2�3�D�O����!�#��	�	�;�Q�?����A�%��#�#�A�&�.�.�+�=��I�I�&�()��
�K�K���!%��������A�
B�
'�t�y�y�~�~�6�E��I�I�d�,�,�d�.>�.>�!�I�L��N�N��N�%�%�d�i�i�n�n�5�D��H�H�T�]�]�D�$4�$4��H�B��M�M�t�M�$��4�<�<��1��K�K���N�O��L�L�/�/�1�E�����.�.�u�5�;���
�
�c�T�^�^�T�_�_�=�=�>��"�"�$��>�>�A���2�2�4�H�G�C��I�I�c�1���9�9������ :� :� <�
E����*�*�8�4���� � �!@�A�!=���EH��\!�	C��I�I�0�#�T�I�B��	*�2�S�8�C��I�I�c�1�D�I�)�)��	*��,�
E����!�!�"=��"C�D�D��
E�sC�	R�R�	HR�6S&�S#�7S#�?S�S#�&	T�/T�Tc��	|j�y#t$r+}|jd|j�d|���Yd}~yd}~wwxYw)z�Calls finalize_sos_cmd() on each node so that we have the final
        command before we thread out the actual execution of sos
        z#Could not finalize sos command for r�N)�finalize_sos_cmdr�r�r��r�r�r�s   rfr�zSoSCollector._finalize_sos_cmd�sB��	4��#�#�%���	4��N�N�$�n�n�c�3�
4�
4��	4�s��	A�!A�Ac�$�	|js|j�n&|jjs|j�|jr|xjdz
c_yy#t
$r}|j
d|z�Yd}~yd}~wwxYw)zRuns sosreport on each noder�zError running sosreport: %sN)r��	sosreportryr6rpr�r�r�s   rfr�zSoSCollector._collectsw��		@��<�<�� � �"��y�y�)�)��$�$�&�������!�#�� ���	@��N�N�8�3�>�?�?��	@�s�A$A(�(	B�1B
�
Bc��|jD]=}|js�|jd|jz�|j	��?y)zClose all sessions for nodeszClosing connection to %sN)ror�r�r�r�)r�r�s  rfr�z"SoSCollector.close_all_connectionssB���&�&�	$�F�������9�F�N�N�J�K��!�!�#�	$r�c��
�d}g}|jD]$}|jD]}|j|���&d}|jjr�|j
|j|j|j|jd�}	|jjd�td|��}|j|j�|j�\}}d}	|j!d�|D]�}|j#d	�d
}	|rj%|	�}	t&j(j+|j|�}
|j,j/|
|	��|s�tj1|�}|s��t&j(j+d|j#d	�d
�}
|
d
z
}
|j,j3||
���|j,j/|j4t&j(j+dd���|j,j/|j6t&j(j+dd���|j�/|j,j9|jj:�|r�t&j(j+|j|j,j<�}j?t&j(j+|dd�d��|j?t&j(j+|dd�d��|j?t&j(j+|dd�d��|j,jA|jj:�}
t&j(j+|jt&j(jC|
��}|r!j%|jEdd��}t'jF|
|�|rzj%t&j(j+|jd|jHz��}t'jF||�|jjd|z�|jJjd|z�|jjd�|jjd|z�|S#t$r)}|jjd|z�Yd}~��=d}~wwxYw#t$r.}d|�d|jL��}|jO|d�Yd}~yd}~wwxYw)zeCalls for creation of tar archive then cleans up the temporary
        files created by sos-collectorNF)rr�sys_tmprrrr!T)�in_place�hook_commonsz&ERROR: unable to obfuscate reports: %sz!Creating archive of sosreports...r\���)r��	checksumsz.sha256r�zsos.logzui.log)�
short_name�sos_reportsz
manifest.jsonz.tarz-obfuscated.tarz%s_private_mapz4A mapping of obfuscated elements is available at
	%szArchive created as %szP
The following archive has been created. Please provide it to your support team.z	%s
zCould not finalize archive: z.

Data may still be available uncompressed at r�)(ro�	file_listr�ryrrrrrrr�r%r	�set_target_pathr�r�r�r'r��obfuscate_stringrmr�r�r��add_file�get_new_checksum�
add_string�sos_log_file�sos_ui_log_file�add_final_manifest_datar��_name�obfuscate_file�finalize�basename�replace�renamer�r$r�r�)r�r0�	arc_pathsr�r��do_cleanr�cleanerr�r�r�checksum�_dirr]�
final_name�map_namers                 rfr�z#SoSCollector.create_cluster_archivesy�����	��$�$�	(�D����
(��� � ��'�
(�	(����9�9�?�?��+�+��+�+��<�<��9�9� �M�M��L�	
)���� � ��$�$�d�2>�@���'�'����4�&-�o�o�&7�#��)���
B	��M�M�=�>�"�
@���{�{�3�'��+���"�3�3�D�9�D��w�w�|�|�D�K�K��7�����%�%�d��%�6��&�7�7��>�H��!�w�w�|�|�K����S�9I�"�9M�N���	�)�����/�/��$�?�
@�
�L�L�!�!�$�"3�"3�')�w�w�|�|�J�	�'J�
"�
L��L�L�!�!�$�"6�"6�')�w�w�|�|�J��'I�
"�
K��}�}�(����4�4��I�I�.�.����w�w�|�|�D�K�K����1C�1C�D���&�&��G�G�L�L��z�9�=�(�'���&�&��G�G�L�L��z�8�<�'�'���&�&��G�G�L�L��}�o�F�.�'��
�|�|�,�,�T�Y�Y�-G�-G�H�H������d�l�l�B�G�G�4D�4D�X�4N�O�J��$�5�5��&�&�v�/@�A��
�
�I�I�h�
�+��#�3�3��G�G�L�L����!1�D�4E�4E�!E�G����	�	�(�H�-���� � �"6�8@�"A�B�
�K�K���4�z�A�B��K�K���G�
H��K�K���X�
�2�3����E�
)����!�!�"J�$'�#(�)�)��
)��F�	�58�$�:K�:K�M�C��I�I�c�1����	�s?�AS3�$BT(�+T(�?M3T(�3	T%�<T � T%�(	U�1$U�U)NrF)1r@�
__module__�__qualname__r��desc�arg_defaultsrlr��classmethodr�r�r�r�r�r�r�r�r�r�rr'r*r�r�r-rHrYr_rhrur�r�r�r�r�r�r�r�r�r�r�r�r�r\r�r�r�r��
__classcell__)r�s@rfrr&s:����<F�D�C��E�C��e�C�	��C�	�u�	C�
	�5�C�	�&�
C�	��C�	�2�C�	��C�	�V�C�	�2�C�	�2�C�	�"�C�	�r�C�	��C� 	��!C�"	��#C�$	�D�%C�&	��'C�(	��)C�*	�B�+C�,	��-C�.	�U�/C�0	��1C�2	��3C�4	�A�5C�6	��7C�8	�6�9C�:	�2�;C�<	�d�=C�>	��?C�@	�u�AC�B	�E�CC�D	��EC�F	��GC�H	�U�IC�J	��KC�L	�E�MC�N	�U�OC�P	�B�QC�R	�$�SC�T	�t�UC�V	�"�WC�X	��YC�Z	�T�[C�\	�T�]C�^	�b�_C�`	��aC�b	��cC�d	�b�eC�f	��gC�h��������� ���� %�!�EC�L�J2�h
"���������,���� �B�DH��DH�L����&�<

�)�*
8�!�2�!���*8�X#�-�"C��$8�L�4RM�h&�>>�>
K�$�L�>�&�.�`�, �B�&VE�p4�@�$�_r�r)#r�r�rormrKr�rMrzrFr�r�concurrent.futuresrr�pathlibr�pipesr�textwrapr�sos.cleanerr	�sos.collector.sosnoder
�sos.optionsrr�
sos.componentr
�
sos.utilitiesrr�rrlrrcr�rf�<module>r.s]�����	�
�	�
�
�
�
��1�����"�)�2�&���*��Q�<�Qr�

Zerion Mini Shell 1.0