o
    iѥ                  
   @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ d dlm Z m!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l.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; e<e=Z>dZ?G dd dZ@dZAdejBdeCde$de#deDf
ddZEG dd dZFdeGfdd ZHdd!deGdeCfd"d#ZIdS )$    N)suppress)Path)AnyDictIterableListOptionalSetTupleUnion)atomic_helperclouddistrosfeatureshandlershelpersimporter	lifecyclenetsources
type_utilsutil)Netv1Netv2)
EventScope	EventTypeuserdata_to_events)BootHookPartHandler)CloudConfigPartHandler)JinjaTemplatePartHandler)ShellScriptPartHandler)ShellScriptByFreqPartHandler)cmdline)events)CLOUD_CONFIGDEFAULT_RUN_DIR
PER_ALWAYSPER_INSTANCEPER_ONCE)NetworkConfigSourceNO_PREVIOUS_INSTANCE_IDc                   @   s   e Zd Zdd ZdS )
_Semaphorec                 C   s   || _ || _d S N)	semaphoreargs)selfr-   r.    r0   2/usr/lib/python3/dist-packages/cloudinit/stages.py__init__:   s   
z_Semaphore.__init__N)__name__
__module____qualname__r2   r0   r0   r0   r1   r+   9   s    r+   zAggregated cloud-config created by merging merged_system_cfg (/etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d), metadata, vendordata and userdata. The combined_cloud_config represents the aggregated desired configuration acted upon by cloud-init.
datasourcecfgevent_source_typescopereturnc                 C   s   | j }t|di }tt|t|g}tj| j	|t
 v rOt| j}|j|d v rOtd|tj| jd ||sGt
 ||< || tj td| |g}dd |D }	|D ]}
|||
g v rvtd|
j|  d	S qatd
|	| dS )aA  Determine if a particular EventType is enabled.

    For the `event_source_type` passed in, check whether this EventType
    is enabled in the `updates` section of the userdata. If `updates`
    is not enabled in userdata, check if defined as one of the
    `default_events` on the datasource. `scope` may be used to
    narrow the check to a particular `EventScope`.

    Note that on first boot, userdata may NOT be available yet. In this
    case, we only have the data source's `default_update_events`,
    so an event that should be enabled in userdata may be denied.
    updatesscopesz/Adding event: scope=%s EventType=%s found in %szhotplug.enabledzAllowed events: %sc                 S   s   g | ]}|j qS r0   )value).0sr0   r0   r1   
<listcomp>{   s    z(update_event_enabled.<locals>.<listcomp>z$Event Allowed: scope=%s EventType=%sTz$Event Denied: scopes=%s EventType=%sF)default_update_eventsr   getr   mergemanydictcopydeepcopyr   HOTPLUGsupported_update_eventssetread_hotplug_enabled_filepathsr=   LOGdebug	get_cpathadd)r6   r7   r8   r9   default_eventsuser_eventsallowedhotplug_enabled_filer<   scope_values	evt_scoper0   r0   r1   update_event_enabledG   sP   

	


rU   c                   @   s<  e Zd Zdjdeee  fddZdd Zedd Z	ed	d
 Z
