
    x[h              
           % S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  S
\/\/ S.r\\S'   \R&                  " \5      r " S S\5      rS\S\
S\S\SS4
S jrg)z#Set Hostname: Set hostname and FQDN    N)util)
write_json)Cloud)Config)
MetaSchema)ALL_DISTROS)PER_INSTANCEcc_set_hostname)iddistros	frequencyactivate_by_schema_keysmetac                       \ rS rSrSrSrg)SetHostnameError   zRaised when the distro runs into an exception when setting hostname.

This may happen if we attempt to set the hostname early in cloud-init's
init-local timeframe as certain services may not be running yet.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       B/usr/lib/python3/dist-packages/cloudinit/config/cc_set_hostname.pyr   r      s    r   r   namecfgcloudargsreturnc                    [         R                  " USS5      (       a  [        R                  SU 5        g [         R                  " USS 5      nUb  UR                  R                  SU5        [         R                  " USS 5      nUb  UR                  R                  SU5        [         R                  " X5      u  pgn[        R                  R                  UR                  S5      S5      n	0 n
[        R                  R                  U	5      (       aN  [        R                  " U	5      R                  S:  a*  [         R                  " [         R                  " U	5      5      n
XjR!                  S	5      :g  =(       d    XzR!                  S
5      :g  nU(       d  [        R                  S5        g U(       a  US:X  a  [        R                  S5        g [        R                  SXv5         UR                  R#                  Xg5        [+        XUS.5        g ! [$         a>  nSU< SU< S3n[         R&                  " [        U5        [)        U< SU< 35      UeS nAff = f)Npreserve_hostnameFzVConfiguration option 'preserve_hostname' is set, not setting the hostname in module %sprefer_fqdn_over_hostnamecreate_hostname_filedatazset-hostnamer   hostnamefqdnz*No hostname changes. Skipping set_hostname	localhostz6Hostname is localhost. Let other services handle this.zSetting the hostname to %s (%s)zFailed to set the hostname to z ()z: )r&   r'   )r   get_cfg_option_boolLOGdebugdistro
set_optionget_hostname_fqdnospathjoin	get_cpathexistsstatst_size	load_jsonload_text_filegetset_hostname	Exceptionlogexcr   r   )r   r   r   r   hostname_fqdnr$   r&   r'   
is_defaultprev_fnprev_hostnamehostname_changedemsgs                 r   handlerD   '   s   %8%@@		5	

 	 ,,($M   ;]K  33#T ' 68LM#'#9#9##E XZ ggll5??62NCGM	ww~~g2777#3#;#;a#?t':':7'CD#4#4$  +	""6*	*  		>?h+-		JKII/@;!!(1
 wt<=	  ;9=xHC323:;s   #H 
I9II)r   loggingr0   	cloudinitr   cloudinit.atomic_helperr   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.distrosr   cloudinit.settingsr	   r   __annotations__	getLoggerr   r+   r;   r   strlistrD   r   r   r   <module>rQ      s    *  	  . ! # . ) + }!	j  !y 4> 4>6 4>% 4>t 4> 4>r   