o
    x[h†  ã                
   @   s¨   U d Z ddlZddlmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ e e¡Zdd	d
œZdg d¢edgdœZe
ed< dd„ Zdededededdf
dd„ZdS )z"Resolv Conf: configure resolv.confé    N)Ú	templaterÚutil)ÚCloud)ÚConfig)Ú
MetaSchema)ÚPER_INSTANCEzresolv.confzsystemd.resolved.conf)z/etc/resolv.confz/etc/systemd/resolved.confÚcc_resolv_conf)ÚalpineÚ
azurelinuxÚfedoraÚmarinerÚopensusezopensuse-leapzopensuse-microoszopensuse-tumbleweedÚphotonÚrhelÚsle_hpcz	sle-microÚslesÚ	openeulerÚmanage_resolv_conf)ÚidÚdistrosÚ	frequencyÚactivate_by_schema_keysÚmetac                 C   sš   g }g }d|v r%|d   ¡ D ]\}}t|tƒr$|r| |¡ q| |¡ q|| D ]}|d |= q)| d¡s:i |d< ||d< t d| ¡ t | ||¡ d S )NÚoptionsÚflagsz$Writing resolv.conf from template %s)	ÚitemsÚ
isinstanceÚboolÚappendÚgetÚLOGÚdebugr   Úrender_to_file)Útemplate_fnÚparamsÚtarget_fnamer   Úfalse_flagsÚkeyÚvalÚflag© r*   úA/usr/lib/python3/dist-packages/cloudinit/config/cc_resolv_conf.pyÚgenerate_resolv_conf1   s    

€
r,   ÚnameÚcfgÚcloudÚargsÚreturnc                 C   sœ   d|vrt  d| ¡ dS t |dd¡st  d| ¡ dS d|vr&t  d¡ dS z| t|jj ¡}W n t	y@   t  d¡ Y dS w t
||d |jjd	� dS )
a[  
    Handler for resolv.conf

    @param name: The module name "resolv_conf" from cloud.cfg
    @param cfg: A nested dict containing the entire cloud config contents.
    @param cloud: The L{CloudInit} object in use.
    @param log: Pre-initialized Python logger object to use for logging.
    @param args: Any module arguments from cloud.cfg
    r   zFSkipping module named %s, no 'manage_resolv_conf' key in configurationNFzGSkipping module named %s, 'manage_resolv_conf' present but set to FalseÚresolv_confz3manage_resolv_conf True but no parameters provided!z0No template found, not rendering resolve configs)r#   r$   r%   )r    r!   r   Úget_cfg_option_boolÚwarningÚget_template_filenameÚRESOLVE_CONFIG_TEMPLATE_MAPÚdistroÚresolve_conf_fnÚKeyErrorr,   )r-   r.   r/   r0   r#   r*   r*   r+   ÚhandleH   s:   
ýý

ÿ
þýr:   )Ú__doc__ÚloggingÚ	cloudinitr   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.settingsr   Ú	getLoggerÚ__name__r    r6   r   Ú__annotations__r,   ÚstrÚlistr:   r*   r*   r*   r+   Ú<module>   s$   
þí"