dd Zedd Zdd ZdkddZdd ZedededefddZdd ZdlddZdd  Zd!efd"d#Zd$d% Zd&d' Zd(d) Zd*d+ Zdejfd,d-Zd.d/ Zdld0d1Z d2efd3d4Z!d5d6 Z"edejfd7d8Z#d9d: Z$d;d< Z%dmd>d?Z&d@dA Z'dBdC Z(dDdE Z)dFdG Z*dHdI Z+dJdK Z,dLdM Z-dNdO Z.dldee/j0 fdPdQZ1dRdS Z2dTdU Z3	dldVdWZ4e5fdXdYZ6e5fdZd[Z7e5fd\d]Z8de9e:e;df fd^d_Z<de=e9e:e;df e9e>ef f fd`daZ?dbdc Z@deAfdddeZBdeCfdfdgZDdhdi ZEdS )nInitNds_depsc                 C   sd   |d ur|| _ ntjtjg| _ i | _d | _d | _d | _d| _d | _	|d u r-t
jdddd}|| _d S )NFzinit-reporterz	init-desc)namedescriptionreporting_enabled)rW   r   DEP_FILESYSTEMDEP_NETWORK_cfg_paths_distror6   ds_restored_previous_iidr#   ReportEventStackreporter)r/   rW   rc   r0   r0   r1   r2      s    
zInit.__init__c                 C   s   i | _ d | _d | _d S r,   )r]   r^   r_   r/   r0   r0   r1   _reset   s   
zInit._resetc                 C   sf   | j s0| d}|dd}t|}td| |||| j| _ | jd ur0| j | j_	| j
| j_| j S )NsystemdistroubuntuzUsing distro class %s)r_   _extract_cfgpopr   fetchrK   rL   rJ   r6   rg   r7   sys_cfg)r/   system_configdistro_name
distro_clsr0   r0   r1   rg      s   




zInit.distroc                 C   s
   |  dS )N
