CasperSecurity

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

o

쑛hK5�@sddlZddlZddlmZddlmZddlmZmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZe�e�ZdZgd�Z d
diZ!Gdd�de	�Z"dd�Z#dd�Z$de"de%de&fdd�Z'Gdd�d�Z(dS)�N)�	signature)�
ModuleType)�Dict�List�
NamedTuple�Optional)�config�importer�	lifecycle�performance�
type_utils�util)�ALL_DISTROS)�ConfigMerger)�ReportEventStack)�FREQUENCIES)�Init�cc_)�cc_emit_upstartzcc_refresh_rmc_and_interface.py�cc_migrator�cc_rightscale_userdata�cc_ubuntu_advantage�
cc_ubuntu_proc@s2eZdZUeed<eed<eed<eeed<dS)�
ModuleDetails�module�name�	frequency�run_argsN)�__name__�
__module__�__qualname__r�__annotations__�strr�r#r#�:/usr/lib/python3/dist-packages/cloudinit/config/modules.pyr4s

rcCsX|�dd�}|���d�r|dt|�d�}|��}|sdS|�t�s*dt|f}|S)N�-�_z.pyr�z%s%s)�replace�lower�endswith�len�strip�
startswith�
MOD_PREFIX)r�
canon_namer#r#r$�form_module_name;s
r0cCs�t|d�rd|jvsd|jvrtd|�d|�d���|jdtvr2td|�d|�d|jd�d���t|d	�rBtd|�d|�d
���dS)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.)�hasattrr1�
ValueErrorr)�modrr#r#r$�validate_moduleGs$�

���
��r8�module_details�cfg�returncCs2t|jj�di��}|sdS|�|���sdSdS)N�activate_by_schema_keysTF)�	frozensetrr1�get�intersection�keys)r9r:�activate_by_schema_keys_keysr#r#r$�
_is_active]s�rBc@sxeZdZddefdd�Zedejfdd��Zde	e
fdd	�Zde	efd
d�Z
de	efd
d�Zddd�Zdd�ZdS)�ModulesN�initcCs2||_||_d|_|durtdddd�}||_dS)Nzmodule-reporterzmodule-descF)r�description�reporting_enabled)rD�	cfg_files�_cached_cfgr�reporter)�selfrDrGrIr#r#r$�__init__is�
zModules.__init__r;cCs<|jdurt|jj|jj|j|jjd�}|j|_t�|j�S)N)�paths�
datasource�additional_fns�base_cfg)	rHrrDrLrMrGr:�copy�deepcopy)rJ�mergerr#r#r$r:vs
�zModules.cfgcCsPg}||jvr	|S|j�|�}|s|S|D]�}|sqt|t�r)|�d|��i�qt|t�rbi}t|�dkr>|d��|d<t|�dkrL|d��|d<t|�dkrZ|dd�|d<|ra|�|�qt|t�r�i}d	}d
|vry|d
��|d<d}d|vr�|d��|d<d|vr�|dp�g|d<|r�|r�|�|�qt	d
|t
�|�f��|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.
        r7�r��freqr'N�argsFrTrz3Failed to read '%s' item in config, unknown type %s)r:r>�
isinstancer"�appendr,�listr+�dict�	TypeErrorr�obj_name)rJr�module_list�cfg_mods�item�contents�validr#r#r$�
_read_modules�sX

��

�

���zModules._read_modulesc	Cs*g}|D]�}|d}|�d�}|�d�pg}t|�}|sq|r2|tvr2tjd|�d|��dd�d}|tvrJtjd	|�d
t|�d�dd�t|}t�|d
t�	t
�gdg�\}}	|sr|tvrjt�
d|dd��nt�d||	�qt�|d�}
t|
|�|dur�|
jd}|�t|
|||d��q|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.
        r7rUrVzConfig 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)r>r0rr
�	deprecate�RENAMED_MODULESr	�find_modulerr\r�REMOVED_MODULES�LOG�info�warning�
import_moduler8r1rXr)rJ�raw_mods�mostly_mods�raw_mod�raw_namerUr�mod_name�mod_locs�looked_locsr7r#r#r$�_fixup_modules�sh
��	���
��

��zModules._fixup_modulesrqcCs�|j��}g}g}|D]�\}}}}z�t�d|||�|�|�d|��}	d|	|f}
t|	|
|jd�}||j||d�}|�Zt|j	�}
|
j
}t|�dkrYtj
ddd	�|�d
ti�tjddd
��}|j|	|j	||d�\}}Wd�n1swwY|r�|	�d|jd�d�|_nd|	|_Wd�n1s�wYWqty�}zt�td||�|�||f�WYd}~qd}~ww||fS)Nz(Running module %s (%s) with frequency %szconfig-zrunning %s with frequency %s)rrE�parent)rr:�cloudrV�z%Config modules with a `log` parameterz23.2rc�logrf�skip)�log_mode)rUz ran successfully and took z.3fz secondsz%s previously ranzRunning module %s (%s) failed)rD�cloudifyrl�debugrXrrIr:rrg�
parametersr+r
rh�updater�Timed�run�delta�message�	Exceptionr
�logexc)rJrq�cc�failures�	which_ranr7rrUrV�run_name�desc�myrep�	func_args�func_signature�func_params�timer�ran�_r�er#r#r$�_run_moduless`
�

��
�
����
�����zModules._run_modulescCs&|||d�}|g}|�|�}|�|�S)N)r7rVrU)rwr�)rJrtrVrU�	mod_to_berprqr#r#r$�
run_single9s�

zModules.run_singlecCs|�|�}|�|�}|jjj}g}g}|j�dg�}g}g}	|D]A}
|
\}}}
}|dur-q |jd}t|
|j�s>|�	|�q |rX|t
gkrX||vrX||vrS|�	|�q |�	|�|	�	|||
|g�q |rmt�dd�
|��|ryt�dd�
|�|�|r�t�dd�
|��|�|	�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_modulesNr2z?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, )rbrwrD�distrorr:r>r1rBrXrrlrm�joinr�)rJ�section_namerprq�distro_name�skipped�forced�
overridden�inapplicable_mods�active_modsr9r7r�_freq�_args�worked_distrosr#r#r$�run_sectionEsJ
	





��
zModules.run_section)NN)rrr rrK�propertyr�Configr:rrrbrrwr�r�r�r#r#r#r$rChs

;C
7rC))rP�logging�inspectr�typesr�typingrrrr�	cloudinitrr	r
rrr
�cloudinit.distrosr�cloudinit.helpersr�cloudinit.reporting.eventsr�cloudinit.settingsr�cloudinit.stagesr�	getLoggerrrlr.rkrirr0r8rZ�boolrBrCr#r#r#r$�<module>s* 
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY