%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/modules.cpython-312.pyc

�

���f�3���ddlZddlZddlmZddlmZddlmZmZm	Z	m
Z
ddlmZm
Z
mZmZmZddlmZddlmZddlmZdd	lmZdd
lmZej6e�ZdZdd
gZddiZ Gd�de	�Z!d�Z"d�Z#de!de$de%fd�Z&Gd�d�Z'y)�N)�	signature)�
ModuleType)�Dict�List�
NamedTuple�Optional)�config�importer�	lifecycle�
type_utils�util)�ALL_DISTROS)�ConfigMerger)�ReportEventStack)�FREQUENCIES)�Init�cc_�cc_migrator�cc_rightscale_userdata�cc_ubuntu_advantage�
cc_ubuntu_proc�<�eZdZUeed<eed<eed<eeed<y)�
ModuleDetails�module�name�	frequency�run_argsN)�__name__�
__module__�__qualname__r�__annotations__�strr���:/usr/lib/python3/dist-packages/cloudinit/config/modules.pyrr+s����

�I��N��3�i�r$rc���|jdd�}|j�jd�r|dt|�dz
}|j	�}|sy|jt�s
t�|��}|S)N�-�_z.pyr�)�replace�lower�endswith�len�strip�
startswith�
MOD_PREFIX)r�
canon_names  r%�form_module_namer22sp�����c�3�'�J�����"�"�5�)���S��_�q�%8�:�
��!�!�#�J���� � ��,�)�:�6�
��r$c	�"�t|d�rd|jvsd|jvrtd|�d|�d���|jdtvr"td|�d|�d|jd�d���t|d	�rtd|�d|�d
���y)N�metar�distroszModule 'z
' with name 'z4' MUST have a 'meta' attribute of type 'MetaSchema'.z' has an invalid frequency �.�schemazX' has a JSON 'schema' attribute defined. Please define schema in cloud-init-schema,json.)�hasattrr4�
ValueErrorr)�modrs  r%�validate_moduler;>s����C�� ��c�h�h�&��C�H�H�$���s�e�=���/$�
$�
�	
��x�x���K�/���s�e�=���.I��x�x��$�%�Q�
(�
�	
��s�H����s�e�=���/G�
G�
�	
�r$�module_details�cfg�returnc��t|jjjdi��}|sy|j	|j��syy)N�activate_by_schema_keysTF)�	frozensetrr4�get�intersection�keys)r<r=�activate_by_schema_keys_keyss   r%�
_is_activerFTsL��#,����"�"�&�&�'@�"�E�$� �(��'�4�4�S�X�X�Z�@��r$c��eZdZddefd�Zedejfd��Zde	e
fd�Zde	efd�Z
de	efd	�Zdd
�Zd�Zy)
�ModulesN�initc�\�||_||_d|_|�tddd��}||_y)Nzmodule-reporterzmodule-descF)r�description�reporting_enabled)rI�	cfg_files�_cached_cfgr�reporter)�selfrIrMrOs    r%�__init__zModules.__init__`s:����	�"���48�����'�&�)�"'��H�
!��
r$r>c�$�|j�ft|jj|jj|j
|jj��}|j|_tj|j�S)N)�paths�
datasource�additional_fns�base_cfg)	rNrrIrSrTrMr=�copy�deepcopy)rP�mergers  r%r=zModules.cfgmsg�����#�!��i�i�o�o��9�9�/�/�#�~�~������	�F� &�z�z�D���}�}�T�-�-�.�.r$c	��g}||jvr|S|jj|�}|s|S|D�]T}|s�t|t�r"|j	d|j�i��9t|t�rui}t|�dk\r|dj�|d<t|�dk\r|dj�|d<t|�dk\r|dd|d<|s��|j	|���t|t�rei}d	}d
|vr|d
j�|d<d}d|vr|dj�|d<d|vr|dxsg|d<|s��|s�� |j	|���3td
|�dtj|�����|S)aURead the modules from the config file given the specified name.

        Returns a list of module definitions. E.g.,
        [
            {
                "mod": "bootcmd",
                "freq": "always",
                "args": "some_arg",
            }
        ]

        Note that in the default case, only "mod" will be set.
        r:�r��freqr)N�argsFrTrzFailed to read 'z' item in config, unknown type )r=rB�
isinstancer"�appendr.�listr-�dict�	TypeErrorr�obj_name)rPr�module_list�cfg_mods�item�contents�valids       r%�
_read_moduleszModules._read_modules{s���#%���t�x�x�����8�8�<�<��%������$	�D����$��$��"�"��t�z�z�|���
�D�4�)����t�9��>�&*�1�g�m�m�o�H�U�O��t�9��>�'+�A�w�}�}��H�V�$��t�9��>�'+�A�B�x�H�V�$���&�&�x�0��D�4�)������T�>�&*�6�l�&8�&8�&:�H�U�O� �E��$�&�'+�K�'8�'>�'>�'@�H�V�$��T�>�'+�F�|�'9�r�H�V�$����&�&�x�0���Z�0�0��6�8���C$	�J�r$c	���g}|D�]_}|d}|jd�}|jd�xsg}t|�}|s�=|r'|tvrtjd|�d|��d��d}|t
vr.tjd	|�d
t
|�d�d��t
|}t
j|d
tjt�gdg�\}}	|s;|tvrtjd|dd�ntjd||	���
t
j|d�}
t!|
|�|�|
j"d}|j%t'|
|||�����b|S)z�Convert list of returned from _read_modules() into new format.

        Invalid modules and arguments are ignored.
        Also ensures that the module has the required meta fields.
        r:r]r^zConfig specified module z has an unknown frequency z22.1��
deprecated�deprecated_versionNzModule has been renamed from z to z/. Update any references in /etc/cloud/cloud.cfgz24.1��handlez\Module `%s` has been removed from cloud-init. It may be removed from `/etc/cloud/cloud.cfg`.r)z,Could not find module named %s (searched %s)rr)rrrr)rBr2rr�	deprecate�RENAMED_MODULESr
�find_modulerrdr	�REMOVED_MODULES�LOG�info�warning�
import_moduler;r4r`r)rP�raw_mods�mostly_mods�raw_mod�raw_namer]r�mod_name�mod_locs�looked_locsr:s           r%�_fixup_moduleszModules._fixup_modules�s������9	�G��u�~�H��;�;�v�&�D��{�{�6�*�0�b�H�'��1�H�����K�/��#�#�2�8�*�=&�&*�V�-�(.�����?�*��#�#�7��z��*�8�4�5�6>�>�(.�
�+�8�4��$,�$8�$8��2�z�2�2�6�:�;�h�Z�%�!�H�k����.��H�H�I� ������K�K�F� �#��
��(�(��!��5�C��C��*��|��x�x��,�������!�"�%�	�
�e9	�t�r$rzc��|jj�}g}g}|D�]	\}}}}	tjd|||�|j	|�d|��}	d|	�d|��}
t|	|
|j��}||j||d�}|5t|j�}
|
j}t|�dk(r.tjdd	�
�|jdti�|j|	|j||��\}}|rd
|	z|_n
d|	z|_ddd���||fS#1swY�xYw#t"$r:}t%j&td||�|j	||f�Yd}~��[d}~wwxYw)Nz(Running module %s (%s) with frequency %szconfig-zrunning z with frequency )rrK�parent)rr=�cloudr^�z%Config modules with a `log` parameterz23.2rl�log)r]z%s ran successfullyz%s previously ranzRunning module %s (%s) failed)rI�cloudifyru�debugr`rrOr=rrp�
parametersr-rrq�update�run�message�	Exceptionr
�logexc)rPrz�cc�failures�	which_ranr:rr]r^�run_name�desc�myrep�	func_args�func_signature�func_params�ran�_r�es                  r%�_run_moduleszModules._run_modules�s���
�Y�Y�
�
�
!�����	�%0�)	+�!�C��t�T�(
+��	�	�>��c�4��
� � ��&�$�T�F�+��9A�4�H��(�!�t�D�M�M���!��8�8�� �	�	��G�%.�s�z�z�%:�N�"0�";�";�K��;�'�1�,�!�+�+�'N�/5��"�(�(�%���6� �f�f� �#�*�*�i�d�%��G�C���(=��(H��
�(;�h�(F��
�G��-)	+�T�8�$�$�)G�G��"�
+����C�!@�$��L�����q�	�*�*��
+�s1�A!D>�BD2�#D>�2D;	�7D>�>	F�/E<�<Fc�X�|||d�}|g}|j|�}|j|�S)N)r:r^r])r�r�)rPr}r^r]�	mod_to_beryrzs       r%�
run_singlezModules.run_single+s>�����
�	��;���)�)�(�3��� � ��-�-r$c��|j|�}|j|�}|jjj}g}g}|j
j
dg�}g}g}	|D]�}
|
\}}}
}|��
|jd}t|
|j
�s|j|��D|r5|tgk7r+||vr'||vr|j|��j|j|�|	j|||
|g���|r%tjddj|��|r&tjddj|�|�|r%tjddj|��|j|	�S)z�Runs all modules in the given section.

        section_name - One of the modules lists as defined in
          /etc/cloud/cloud.cfg. One of:
         - cloud_init_modules
         - cloud_config_modules
         - cloud_final_modules
        �unverified_modulesr5z?Skipping modules '%s' because no applicable config is provided.�,zSkipping modules '%s' because they are not verified on distro '%s'.  To run anyway, add them to 'unverified_modules' in config.z running unverified_modules: '%s'z, )rjr�rI�distrorr=rBr4rFr`rrurv�joinr�)rP�section_nameryrz�distro_name�skipped�forced�
overridden�inapplicable_mods�active_modsr<r:r�_freq�_args�worked_distross                r%�run_sectionzModules.run_section7s}���%�%�l�3���)�)�(�3���i�i�&�&�+�+�������X�X�\�\�"6��;�
�����)�	:�N�(6�%�S�$��u��{�� �X�X�i�0�N��n�d�h�h�7�!�(�(��.���.�[�M�"A��n�4��:�-����t�,� ��M�M�$�'�����T�5�%�8�9�'	:�*��H�H�����*�+�
�
��H�H�2�����!��
���H�H�7����6�9J�K�� � ��-�-r$)NN)rrr rrQ�propertyr	�Configr=rrrjrr�r�r�r�r#r$r%rHrH_sn��!�T�!��/�V�]�]�/��/�9�T�$�Z�9�vA�$�}�*=�A�F0%��]�(;�0%�d
.�8.r$rH)(rW�logging�inspectr�typesr�typingrrrr�	cloudinitr	r
rrr
�cloudinit.distrosr�cloudinit.helpersr�cloudinit.reporting.eventsr�cloudinit.settingsr�cloudinit.stagesr�	getLoggerrrur0rtrrrr2r;rb�boolrFrHr#r$r%�<module>r�s�������3�3�C�C�)�*�7�*�!��g����!���
������?���
�J��	�
�,�}��4��D��P.�P.r$

Zerion Mini Shell 1.0