restricted)ri   rd   r0   r0   r1   r7      s   
zInit.cfgc                 C   s`   |    t| j}|dkr|dd  |S |dkr#t|di }|S |dkr.t|di }|S )Nrp   system_inforf   )rq   rJ   )rq   rJ   )read_cfgrD   rE   r]   rj   r   get_cfg_by_path)r/   restrictionocfgr0   r0   r1   ri      s   zInit._extract_cfgc                 C   s&   | j s| d}t|| j| _ | j S )NrJ   )r^   ri   r   Pathsr6   )r/   	path_infor0   r0   r1   rJ      s   
z
Init.pathsc                 C   s   | j j}| j j}|tj|dtj|ddtj|ddtj|ddtj|ddtj|dtj|dtj|dtj|d	tj|d
tj|d	g}|S )Nscriptszper-instancezper-oncezper-bootvendorseed	instancesr   semdata)rJ   	cloud_dirrun_dirospathjoin)r/   c_dirr   initial_dirsr0   r0   r1   _initial_subdirs   s    zInit._initial_subdirsFc                 C   s8   | j jg}|r|| j j |D ]}t| qt|S r,   )rJ   boot_finishedappendinstance_linkr   del_filelen)r/   rm_instance_lnkrm_listfr0   r0   r1   purge_cache   s   
zInit.purge_cachec                 C   s   |    d S r,   )_initialize_filesystemrd   r0   r0   r1   
initialize   s   zInit.initializemode_1mode_2r:   c                 C   s   | |@ S r,   r0   )r   r   r0   r0   r1   _get_strictest_mode   s   zInit._get_strictest_modec           	      C   s
  d}t |   t | jd}|rtt | dt |}W d    n1 s*w   Y  t j	||dd | j
d}|sAi }t|tsI|g}d }|D ](}t |\}}zt ||| W  d S  tyu } z|}W Y d }~qMd }~ww td|d|| d S d S )Ni  def_log_fileF)preserve_modesyslog_fix_permsz,Failed changing perms on '%s'. tried: %s. %s,)r   ensure_dirsr   get_cfg_option_strr7   r   OSErrorr   get_permissionsensure_filerB   
isinstancelistextract_usergroupchownbynamerK   warningr   )	r/   modelog_filepermserrorpermuger0   r0   r1   r      s@   


zInit._initialize_filesystemc                 C   s   | j s| || _ d S d S r,   )r]   	_read_cfg)r/   	extra_fnsr0   r0   r1   rr     s   zInit.read_cfgc                 C   sB   |  |i }|di di }|dtdfv r|S |  ||S )z read and merge our configurationrq   rJ   r   N)_read_bootstrap_cfgrB   r%   )r/   r   initial_configrJ   r0   r0   r1   r     s
   zInit._read_cfgbootstrapped_configc                 C   s<   t || j}|d}t j|| j|t|j|dd}|jS )Ninstance_data_sensitiveinstance_data_file)rJ   r6   additional_fnsbase_cfg)r   rv   r6   get_runpathConfigMergerfetch_base_configr   r7   )r/   r   r   no_cfg_pathsr   mergerr0   r0   r1   r   0  s   zInit._read_bootstrap_cfgc                 C   s   t | jdS )Nobj_pkl)r   pkl_loadrJ   get_ipath_currd   r0   r0   r1   _restore_from_cache?  s   zInit._restore_from_cachec                 C   s>   t | jddrt j| jdddd t| j| jdS )Nmanual_cache_cleanFmanual_clean_markerw )omodecontentr   )	r   get_cfg_option_boolr7   
write_filerJ   r   r   	pkl_storedsrd   r0   r0   r1   _write_to_cacheE  s   
zInit._write_to_cachec                 C   sN   | j dpg }dttfD ]}||vr|| q| j dp"g }||fS )Ndatasource_pkg_listr   datasource_list)r7   rB   r   obj_namer   r   )r/   pkg_listncfg_listr0   r0   r1   _get_datasourcesP  s   
zInit._get_datasourcesc                 C   s   |dvr
t d| |  }|sdS | jd}tj|r&t|	 }nd }||
 kr4|d| fS |dkr>|d| fS t|drO|| jrO|d	| fS d d
| fS )N)checktrustz!Unexpected value for existing: %s)Nzno cache foundinstance_idz&restored from cache with run check: %sr   zrestored from cache: %scheck_instance_idzrestored from checked cache: %szcache invalid in datasource: %s)
ValueErrorr   rJ   r   r   r   existsr   load_text_filestripget_instance_idhasattrr   r7   )r/   existingr   
run_iid_fnrun_iidr0   r0   r1   _restore_from_checked_cacheZ  s$   z Init._restore_from_checked_cachec           	   
   C   sD  | j d ur| j S tjdd| | jd}| |\}}||_t|| _t	|j W d    n1 s3w   Y  |sz+| 
 \}}t| j| j| jt| j||| j\}}t| jj td|| W n3 tjy } z&|dkrt||  }|r| rtd| n	t| jj |W Y d }~nd }~ww || _ |   |S )Nzcheck-cachez"attempting to read from cache [%s])rX   rY   parentzLoaded datasource %s - %sr   z3Restored fallback datasource from checked cache: %s)r6   r#   rb   rc   r   rY   boolr`   rK   rL   r   r   find_sourcer7   rg   rJ   rD   rE   rW   r   r   r   infoDataSourceNotFoundExceptionr   check_if_fallback_is_allowedre   )	r/   r   myrepr   descr   r   dsnamer   r0   r0   r1   _get_data_sourcet  sX   



	zInit._get_data_sourcec                 C   s   g dS )N)r   rx   r|   r0   rd   r0   r0   r1   _get_instance_subdirs     zInit._get_instance_subdirsc                 C   s   | j |}|std|S )NzCNo instance directory is available. Has a datasource been fetched??)rJ   	get_ipathRuntimeError)r/   subnameinstance_dirr0   r0   r1   
_get_ipath  s   zInit._get_ipathnetcfgc                 C   s   t j| jjs
dS | jd}| jd}t j|r/|t	t
|kr.tj||dd ntj||dd t j|sEt|| dS dS )zCreate /var/lib/cloud/instance/network-config.json

        Only attempt once /var/lib/cloud/instance exists which is created
        by Init.instancify once a datasource is detected.
        Nnetwork_config  r   )r   r   islinkrJ   r   r   r   r   r   	load_jsonr   r   
write_jsonsym_link)r/   r   ncfg_instance_pathnetwork_linkr0   r0   r1   _write_network_config_json  s    zInit._write_network_config_jsonc                 C   s  |   }t| jj  }|t| k}|rtd nt	| jj t
|| jj g }|  D ]}|tj|| q3t| | jd}dt| j| jf }d }tj|d}	z	t|	 }W n	 tyq   Y nw |sv|}t|	d|  ttj|dd|  | j }
tj|d}|  }t|d|
  t| jdd|
  ttj|d	d|  |   |r||krtd
 |
