o
    i	                  
   @   s   U d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	ged
gdZeed< eeZdede	dededdf
ddZdS )z@Update Etc Hosts: Update the hosts file (usually ``/etc/hosts``)    N)	lifecycle	templaterutil)Cloud)Config)
MetaSchema)
PER_ALWAYScc_update_etc_hostsallmanage_etc_hosts)iddistros	frequencyactivate_by_schema_keysmetanamecfgcloudargsreturnc           
      C   s   t |dd}|jj}t j|dgdrP|dkrtjdddd t ||\}}}|s1t	d	 d S |
d
|jj }	|	sDtd|jj t|	|||d d S |dkrut ||\}}}|sft	d	 d S td| |j|| d S td||  d S )Nr   Ftemplate)addonsz+Value 'template' for key 'manage_etc_hosts'z22.2zUse 'true' instead.)
deprecateddeprecated_versionextra_messagez<Option 'manage_etc_hosts' was set, but no hostname was foundzhosts.%sz.No hosts template could be found for distro %s)hostnamefqdn	localhostzManaging localhost in %szPConfiguration option 'manage_etc_hosts' is not set, not managing %s in module %s)r   get_cfg_option_strdistrohosts_fntranslate_boolr   	deprecateget_hostname_fqdnLOGwarningget_template_filenameosfamilyRuntimeErrorr   render_to_filedebugupdate_etc_hosts)
r   r   r   r   manage_hostsr    r   r   _tpl_fn_name r/   F/usr/lib/python3/dist-packages/cloudinit/config/cc_update_etc_hosts.pyhandle   sR   
r1   )__doc__logging	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.settingsr   r   __annotations__	getLogger__name__r$   strlistr1   r/   r/   r/   r0   <module>   s   
"