BYPASS SHELL BY ./RAZORGANZ
Server: nginx/1.20.1
System: Linux iZdzfnv9mwfppeZ 5.10.134-19.2.al8.x86_64 #1 SMP Wed Oct 29 22:47:09 CST 2025 x86_64
User: apache (48)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/cloudinit/config/__pycache__/modules.cpython-36.pyc
3

�q�h/�@s�ddlZddlmZddlmZddlmZmZmZm	Z	ddl
mZmZddl
m
Zddl
mZmZddlmZdd	lmZdd
lmZddlmZddlmZeje�Zd
ZGdd�de�Zdd�Z dd�Z!ee"e#d�dd�Z$Gdd�d�Z%dS)�N)�	signature)�
ModuleType)�Dict�List�
NamedTuple�Optional)�config�importer)�log)�
type_utils�util)�ALL_DISTROS)�ConfigMerger)�ReportEventStack)�FREQUENCIES)�InitZcc_c@s"eZdZUeeeee	dS)�
ModuleDetailsN)
�__name__�
__module__�__qualname__r�module�str�name�	frequencyr�run_args�rr�/usr/lib/python3.6/modules.pyr s
rcCsX|jdd�}|j�jd�r.|dt|�d�}|j�}|s>dS|jt�sTdt|f}|S)N�-�_z.pyr�z%s%s)�replace�lower�endswith�len�strip�
startswith�
MOD_PREFIX)rZ
canon_namerrr�form_module_name's
r'cCs�t|d�s d|jks d|jkr6td|�d|�d���|jdtkrftd|�d|�d|jd�d���t|d	�r�td|�d|�d
���dS)N�metar�distroszModule 'z
' with name 'z4' MUST have a 'meta' attribute of type 'MetaSchema'.z' has an invalid frequency �.ZschemazX' has a JSON 'schema' attribute defined. Please define schema in cloud-init-schema,json.)�hasattrr(�
ValueErrorr)�modrrrr�validate_module3s

 
r.)�module_details�cfg�returncCs2t|jjjdi��}|sdS|j|j��s.dSdS)NZactivate_by_schema_keysTF)�	frozensetrr(�get�intersection�keys)r/r0Zactivate_by_schema_keys_keysrrr�
_is_activeIsr6c@sxeZdZded�dd�Zeejd�dd��Ze	e
d�dd	�Ze	ed�d
d�Z
e	ed�d
d�Zddd�Zdd�ZdS)�ModulesN)�initcCs2||_||_d|_|dkr(tdddd�}||_dS)Nzmodule-reporterzmodule-descF)r�descriptionZreporting_enabled)r8�	cfg_files�_cached_cfgr�reporter)�selfr8r:r<rrr�__init__UszModules.__init__)r1cCs<|jdkr0t|jj|jj|j|jjd�}|j|_tj|j�S)N)�paths�
datasourceZadditional_fnsZbase_cfg)	r;rr8r?r@r:r0�copy�deepcopy)r=Zmergerrrrr0bs
zModules.cfgcCshg}||jkr|S|jj|�}|s&|S�x:|D�]0}|s:q.t|t�rX|jd|j�i�q.t|t�r�i}t|�dkr�|dj�|d<t|�dkr�|dj�|d<t|�dkr�|dd�|d<|r�|j|�q.t|t��rJi}d	}d
|k�r�|d
j�|d<d}d|k�r|dj�|d<d|k�r2|d�p,g|d<|�r`|�r`|j|�q.t	d
|t
j|�f��q.W|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��freqrN�argsFrTrz3Failed to read '%s' item in config, unknown type %s)r0r3�
isinstancer�appendr$�listr#�dict�	TypeErrorr�obj_name)r=rZmodule_listZcfg_mods�item�contentsZvalidrrr�
_read_modulespsL





zModules._read_modulescCs�g}x�|D]�}|d}|jd�}|jd�p,g}t|�}|s<q
|rZ|tkrZtjd||�d}tj|dtjt	�gdg�\}}	|s�tjd||	�q
tj
|d	�}
t|
|�|dkr�|
jd
}|j
t|
|||d��q
W|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-rErFz6Config specified module %s has an unknown frequency %sN��handlez,Could not find module named %s (searched %s)rr)rrrr)r3r'r�LOGZwarningr	�find_modulerrLr�
import_moduler.r(rHr)r=�raw_mods�mostly_modsZraw_modZraw_namerEr�mod_nameZmod_locsZlooked_locsr-rrr�_fixup_modules�sB



zModules._fixup_modules)rVcCsF|jj�}g}g}�x(|D�]\}}}}y�tjd|||�|j|�d|��}	d|	|f}
t|	|
|jd�}||j||d�}|�pt|j	�}
|
j
}t|�dkr�tj
ddd	�|jd
ti�|j|	|j	||d�\}}|r�d|	|_n
d
|	|_WdQRXWqtk
�r8}z$tjtd||�|j||f�WYdd}~XqXqW||fS)Nz(Running module %s (%s) with frequency %szconfig-zrunning %s with frequency %s)rr9�parent)rr0ZcloudrF�z%Config modules with a `log` parameterz23.2)Z
deprecatedZdeprecated_versionr
)rEz%s ran successfullyz%s previously ranzRunning module %s (%s) failed)r8ZcloudifyrR�debugrHrr<r0rrQZ
parametersr#rZ	deprecate�updateZrun�message�	ExceptionZlogexc)r=rVZccZfailuresZ	which_ranr-rrErFZrun_nameZdescZmyrepZ	func_argsZfunc_signatureZfunc_paramsZranZ_r�errr�_run_modules�sB



$zModules._run_modulescCs&|||d�}|g}|j|�}|j|�S)N)r-rFrE)rXr`)r=rWrFrEZ	mod_to_berUrVrrr�
run_single
s
zModules.run_singlecCs|j|�}|j|�}|jjj}g}g}|jjdg�}g}g}	x�|D]�}
|
\}}}
}|dkr\qB|jd}t|
|j�s~|j	|�qB|r�|t
gkr�||kr�||kr�|j	|�qB|j	|�|	j	|||
|g�qBW|r�tjddj
|��|r�tjddj
|�|�|�rtjddj
|��|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
        Zunverified_modulesNr)z?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, )rOrXr8Zdistrorr0r3r(r6rHr
rR�info�joinr`)r=Zsection_namerUrVZdistro_nameZskippedZforcedZ
overriddenZinapplicable_modsZactive_modsr/r-rZ_freqZ_argsZworked_distrosrrr�run_sectionsF	







zModules.run_section)NN)NN)rrrrr>�propertyrZConfigr0rrrOrrXr`rarerrrrr7Ts

;02
r7)&rA�inspectr�typesrZtypingrrrrZ	cloudinitrr	r
ZloggingrrZcloudinit.distrosr
Zcloudinit.helpersrZcloudinit.reporting.eventsrZcloudinit.settingsrZcloudinit.stagesrZ	getLoggerrrRr&rr'r.rJ�boolr6r7rrrr�<module>	s$