S |   |
S )Nz0Instance link already exists, not recreating it.r}   z%s: %sr6   z%s
zprevious-datasourceinstance-idr   zprevious-instance-idzJNot re-loading configuration, instance id and datasource have not changed.)r   r   rJ   r   resolveabsoluterK   r   r   r   r   r   r   r   r   r   r   rM   r   r   r   r   r   	Exceptionr   r   previous_iidr   r   re   )r/   idirdestinationalready_instancifieddir_listddpr   previous_dsds_fniidiid_fnr   r0   r0   r1   _reflect_cur_instance  sT   

	zInit._reflect_cur_instancec                 C   s   | j std| j S )a*  ds has a reference to the DataSource object

        self.datasource can contain a DataSource or None
        self.ds is preferred for any code path that is known to require an
        initialized DataSource, basically any code besides the initial
        bootstrapping of various objects.
        zDatasource is not initialized.)r6   r   rd   r0   r0   r1   r   
  s   	zInit.dsc                 C   sl   | j d ur| j S | jd}tj|d}z
t| | _ W n t	y+   t
| _ Y nw td| j  | j S )Nr}   r   zprevious iid found to be %s)ra   rJ   rM   r   r   r   r   r   r   r   r*   rK   rL   )r/   r  r  r0   r0   r1   r     s   

zInit.previous_iidc                 C   s   |   }|tkp|| j kS )zReturn true if this is a new instance.

        If datasource has already been initialized, this will return False,
        even on first boot.
        )r   r*   r   r   )r/   previousr0   r0   r1   is_new_instance%  s   zInit.is_new_instancer   c                 C   s   | j |dS )zUoptionally load datasource from cache, otherwise discover
        datasource
        )r   )r   )r/   r   r0   r0   r1   rk   1  s   z
Init.fetchc                 C   s   |   S r,   )r  rd   r0   r0   r1   
instancify7  r   zInit.instancifyc                 C   s(   t j| j| j| j| jt| j| jdS )N)rc   )	r   Cloudr   rJ   r7   rg   r   Runnersrc   rd   r0   r0   r1   cloudify:  s   
zInit.cloudifyc                 C   sp   |  | j d | | j d | | j d | | j d | | j d | | j	 d d S )Nuserdata
vendordatavendordata2)
_store_rawdatar   get_userdata_raw_store_processeddataget_userdata_store_raw_vendordataget_vendordata_rawget_vendordataget_vendordata2_rawget_vendordata2rd   r0   r0   r1   updateE  s   
zInit.updatec                 C   sJ   t jdd| jd | jj|  d W d    d S 1 sw   Y  d S )Nzsetup-datasourcezsetting up datasourcer   )r
  )r#   rb   rc   r   setupr
  rd   r0   r0   r1   setup_datasourceO  s
   "zInit.setup_datasourcec                 C   sV   t jdd| jd | jj| j|  d |   W d    d S 1 s$w   Y  d S )Nzactivate-datasourcezactivating datasourcer  )r7   r
  )r#   rb   rc   r   activater7   r
  r   rd   r0   r0   r1   activate_datasourceU  s   

"zInit.activate_datasourcec                 C   s(   |d u rd}t | d| |d d S )N    z%s_rawr   )r   r   r   r/   r}   r6   r0   r0   r1   r  `  s   zInit._store_rawdatac                 C   sR   |d urt |tttfvrtdtt | t|tr!t|}| || d S )Nz'vendordata_raw is unsupported type '%s')	typebytesstrr   	TypeErrorr   r   
json_dumpsr  r"  r0   r0   r1   r  f  s   

