name : main.cpython-39.opt-1.pyc
a

'�Dg���@s�ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.e/Z0dZ1dZ2e+e,e-d�Z3ddddd �Z4e�5e6�Z7d\d"d#�Z8d]d$d%�Z9d&d'�Z:e�;d(�e7j<fe
e/gdfd)�d*d+��Z=d,d-�Z>e#d.�d/d0�Z?d1d2�Z@d^d4d5�ZAd_e	eBe/fd7�d8d9�ZCd:d;�ZDd<d=�ZEeee/eFfe	eGe0fd>�d?d@�ZHeejIe	eGe0fdA�dBdC�ZJdDdE�ZKdFdG�ZLdHdI�ZMdJdK�ZNdLdM�ZOejPdN�dOdP�ZQdQdR�ZRdSdT�ZSd`dUdV�ZTdWdX�ZUdYdZ�ZVe6d[k�r�e�WeTejX��dS)a�N)�Optional�Tuple�Callable�Union)�netinfo)�signal_handler)�sources)�socket)�stages)�
url_helper)�util)�performance)�version)�warnings)�	reporting)�
atomic_helper)�	lifecycle)�handlers)�log_util�loggers)�read_cfg_paths)�cc_set_hostname)�Modules)�validate_cloudconfig_schema)�log_with_downgradable_level)�events)�PER_INSTANCE�
PER_ALWAYS�PER_ONCE�CLOUD_CONFIGzOCloud-init v. {version} running '{action}' at {timestamp}. Up {uptime} seconds.zcloud_%s_modules)�instance�always�oncezLocal Stagez
Network StagezConfig StagezFinal Stage)�
init-local�init�modules-config�
modules-final�cCsV|rtj�d|�tj�d�tj�d�tjtjd�tj�d�tj�d�dS)N�%s
z<------------------------------------------------------------�
)�file)�sys�stderr�write�	traceback�	print_exc��msg�r2�6/usr/lib/python3.9/site-packages/cloudinit/cmd/main.pyr/Tsr/cCs&|st|�}tjd|ddtd�|S)Nr(FT)Zconsoler,�log)�welcome_formatrZ	multi_log�LOG)�actionr1r2r2r3�welcome^sr8cCstjt��t��t��|d�S)N)r�uptimeZ	timestampr7)�WELCOME_MSG_TPL�formatr�version_stringrr9Ztime_rfc2822�r7r2r2r3r5es�r5�
Closing stdin)�loggercCsft�tj���sZ|d�ttj��&}t�|��tj���Wd�qb1sN0Yn|d�dS)zj
    reopen stdin as /dev/null to ensure no side effects

    logger: a function for logging messages
    r>Nz"Not closing stdin, stdin is a tty.)�os�isattyr+�stdin�fileno�open�devnull�dup2)r?�fpr2r2r3�close_stdinns
6rHcCs.g}|jr*|jD]}|�tj�|j��q|S�N)�files�appendr@�path�realpath�name)�argsZfn_cfgsZfhr2r2r3�extract_fns}s

rP)�modscCsvt|}|�|�\}}t|�t|�}|dkrXd||f}tj�d|�t�|�gSt�dt|�t|��|SdS)Nrz)No '%s' modules to run under section '%s'r(zRan %s modules with %s failures)�MOD_SECTION_TPLZrun_section�lenr+r,r-r6�debug)rQ�action_name�sectionZfull_section_name�	which_ran�failuresZtotal_attemptedr1r2r2r3�run_module_section�s�
�rYcCs|�d�rt�|�d��dS)Nr)�getrZupdate_configuration)�cfgr2r2r3�apply_reporting_cfg�s
r\��cloud-config-url�urlcCs@t�|�}|D]}||vr|||fSqtd||f��dS)Nz!No keys (%s) found in string '%s')rZkeyval_str_to_dict�KeyError)�cmdline�names�data�keyr2r2r3�parse_cmdline_url�s

reT)�returnc
Cs2|durt��}zt|�\}}Wnty<tjdfYS0|�d�}|r�tj�	|�r�|rzd||f}tj
}|r�tj}nd||f}tj}||fS|dddd	�}|s�|r�tj}d
|d<ntj}d|d<d}	d
}
�ztj
fi|��}d}|���r�d}
t|tj��rHz|t|jt|
�d��7}Wnt�y4Yn0|�|
��sZd}
n|j�|
��sZd}
|
�r�|dk�r�tjddddd�WSn2|dk�r�tj}ntj
}|d|�dt|
���fWSn|d||jffWS||j}	Wn8tj�y}z|d||ffWYd}~Sd}~00tj||	dd�tj
d|||ffS)a�Write data from url referenced in command line to path.

    path: a file to write content to if downloaded.
    network: should network access be assumed.
    cmdline: the cmdline to parse for cloud-config-url.

    This is used in MAAS datasource, in "ephemeral" (read-only root)
    environment where the instance netboots to iscsi ro root.
    and the entity that controls the pxe config has to configure
    the maas datasource.

    An attempt is made on network urls even in local datasource
    for case of network set up in initramfs.

    Return value is a tuple of a logger function (logging.DEBUG)
    and a message indicating what happened.
    Nz!No kernel command line url found.)zfile://�/z_file '%s' existed, possibly from local stage download of command line url '%s'. Not re-writing.zafile '%s' existed, possibly from previous boot download of command line url '%s'. Not re-writing.�
�T)r_�timeoutZretries�stream�Zsec_betweeng�������?s
#cloud-config�)Z
chunk_sizeFr_z!The kernel command line key `url`z22.3zD Please use `cloud-config-url` kernel command line parameter instead��
deprecated�deprecated_version�
extra_messageZskip_logr^z
contents of 'z' did not start with z$url '%s' returned code %s. Ignoring.zretrieving url '%s' failed: %si�)�modez*wrote cloud-config data from %s='%s' to %s)rZget_cmdlinerer`�logging�DEBUG�
startswithr@rL�exists�INFO�WARNrZread_file_or_url�ok�
isinstanceZUrlResponse�nextZiter_contentrS�
StopIteration�contentsr�	deprecate�str�codeZUrlError�
write_file)rL�networkraZcmdline_namer_Z
path_is_local�m�level�kwargsrc�headerZrespZsniffed_contentZis_cloud_cfg�er2r2r3�attempt_cmdline_url�s�
����

�

�

��&��r�cCs�dtjjtjjf}tj�|j�d�d�}tj�	|�rjt
�|�}||kr�t�
d�|�d�t
�||�n*tj�	|j�d��r�t�d�t
�||�dS)	z�Purge the cache if python version changed on us.

    There could be changes not represented in our cache (obj.pkl) after we
    upgrade to a new version of python, so at that point clear the cache
    z%d.%drczpython-versionz-Python version change detected. Purging cacheTZobj_pklzMWriting python-version file. Cache compatibility status is currently unknown.N)r+�version_info�major�minorr@rL�join�paths�	get_cpathrvr�load_text_filer6rT�purge_cacher��
get_ipath_cur�info)r$Zcurrent_python_versionZpython_version_pathZcached_python_versionr2r2r3�$purge_cache_on_python_version_changes$��


�r�cCst�|jd�rdS|jS)NZdisable_network_activationF)r�get_cfg_option_boolr[�local)r$rOr2r2r3�_should_bring_up_interfaces5sr�)�
raw_configrfc
Cs�|sdSt�|��dd��dkr&dSzt�|�}Wn:tyn}z"ttdtj	d|d�WYd}~d	Sd}~00d
|vr�|d
D]2}|�
d�p�i}|�
dd
�}|r�|�d�s�dSq�dS|�
d�r�dS|�
di��
d�r�dS|�
d�r�dSdS)a�Determine if our cloud-config requires us to wait

    User data requires us to wait during cloud-init network phase if:
    - We have user data that is anything other than cloud-config
      - This can likely be further optimized in the future to include
        other user data types
    - cloud-config contains:
      - bootcmd
      - random_seed command
      - mounts
      - write_files with source
    )Fzno configuration foundN�
ztext/cloud-config)Tz non-cloud-config user data foundz24.4z'Unexpected failure parsing userdata: %s)r?rZrequested_levelr1rO)Tz!failed to parse user data as yamlZwrite_files�sourceZurir')rgzfile:)Tz!write_files with source uri found)Fz$write_files without source uri foundZbootcmd)Tz
bootcmd foundZrandom_seedZcommand)Tzrandom_seed command foundZmounts)Tzmounts found)Fz8cloud-config does not contain network requiring elements)rZtype_from_starts_with�strip�yaml�	safe_load�	Exceptionrr6rs�WARNINGrZru)r�Zparsed_yamlr��itemZsource_dictZ
source_urir2r2r3�_should_wait_via_user_data;s@���

r�)�
datasourcerfcCs�|sdSt|���\}}|r*d|�d�fSt|���\}}|rLd|�d�fSt|���\}}|rnd|�d�fSdd|�d|�d	|��fS)
z�Determine if we should wait on network connectivity for cloud-init.

    We need to wait during the cloud-init network phase if:
    - We have no datasource
    - We have user data that may require network access
    )Tzno datasource foundTz
 in user dataz in vendor dataz in vendor data2Fzuser data: z, vendor data: z, vendor data2: )r�Zget_userdata_rawZget_vendordata_rawZget_vendordata2_raw)r�Zuser_should_waitZuser_reasonZvendor_should_waitZ
vendor_reasonZvendor2_should_waitZvendor2_reasonr2r2r3�_should_wait_on_networkps0	������r�cs�tjtjg}|jrtjg}ttj�dtd�|jd�g�|jrDdnd}t	|�}t
j||jd�}|�
t|��d}d}z@|js�t�fdd��t�|j|�\}}nt�|j|�\}}Wn:ty�d	}t�t|�t|���tj|f�Yn0|j�rt�d
�t��|j�s*t�|j�t |j�t!||d�t�"dt�#�|��D]\}	}t�$|	|��qLz|�%�Wn t�y�t�td
�Yn0|j&}
t'|�|j�r�tj(ntj)}|tj)k�rtj�*|j&�+d���s�t�d�|j,�-�d}t.j/�0dt1�2��nZd}t�3|jdd�}
|
�r.t�d�d}n(|
�4d�}tj�*|��rVt�d|�d}|�5�t6||�}zD|j7|d�|tj)k�r�|j8j9|k�r�t�d||j8�dgfWSWn�tj:�y:|tj(k�r�t�d�nt�td�|j;�s*|j<|d�t�d|�|tj(k�rdgfYSddgfYSnt�d|�Yn0t=|�|�>�}t�d ||||�?��|tj(k�r|t@|d!d"d#�|j<|d�|tj(k�rtA|j8�\}}|�r�t�d$|�n t�d%|�t�B|j&�+d�d&�|j8j9|k�r�t�d'||j8�|j8gfSt�d(||j8�|�C�|�D�t@|d)d*d#�z2|�E�jFd+|jGtHgtHd,�\}}|�s\|�GtI�Wn,t�y�t�td-�|j8d-gfYS0|j&�4d.�}tj�*|��r�t�J|�jKd/k�r�tLtM�Nt�O|��ddd0d1�n
t�d2�t |j�tP|t|�|jd3�}zR|}|}t�|j|�\}}||k�s.||k�rNt�Qd4||�t�|j|�\}}Wn t�ypt�td5�Yn0t�|j�|�R�tS|j8|jd6�|j8tT|||�fS)7Nz%s.dz91_kernel_cmdline_url.cfg)rLr�r#r$�Zds_deps�reportercs��tj|f�SrI)rKrsrtr0�Z
early_logsr2r3�<lambda>�rmzmain_init.<locals>.<lambda>�#Failed to setup output redirection!�@Logging being reset, this logger may no longer be active shortlyr0�!PID [%s] started cloud-init '%s'.z0Failed to initialize, likely bad things to come!z
.skip-networkz4Will wait for network connectivity before continuing�trustr(�checkZmanual_cache_cleanFz"manual cache clean set from configZmanual_clean_markerz(manual cache clean found from marker: %s��existingz)[%s] Exiting. datasource %s in local modezNo local datasource foundz8No instance datasource found! Likely bad things to come!)Zbring_upz[%s] Exiting without datasourcezNo instance datasource found.z2[%s] barreling on in force mode without datasourcez5[%s] %s will now be targeting instance id: %s. new=%sr�r�)�stage�retry_stagezTNetwork connectivity determined necessary for cloud-init's network stage. Reason: %szVNetwork connectivity determined unnecessary for cloud-init's network stage. Reason: %sr'z.[%s] Exiting. datasource %s not in local mode.z6[%s] %s is in local mode, will apply init modules now.zinit-netzmodules:config�consume_data)rOZfreqzConsuming user data failed!Zcloud_configrT)�config�strictZlog_detailsZlog_deprecationsz2Skipping user-data validation. No user-data found.�r�z#Stdout, stderr changing to (%s, %s)z'Failed to re-adjust output redirection!)r�r[)UrZDEP_FILESYSTEMZDEP_NETWORKr�r�r@rLr�rr5r
�Initr��read_cfgrP�skip_log_setuprHr�fixup_outputr[Zget_output_cfgr��logexcr6r/rKrsrxrTr�
reset_logging�
setup_loggingr\r8r��getppidr4Z
initializer�r�ZDSMODE_LOCALZDSMODE_NETWORKrv�get_runpathZdistroZwait_for_networkr+r,r-rZ
debug_infor�r�r�r��fetchr�Zdsmode�DataSourceNotFoundException�forceZapply_network_config�_maybe_persist_instance_dataZ
instancifyZis_new_instance�_maybe_set_hostnamer�r�Zsetup_datasource�update�cloudify�runr�rr�stat�st_sizerr�r�r�r�warningZactivate_datasource�di_report_warnrY)rNrOZdeps�bootstage_name�w_msgr$ZoutfmtZerrfmtr1ZlvlZpath_helperrrr�ZmcfgZmfileZbring_up_interfacesZiidZshould_wait�reasonZranZ_resultsZcloud_cfg_pathrQZoutfmt_origZerrfmt_origr2r�r3�	main_init�sB����





���
����
��
 �

r�cCs�d|vrt�d�dS|d}|dur4t�d�dSt|t�sNt�d|�dS|�d�}|durnt�d�dSt|t�s�t�d|�dS|j�d�d	}|�	t
j�r�|tt
j�d�}nt�d
||�||vr�t�d|||�dSt
jd||t|�d
�dS)NZ	di_reportzno di_report found in config.zdi_report was None.z%di_report config not a dictionary: %sZdatasource_listz(no 'datasource_list' found in di_report.z(di_report/datasource_list not a list: %s�.riz1Datasource '%s' came from unexpected module '%s'.z:used datasource '%s' from '%s' was in di_report's list: %sZdsid_missing_source)r��dslist)r6rTrz�dictr�rZ�list�
__module__�
rpartitionrurZ	DS_PREFIXrSrZshow_warningr)r�r[Zdicfgr��modnamer2r2r3r��sH





���r�cCs^|j}d||f}t|�}tjg|jd�}|�t|��z|jdd�Wn@tj	y�d|}t
�t|�t
|�|js�|gYSYn0t|�t|t|�|jd�}z|js�t�t
�|j|�Wnty�t
�td�Yn0|jr�t�d�t��|j�st�|j�t|j�t||d	�t�d
t��|�|dk�rRtj dd
dd�t!|||�S)Nz%s:%sr�r�r�zGCan not apply stage %s, no datasource found! Likely bad things to come!r�r�r�r0r�r$z
`--mode init`�24.1�Use `cloud-init init` instead.)rorprq)"rrr5r
r�r�r�rPr�rr�rr�r6r/r�r�rr�rHr�r[r�rTrr�r�r\r8r�r@r�rr~rY)rUrOrNr�r�r$r1rQr2r2r3�main_modules�sR���

�r�c
Cs~|j}t|�}tjg|jd�}|�t|��z|jdd�Wn4tj	ypt
�td�t
d�|jslYdSYn0t|�t|t|�|jd�}|j}|r�t�d|�|j}|r�t�d|�t�|�}zt�t
�|jd�Wnty�t
�td	�Yn0|j�rt�d
�t��t�|j�t|j�t||d�|�|||�\}}	|	�r`t� d|�dS|�svt� d
|�dSdSdS)Nr�r�r�z;Failed to fetch your datasource, likely bad things to come!rlr�zUsing passed in arguments %szUsing passed in frequency %sr�r�r0zRan %s but it failed!zDid not run %s, does it exist?r)!rNr5r
r�r�r�rPr�rr�rr�r6r/r�r�r�module_argsrTZ	frequency�FREQ_SHORT_NAMESrZrHr�r[r�rr�r�r\r8Z
run_singler�)
rNrO�mod_namer�r$rQZmod_argsZmod_freqrWrXr2r2r3�main_single�sZ	��
�
r�cCs�t�}|�d�}tj�|j�}tj�|d�}tj�|d�}tj�|d�}tj�|d�}t��}	t	�
||f�|j\}
}|dkr�|jr�d}q�d}n |dkr�d|j
}ntd|��|tvr�td	�|���giddd
�}
dd|
��|
��|
��|
��d�i}|dk�r"||||fD]}t	�|��qn*zt�t	�|��}Wnt�yJYn0||dv�rj|
��|d|<|d}||d
<||d�r�||d�s�t�dt|�tt	���||d<ttdd�|	j��}|��}t� ||�t	j!tj�"||�|dd��z�zX|||�}|dv�r6|\}}|du�r:t#|�|d<n|}||d�$dd�|D��Wn�t�y�}z:t�%d|�t&d|�||d�'t#|��WYd}~nnd}~0t(�y}zL|j)�r�t�%d|�t&d|�||d�'dt#|j)��d��WYd}~n
d}~00Wtt	���||d<d|d
<|��}|�*�|�+�D]J}||v�r|t,t-||||��||d|<n||||d|<�qHt� ||�n�tt	���||d<d|d
<|��}|�*�|�+�D]J}||v�r
t,t-||||��||d|<n||||d|<�q�t� ||�0|dk�r�g}|�+�D]<}t.||t/��rF||�0d��rF|�$||�0dg���qFt� |d|d|d �i�t	j!tj�"||�|dd�t1||d�S)!Nrczstatus.jsonzresult.jsonr$r#�modules�
modules-%szunknown name: %sz'Invalid cloud init mode specified '{0}')�errors�recoverable_errors�start�finished�v1)r�r$r#r%r&r�r�r�z=Unexpected start time found for %s. Was this stage restarted?cSst|tj�SrI)rzrZLogExporter)�hr2r2r3r��rmz status_wrapper.<locals>.<lambda>T)r�)r$r#r�r�cSsg|]}t|��qSr2)r)�.0r�r2r2r3�
<listcomp>�rmz"status_wrapper.<locals>.<listcomp>zfailed stage %szfailed run of stage %sz	sys.exit(z) calledr�r&)r�r�)2rr�r@rL�normpathZrun_dirr�rs�	getLoggerrZensure_dirsr7r�rr�
ValueError�
STAGE_NAMEr;�copyZdel_file�json�loadsr�r�r6r��floatr9r{�filterrZexport_logsrZ
write_jsonZsym_link�relpathr�extend�	exceptionr/rK�
SystemExitr�Z
clean_logs�keysr��setrzr�rZrS)rNrOr�Zdata_dZlink_dZstatus_pathZstatus_link�result_pathZresult_linkZroot_logger�_name�functorrrZ
nullstatus�status�fr�ZhandlerZpreexisting_recoverable_errors�retr�r�r�Znew_recoverable_errorsrdr�r2r2r3�status_wrapperCs
��
����	
�
���


 *8
�����
����
 ��r�)r$cCs6|jr2|jr2|j�d�}tj�|�s2|jjdd�dS)zCWrite instance-data.json file if absent and datasource is restored.Z
instance_dataF)Zwrite_cacheN)r�Zds_restoredr�r�r@rLrvZpersist_instance_data)r$Zinstance_data_filer2r2r3r��sr�c
Csz|��}tj|j|dd�\}}}|rvzt�d|j|d�Wn:tjyt}z t�d||t	|��WYd}~n
d}~00dS)z�Call set_hostname if metadata, vendordata or userdata provides it.

    @param stage: String representing current stage in which we are running.
    @param retry_stage: String represented logs upon error setting hostname.
    T)Z
metadata_onlyZset_hostnameNzGFailed setting hostname in %s stage. Will retry in %s stage. Error: %s.)
r�rZget_hostname_fqdnr[rZhandleZSetHostnameErrorr6rTr)r$r�r�Zcloud�hostnameZ_fqdn�_r�r2r2r3r��s��r�cCs tj�d�ttj��d�dS)Nr))r+�stdoutr-r��sortedrZFEATURES)rNrOr2r2r3�
main_features�sr�c	Cs�t��|stj}tj|�d�d�}|jddddt�	�dd�|jd	d
ddd
d�|jddddd
d�|jddddd
d�|j
dd�|jddd�}|jddd�}|jdddd d
d�|jd!d"d#d$d%t�
d&�d'�|j
dtfd(�|jd)d*d�}tjd+d,d-d.d/�j}|jd0d1d2d3|��d4d5d6�|jd!d"d#d$d%t�
d&�d'�|j
d)tfd(�|jd7d8d�}|jd9d:d2d;d.d<�|jd=d2d>d
tt���d?�|jd@ddAd
d<�|jdBdCdDdEdF�|jd!d"d#d$d%t�
d&�d'�|j
d7tfd(�|jdGdHd�}|jdIdJd�}|j
dItfd(�|jdKdLd�}	|jdMdNd�}
|jdOdPd�}|jdQdRd�}|jdSdTd�}
|jdUdVd�}|�r�tdWdX�|D�d�}|dKk�r�ddYlm}||	��q�|dMk�r�ddYlm}||
��q�|dOk�r�ddZlm}m}||d[�|j
dO|fd(�n�|dQk�r$dd\lm}m}||�|j
dQ|fd(�n�|dGk�rXdd]l m}m!}||�|j
d^|fd(�nf|dUk�r�dd_l"m}m#}||�|j
dU|fd(�n2|dSk�r�dd`l$m}m%}||
�|
j
dS|fd(�n
|�&da�|j'|db�}t(|dcd
�|j)�s�t*|�St)|�S)dNr)�progz	--versionz-vrz	%(prog)s z'Show program's version number and exit.)r7r�helpz--debugz-d�
store_truez:Show additional pre-action logging (default: %(default)s).F)r7r�defaultz--forcezDForce running even if no datasource is found (use at your own risk).r�)r7r�destrz--all-stages�
all_stageszsRun cloud-init's stages under a single process using a syncronization protocol. This is not intended for CLI usage.)rr7rrr�ZSubcommands�
subcommand)�titlerr$z2Initialize cloud-init and perform initial modules.)r�--localz-lz+Start in local mode (default: %(default)s).z--filez-frKrJz(Use additional yaml configuration files.�rb)r7rr�typer=r�z1Activate modules using a given configuration key.z`init`r�r�Trnz--modez-m�storez9Module configuration name to use (default: %(default)s). r�)r$r��final)r7rr�choices�singlezRun a single module.z--namez-nzModule name to run.)r7r�requiredz--frequencyzModule frequency for this run.)r7rrr
z--reportzEnable reporting.r��*�argumentz0Any additional arguments to pass to this module.)�nargs�metavarr�queryz;Query standardized instance metadata from the command line.ZfeatureszList defined features.Zanalyzez-Devel tool: Analyze cloud-init logs and data.ZdevelzRun development tools.zcollect-logsz*Collect and tar all cloud-init debug info.Zcleanz3Remove logs and artifacts so cloud-init can re-run.r�z/Report cloud-init status or wait on completion.Zschemaz-Validate cloud-config files using jsonschema.css|]}|�d�s|VqdS)�-N)ru)r�Zposargr2r2r3�	<genexpr>�rmzmain.<locals>.<genexpr>)�
get_parser)r�handle_collect_logs_args)�parser)r�handle_clean_args)r�handle_argsZrender)r�handle_schema_args)r�handle_status_argsza subcommand is required�rOr�)+rZconfigure_root_loggerr+�argv�argparse�ArgumentParser�pop�add_argumentrr<�set_defaults�add_subparsers�
add_parser�FileTyper�rr~�messager�r�r�r�r�r�r{Zcloudinit.analyzerZcloudinit.cmd.devel.parserZcloudinit.cmd.devel.logsrZcloudinit.cmd.cleanrZcloudinit.cmd.queryr�cloudinit.config.schemarZcloudinit.cmd.statusr�error�
parse_args�setattrr�sub_main)Z	sysv_argsrZ
subparsersZparser_initZ
parser_modZ
extra_helpZ
parser_singleZparser_queryZparser_featuresZparser_analyzeZparser_develZparser_collect_logsZparser_cleanZ
parser_statusZ
parser_schemarZanalyze_parserZdevel_parserZlogs_parserrZclean_parserrZquery_parserZhandle_query_argsZ
schema_parserrZ
status_parserrrOr2r2r3�mainsp
�������
�������
�������������



�




r.cCs�t�d�t�dddd�}t�d�|d��0|jddgd	�}d
|_t|�|_Wd�n1sb0Y|d��.|jdgd	�}d|_t|�|_Wd�n1s�0Y|d��0|jd
dgd	�}d|_t|�|_Wd�n1s�0Y|d��0|jd
dgd	�}d|_t|�|_Wd�n1�s:0Y|j	�r�d}|j
�rdd|j
��}t�d|�d��t�d�dSt�d�t�d�dS)z>Run all stages in a single process using an ordering protocol.z*Running cloud-init in single process mode.r�r�r�rzREADY=1r$rrFNTr�z
--mode=configz--mode=finalz%a stage of cloud-init exited non-zerozfirst exception received: zSTATUS=Completed with failure, z2. Run 'cloud-init status --long' for more details.z
STOPPING=1rlzSTATUS=Completed)r6r�r	Z
SocketSyncZ	sd_notifyr+r�r-Zsystemd_exit_codeZexperienced_any_errorZfirst_exception)r�syncrOr(r2r2r3r�s<


(
(
(
*
�

rc	Cs�|j\}}|dvr,t�|jr"tjntj�n|jr:t��t��d|ks\d|kr`d|j	kr`t
}d}d}|dkr�|jr�d\}}q�d\}}nV|dkr�d|j	d|j	}}n6|d	kr�d
|jd|j}}|j
}n|}d|}d
}tj|||d�|_|j�Nt�d|�d���|||�}Wd�n1�s.0YWd�n1�sN0Yt��d|k�r~d|j	k�r~t|�}|S)N)r$r�r$r�T)r#zsearching for local datasources)zinit-networkz!searching for network datasourcesr�zrunning modules for %srz	single/%szrunning single module %szrunning 'cloud-init %s'F)Zreporting_enabledzcloud-init stage: '�')r7rZsetup_basic_loggingrTrsrtr�rZattach_handlersrrr�r�rN�reportrZReportEventStackr�r
ZTimedrZflush_eventsrS)rOrNr�ZrnameZ	report_onZrdescZretvalr2r2r3r-.sL
�

���Jr-�__main__)r')N)r])TN)N)Yr r�r@r+r.rsr��typingrrrrZ	cloudinitrrrr	r
rrr
rrrrrrZ
cloudinit.logrrZcloudinit.cmd.develrZcloudinit.configrZcloudinit.config.modulesrr)rZcloudinit.lifecyclerZcloudinit.reportingrZcloudinit.settingsrrrrrZReasonr:rRr�r�r��__name__r6r/r8r5ZtimedrTrHrPrYr\re�intr�r�r��bytes�boolr�Z
DataSourcer�r�r�r�r�r�r�r�r�r�r.rr-�exitrr2r2r2r3�<module>s����



	 

m
�6
�%v2AF
s;E


© 2025 Cubjrnet7