관리-도구
편집 파일: collector.cpython-39.pyc
a �����)g}9����������������������@���s����d�dl�mZmZmZ�eZd�dlmZ�d�dlZd�dl m ��m��mZ �d�dlmZ�G�dd��de�ZG�dd��de�ZG�d d ��d e�ZG�dd��d�Zd#d d�Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd ��Z d$d!d"�Z!dS�)%�����)�absolute_import�division�print_function)�defaultdictN)�timeoutc�������������������@���s���e�Zd�ZdZdS�)�CycleFoundInFactDepsa ��Indicates there is a cycle in fact collector deps If collector-B requires collector-A, and collector-A requires collector-B, that is a cycle. In that case, there is no ordering that will satisfy B before A and A and before B. That will cause this error to be raised. N)�__name__� __module__�__qualname__�__doc__��r���r����H/usr/lib/python3.9/site-packages/ansible/module_utils/facts/collector.pyr���)���s���r���c�������������������@���s���e�Zd�ZdS�)�UnresolvedFactDepN�r���r ���r ���r���r���r���r ���r���4���s���r���c�������������������@���s���e�Zd�ZdS�)�CollectorNotFoundErrorNr���r���r���r���r ���r���8���s���r���c�������������������@���sZ���e�Zd�Ze��ZdZdZe��Zddd�Ze dd���Z dd��Zd d ��Zddd�Z dd d�ZdS�)�BaseFactCollector�GenericNc�����������������C���s0���|pg�|�_�||�_t|�jg�|�_|�j�|�j��dS�)zzBase class for things that collect facts. 'collectors' is an optional list of other FactCollectors for composing.N)� collectors� namespace�set�nameZfact_ids�update� _fact_ids)�selfr���r���r���r���r ����__init__C���s���� zBaseFactCollector.__init__c�����������������C���s���|��dd��|�jkr|�S�d�S�)N�system)�get� _platform)�cls� platform_infor���r���r ����platform_matchP���s����z BaseFactCollector.platform_matchc�����������������C���s���|�j�r|�j��|�S�|S��N)r���Z transform)r���Zkey_namer���r���r ����_transform_nameV���s����z!BaseFactCollector._transform_namec�����������������C���s.���t�|����D�]}|��|�}|�|�||<�q|S�)zKupdate a dicts keys to use new names as transformed by self._transform_name)�list�keysr"����pop)r���Z fact_dictZold_keyZnew_keyr���r���r ����_transform_dict_keys[���s���� z&BaseFactCollector._transform_dict_keysc�����������������C���s"���|�j�||d�}|�jr|��|�}|S�)N)�module�collected_facts)�collectr���r&����r���r'���r(���Z facts_dictr���r���r ����collect_with_namespacee���s���� z(BaseFactCollector.collect_with_namespacec�����������������C���s���i�}|S�)aB��do the fact collection 'collected_facts' is a object (a dict, likely) that holds all previously facts. This is intended to be used if a FactCollector needs to reference another fact (for ex, the system arch) and should not be modified (usually). Returns a dict of facts. r���r*���r���r���r ���r)���l���s���� zBaseFactCollector.collect)NN)NN)NN)r���r ���r ���r���r���r���r����required_factsr����classmethodr ���r"���r&���r+���r)���r���r���r���r ���r���<���s��� r���c�����������������C���sL��|pdg}|�pt���}�|pt���}|p(tt�}t��}t��}dg}|�|��t��}|D�]�} | } | dkrl|�|��qP| dkr�|�|���qP| �d�r�| dd��} | dkr�|�|��qP| dkr�|�|�|���qPd}nd}|r�|�|�| t�����|�| ��qP| |�v�rtd| d � t |���f���|�| ��|�| ��qP|�s:|�|���|�||���|S�) aE��return a set of FactCollector names based on gather_subset spec. gather_subset is a spec describing which facts to gather. valid_subsets is a frozenset of potential matches for gather_subset ('all', 'network') etc minimal_gather_subsets is a frozenset of matches to always use, even for gather_subset='!all' �all�min�!����NTFzHBad subset '%s' given to Ansible. gather_subset options allowed: all, %sz, )� frozensetr���r����extendr���� startswithr����add� TypeError�join�sorted�difference_update)� valid_subsets�minimal_gather_subset� gather_subset�aliases_mapr���Zadditional_subsetsZexclude_subsetsZgather_subset_with_minZexplicitly_addedZsubsetZ subset_idZexcluder���r���r ����get_collector_namesz���sP���� � r>���c�����������������C���s\���t���}t���}|D�]F}d�}|�D�]8}|�|�}|s0q|j}||vr|�|��|�|j��qq|S�r!���)r���r ���r���r5���)�all_collector_classes�compat_platformsZfound_collectorsZfound_collectors_namesZcompat_platformr ���Zall_collector_class�primary_namer���r���r ����find_collectors_for_platform����s���� rB���c�����������������C���s^���t�t�}t�t�}|�D�]@}|j}||��|��|jD�] }||��|��||��|��q2q||fS�r!���)r���r#���r���r����appendr���r5���)�collectors_for_platformZfact_id_to_collector_mapr=����collector_classrA���Zfact_idr���r���r ����build_fact_id_to_collector_map����s���� rF���c�����������������C���sJ���t���}g�}|�D�]6}|�|g��}|D�] }||vr"|�|��|�|��q"q|S�r!���)r���r���rC���r5���)�collector_names�all_fact_subsetsZseen_collector_classes�selected_collector_classes�collector_name�collector_classesrE���r���r���r ����select_collector_classes����s���� rL���c�����������������C���sL���t���}z||��}W�n�ty0���td|����Y�n0�|D�]}|�|j��q6|S�)NzFact collector "%s" not found)r����KeyErrorr���r���r,���)rJ���rH���r,���rK���rE���r���r���r ����_get_requires_by_collector_name���s����rN���c�����������������C���s:���t���}|�D�]*}t||�}|D�]}||�vr|�|��qq |S�)z�Find any collector names that have unresolved requires Returns a list of collector names that correspond to collector classes whose .requires_facts() are not in collector_names. )r���rN���r5���)rG���rH���� unresolvedrJ���r,���Z required_factr���r���r ����find_unresolved_requires��s���� rP���c�����������������C���sL���t���}g�}|�D�]"}||v�r&|�|��q|�|��q|rHtdd�|����|S�)Nzunresolved fact dep %s�,)r���r5���rC���r���r7���)Zunresolved_requiresrH���� new_namesZfailedrO���r���r���r ����resolve_requires��s����rS���c�����������������C���sH���t�t�}|�D�]6}t��}||�D�]}|jD�]}|�|��q(q|||<�q|S�r!���)r���r���r,���r5���)rG���rH����dep_maprJ���Zcollector_depsZ collectorZdepr���r���r ����build_dep_data+��s���� rU���c�����������������C���sn���g�}|�����}|rjd}t|����D�]6\}}|D�]}||v�r,�q q,d}||=�|�||f��q |std|���q|S�)NFTz?Unable to tsort deps, there was a cycle in the graph. sorted=%s)�copyr#����itemsrC���r���)rT���Zsorted_listZunsorted_mapZacyclicZnodeZedgesZedger���r���r ����tsort6��s����rX���c�����������������C���s@���|�����}|�����}t||�}|t��kr&q<t||�}|�|��q|S�r!���)rV���rP���r���rS���r���)rG���rH���rO���Z solutionsrR���r���r���r ����_solve_depsL��s���� rY���c�����������������C���s����|�pg�}�|pt���}|p dt���i}|p*tj}|t_|p:t���}tt�}|ddig}t|�|�}t |�\} }t�| � ���} t| ||||d�}t|| �}t || �} t| �}dd��|D��}t|| �}|S�)z6return a list of collector classes that match the argsr���r���)r:���r;���r<���r=���r���c�����������������S���s���g�|�]}|d���qS�)r���r���)�.0�xr���r���r ���� <listcomp>��������z8collector_classes_from_gather_subset.<locals>.<listcomp>)r2����platformr���r���ZDEFAULT_GATHER_TIMEOUTZGATHER_TIMEOUTr���r���rB���rF���r$���r>���rY���rU���rX���rL���)r?���r:���r;���r<���Zgather_timeoutr���r=���r@���rD���rH���Zall_valid_subsetsrG���Zcomplete_collector_namesrT���Zordered_depsZordered_collector_namesrI���r���r���r ����$collector_classes_from_gather_subset[��s2���� � �r_���)NNNNN)NNNNNN)"Z __future__r���r���r����typeZ __metaclass__�collectionsr���r^���Z"ansible.module_utils.compat.typingZmodule_utils�compat�typing�tZansible.module_utils.factsr���� Exceptionr���� ValueErrorr���rM���r���r���r>���rB���rF���rL���rN���rP���rS���rU���rX���rY���r_���r���r���r���r ����<module>���s>���>������ O�������