zInit._store_raw_vendordatac                 C   s(   |d u rd}t | |t|d d S )Nr   r   )r   r   r   r%  )r/   processed_datar6   r0   r0   r1   r  q  s
   zInit._store_processeddatac                 C   s   |d u ri }| | j| jd tdi |}tdi |}tdi |}||ttfi |ttfi |tt	fi ||t
di |d|||gig}|S )N)rJ   r6   sub_handlersr0   )r  rJ   r   r   r    r   r!   r&   r'   r(   r   )r/   optscloudconfig_handlershellscript_handlerboothook_handlerdef_handlersr0   r0   r1   _default_handlersy  s4   zInit._default_handlersc                 C      | j ddddS )Nvendor_scriptsvendor_cloud_configscript_pathcloud_config_pathr*  r/  rd   r0   r0   r1   _default_vendordata_handlers  
   z!Init._default_vendordata_handlersc                 C   r0  )Nr1  vendor2_cloud_configr3  r6  r7  rd   r0   r0   r1   _default_vendordata2_handlers  r9  z"Init._default_vendordata2_handlersc                    s   |du rg }| j d}| d|fD ]}|r%|tjvr%tjd| q fdd}t  || |D ]} j|dd}	|	rHt	
d|	| q6|   fd	d
}
 fdd} fdd}z|
  || W |  dS |  w )zb
        Generalized handlers suitable for use with either vendordata
        or userdata
        Nr   r   c              	      s   | rt j| s
