
    x[h              
           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j                  e      Zdd	d
Zdg dedgdZe
ed<   d Zdededededdf
dZy)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                 f   g }g }d|v rQ|d   j                         D ];  \  }}t        |t              s|r|j                  |       +|j                  |       = ||z   D ]  }|d   |= 
 |j	                  d      si |d<   ||d<   t
        j                  d|        t        j                  | ||       y )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flags           A/usr/lib/python3/dist-packages/cloudinit/config/cc_resolv_conf.pygenerate_resolv_confr-   1   s    EKFy)//1 	,HC#t$LL%&&s+	, # $9d#$ ::i yF7OII4kB[,?    namecfgcloudargsreturnc                    d|vrt         j                  d|        yt        j                  |dd      st         j                  d|        yd|vrt         j	                  d       y	 |j                  t        |j                  j                           }t        ||d   |j                  j                  	       y# t        $ r t         j	                  d       Y yw xY w)
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/   r0   r1   r2   r%   s        r,   handler=   H   s     3&		<	

 	##C)=uE		=	

 	CIJ11'(D(DE
 =!\\11
   FGs   %,B7 7CC)__doc__logging	cloudinitr   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.settingsr   	getLogger__name__r"   r9   r   __annotations__r-   strlistr=    r.   r,   <module>rK      s    )  % ! # . +g! &"9     45'j .@.+ +6 +% +t + +r.   