d S t| }| D ]I\}}z5t|dgddg\}}|s0t	d||| W qt
|d }t|} |}|rKtd||| W q ty\   ttd| Y qw d S )Nr   
list_typeshandle_partzJCould not find a valid user-data handler named %s in file %s (searched %s)r   z(Added custom handler for %s [%s] from %sz"Failed to register handler from %s)r   r   isdirr   get_modules_from_diritemsr   find_modulerK   r   import_moduler   fixup_handlerregisterrL   r   logexc)r   potential_handlersfnamemod_namemod_locslooked_locsmodtypes)
c_handlersr0   r1   register_handlers_in_dir  sB   


z3Init._do_handlers.<locals>.register_handlers_in_dirF)	overwritez$Added default handler for %s from %sc                     s<      D ]\} }| jv rqt|  j| qd S r,   )r@  initializedr   
call_beginr   _ctyperK  rM  r}   	frequencyr0   r1   init_handlers  s   
z(Init._do_handlers.<locals>.init_handlersc                    s(    d| d}t jt j|d d S )Nr   )r   
handlerdirr}   rU  handlercountexcluded)r}   )r   walkwalker_callback)rY  	part_datarM  r}   data_msgrU  r   r0   r1   walk_handlers  s   z(Init._do_handlers.<locals>.walk_handlersc               	      s`      D ])\} }| jvrq j| z	t| W q ty-   ttd| Y qw d S )NzFailed to finalize handler: %s)	r@  rP  remover   call_endr   r   rE  rK   rR  rT  r0   r1   finalize_handlers  s   
z,Init._do_handlers.<locals>.finalize_handlers)rJ   rM   r   sysr   insertr   ContentHandlersrD  rK   rL   r  )r/   r^  c_handlers_listrU  rY  cdirr  rN  rK  rL  rV  r_  rb  r0   r]  r1   _do_handlers  s0   
#

zInit._do_handlersc              
   C   s  t jdd| jd t| jddr| | ntd W d    n1 s'w   Y  t jdd| jd | 	d	| W d    n1 sFw   Y  t jd
d| jd | 	d| W d    n1 sew   Y  | 
  t| j}t|d< | d|d< t |d< tj| jd|dd | jd}z
tt|}W n8 ttfy } ztd|| W Y d }~d S d }~w tjtfy } ztd|| W Y d }~d S d }~ww |d |d< |d |d< tj||dd d S )Nzconsume-user-datazreading and applying user-datar  allow_userdataTz,allow_userdata = False: discarding user-datazconsume-vendor-dataz reading and applying vendor-datar  zconsume-vendor-data2z!reading and applying vendor-data2r  _docrf   rq   r   combined_cloud_configr   r   r   zESkipping write of system_info/features to %s. Unable to read file: %szDSkipping write of system_info/features to %s. Invalid JSON found: %s)r#   rb   rc   r   r   r7   _consume_userdatarK   rL   _consume_vendordatare   rD   rE   COMBINED_CLOUD_CONFIG_DOCri   r   get_featuresr   r   rJ   r   r   r   r   IOErrorr   jsonJSONDecodeErrorr&  )r/   rU  combined_cloud_cfgjson_sensitive_fileinstance_jsonr   r0   r0   r1   consume_data  s~   



zInit.consume_datac           
      C   s@  |dkr| j  std dS d}n|dkr&| j  s#td dS d}ntdtj| j| j g | j	d	d
}|j	
|i }t|tsNdd	i}td|| |
d}|
dd}t|sftd| dS t|trwtjd| dddd td|| |dkr| j  }|  }	n	| j  }|  }	| j||	||d dS )zH
        Consume the vendordata and run the part handlers on it
        r  zno vendordata from datasourceNvendor_datar  zno vendordata2 from datasourcevendor_data2z>vendor_source arg must be either 'vendordata' or 'vendordata2'F)rJ   r6   r   r   include_vendorenabledz$invalid %s setting. resetting to: %sdisabled_handlersz%s consumption is disabled.zUse of string 'z!' for 'vendor_data:enabled' fieldz23.1zUse boolean value instead.)
deprecateddeprecated_versionextra_messagez)%s will be consumed. disabled_handlers=%s)rY  )r   r  rK   rL   r  r   r   r   r^   r7   rB   r   dictr   r   is_truer%  r   	deprecater  r8  r  r;  rh  )
r/   vendor_sourcerU  cfg_name
_cc_mergervdcfgrz  no_handlersvendor_data_msgrf  r0   r0   r1   rm  o  sd   	












zInit._consume_vendordatac                 C   s&   | j d}|  }| ||| dS )z@
        Consume the userdata and run the part handlers
        TN)r   r  r/  rh  )r/   rU  user_data_msgrf  r0   r0   r1   rl    s   zInit._consume_userdatac                 C   s   |r
d|v r
|d S |S )z
        Network configuration can be passed as a dict under a "network" key, or
        optionally at the top level. In both cases, return the config.
        networkr0   )r/   r7   r0   r0   r1   _get_network_key_contents  s   zInit._get_network_key_contentsc              
   C   s(  t j| jdd}t j|rd |fS tjt	 tj
t tjd tj| jdi}| jr@| jj}t| jdr?| jj|tj< ntjj}|D ]9}t|tsTtd| qF||vr_td| qF| || }t|rwtd| d |f  S |r||f  S qF| jddstd	 | j tj fS )
Nr}   zupgraded-networkr  r   z7data source specifies an invalid network cfg_source: %sz;data source specifies an unavailable network cfg_source: %sznetwork config disabled by %sTzEmpty network config found)!r   r   r   rJ   rM   r   r)   CMD_LINEr"   read_kernel_cmdline_config	INITRAMFSread_initramfs_configDS
SYSTEM_CFGr7   rB   r6   r   network_config_sourcesr   r   r   
DataSourcer   rK   r   r  r   is_disabled_cfgrL   rg   generate_fallback_configFALLBACK)r/   disable_fileavailable_cfgsorder
cfg_sourcencfgr0   r0   r1   _find_networking_config  sR   




zInit._find_networking_configc              
   C   sT   zt d| | jj| W d S  ty) } zt d| W Y d }~d S d }~ww )Nz applying net config names for %szFailed to rename devices: %s)rK   rL   rg   
networkingapply_network_config_namesr   r   )r/   r   r   r0   r0   r1   _apply_netcfg_names  s   zInit._apply_netcfg_namesc                 C   s   t t| jddtfS )Nr|   apply_network_config)r+   r   FileSemaphoresrJ   r   r(   rd   r0   r0   r1   _get_per_boot_network_semaphore  s   z$Init._get_per_boot_network_semaphorec                 C   s   |   }|jj|j S r,   )r  r-   has_runr.   )r/   r|   r0   r0   r1   _network_already_configured  s   z Init._network_already_configuredc           	   
      s  ddl m}m}  \}}|du rtd| dS fdd  fdd}jdurD sD| sD tj	sDt
d	 | dS  \}}|r[| |||jd
d
dd jj| | td|||  }z#|jj|j  jj||dW  d   W S 1 sw   Y  W dS  tjy } ztd| W Y d}~dS d}~w ty   tdj Y dS w )zApply the network config.

        Find the config, determine whether to apply it, apply it via
        the distro, and optionally bring it up
        r   )
SchemaTypevalidate_cloudconfig_schemaNz network config is disabled by %sc                    s$   t  j j| tjdo j| gS )N)r6   r7   r8   r9   )rU   r   r7   r   NETWORKupdate_metadata_if_supported)
event_typerd   r0   r1   "event_enabled_and_metadata_updated)  s   zEInit.apply_network_config.<locals>.event_enabled_and_metadata_updatedc                      s      o	 tjS r,   )r  r   BOOTr0   r  r/   r0   r1   should_run_on_boot_event1  s   
z;Init.apply_network_config.<locals>.should_run_on_boot_eventzWNo network config applied. Neither a new instance nor datasource network update allowedFT)configschema_typestrictlog_detailslog_deprecationsz5Applying network configuration from %s bringup=%s: %s)bring_upz@Unable to render networking. Network config is likely broken: %sz_distro '%s' does not implement apply_network_config. networking may not be configured properly.)cloudinit.config.schemar  r  r  rK   r   r6   r
  r   BOOT_LEGACYrL   r  r   NETWORK_CONFIGrg   r  wait_for_physdevsr  r-   lockr.   r  r   RendererNotFoundErrorr   NotImplementedErrorr   )	r/   r  r  r  r   srcr  r|   r   r0   r  r1   r    st   



(zInit.apply_network_config)NN)Fr,   )r   )Fr3   r4   r5   r   r   r%  r2   re   propertyrg   r7   ri   rJ   r   r   r   staticmethodintr   r   rr   r   r  r   r   r   r   r   r   r  r   r   r   r   r  r   r   r
  rk   r  r  r  r  r   r  r  r  r   Handlerr/  r8  r;  rh  r'   rv  rm  rl  r   r   r   r  r
   r)   r  r  r+   r  r   r  r  r0   r0   r0   r1   rV      sr    




%
0
=

 	
vPN	
4rV   r   c                 C   s   t tj| dS )Nz	cloud.cfg)r   	read_confr   r   r   )r   r0   r0   r1   read_runtime_configt  s   r  r   c                C   s,   t jt  t jt|dt| t  gddS )Nr   T)reverse)r   rC   get_builtin_cfgread_conf_with_confdr$   r  read_conf_from_cmdline)r   r   r0   r0   r1   r   x  s   r   )JrD   rq  loggingr   rc  
contextlibr   pathlibr   typingr   r   r   r   r   r	   r
   r   	cloudinitr   r   r   r   r   r   r   r   r   r   r   r   cloudinit.configr   r   cloudinit.eventr   r   r   cloudinit.handlers.boot_hookr   cloudinit.handlers.cloud_configr   !cloudinit.handlers.jinja_templater   cloudinit.handlers.shell_scriptr    ,cloudinit.handlers.shell_script_by_frequencyr!   cloudinit.netr"   cloudinit.reportingr#   cloudinit.settingsr$   r%   r&   r'   r(   cloudinit.sourcesr)   	getLoggerr3   rK   r*   r+   rn  r  r  r   rU   rV   r%  r  r   r0   r0   r0   r1   <module>   s\   (8

E       o