%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3/dist-packages/cloudinit/cmd/__pycache__/main.cpython-38.pyc

U

��gR��@s�ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/e0Z1dZ2dZ3e,e-e.d�Z4ddddd �Z5e�6e7�Z8d\d"d#�Z9d]d$d%�Z:d&d'�Z;e�<d(�e8j=fe
e0gdfd)�d*d+��Z>d,d-�Z?e$d.�d/d0�Z@d1d2�ZAd^d4d5�ZBd_e	eCe0fd7�d8d9�ZDd:d;�ZEd<d=�ZFeee0eGfe	eHe1fd>�d?d@�ZIeejJe	eHe1fdA�dBdC�ZKdDdE�ZLdFdG�ZMdHdI�ZNdJdK�ZOdLdM�ZPejQdN�dOdP�ZRdQdR�ZSdSdT�ZTd`dUdV�ZUdWdX�ZVdYdZ�ZWe7d[k�r�e�XeUejY��dS)a�N)�Optional�Tuple�Callable�Union)�features�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�r3�4/usr/lib/python3/dist-packages/cloudinit/cmd/main.pyr0Tsr0cCs&|st|�}tjd|ddtd�|S)Nr)FT)Zconsoler-�log)�welcome_formatrZ	multi_log�LOG)�actionr2r3r3r4�welcome^sr9cCstjt��t��t��|d�S)N)r�uptimeZ	timestampr8)�WELCOME_MSG_TPL�formatr�version_stringr
r:Ztime_rfc2822�r8r3r3r4r6es�r6�
Closing stdin)�loggerc	CsRt�tj���sF|d�ttj��}t�|��tj���W5QRXn|d�dS)zj
    reopen stdin as /dev/null to ensure no side effects

    logger: a function for logging messages
    r?z"Not closing stdin, stdin is a tty.N)�os�isattyr,�stdin�fileno�open�devnull�dup2)r@�fpr3r3r4�close_stdinns
"rIcCsTg}|jr*|jD]}|�tj�|j��q|jrP|jD]}|�tj�|j��q6|S�N)�
main_files�appendrA�path�realpath�name�files)�argsZfn_cfgsZfhr3r3r4�extract_fns}s

rR)�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.r7�debug)rS�action_nameZsectionZfull_section_name�	which_ran�failuresZtotal_attemptedr2r3r3r4�run_module_section�s"�
�rZcCs|�d�rt�|�d��dS)Nr)�getrZupdate_configuration)�cfgr3r3r4�apply_reporting_cfg�s
r]��cloud-config-url�urlcCs@t�|�}|D]}||kr|||fSqtd||f��dS)Nz!No keys (%s) found in string '%s')r
Zkeyval_str_to_dict�KeyError)�cmdline�names�data�keyr3r3r4�parse_cmdline_url�s

rfT)�returnc
Cs4|dkrt��}zt|�\}}Wntk
r>tjdfYSX|�d�}|r�tj�	|�r�|r|d||f}tj
}|r�tj}nd||f}tj}||fS|dddd	�}|s�|r�tj}d
|d<ntj}d|d<d}	d
}
�ztj
f|�}d}|���r�d}
t|tj��rHz|t|jt|
�d��7}Wntk
�r4YnX|�|
��sZd}
n|j�|
��sZd}
|
�r�|dk�r�tjddddd�WSn2|dk�r�tj}ntj
}|d|�dt|
���fWSn|d||jffWS||j}	Wn:tjk
�r}z|d||ffWY�Sd}~XYnXtj||	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`ZtimeoutZretries�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_cmdlinerfra�logging�DEBUG�
startswithrArM�exists�INFO�WARNrZread_file_or_url�ok�
isinstanceZUrlResponse�nextZiter_contentrU�
StopIteration�contentsr�	deprecate�str�codeZUrlError�
write_file)rM�networkrbZcmdline_namer`Z
path_is_local�m�level�kwargsrd�headerZrespZsniffed_contentZis_cloud_cfg�er3r3r4�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.%drdzpython-versionz-Python version change detected. Purging cacheTZobj_pklzMWriting python-version file. Cache compatibility status is currently unknown.N)r,�version_info�major�minorrArM�join�paths�	get_cpathrvr
�load_text_filer7rV�purge_cacher��
get_ipath_cur�info)r%Zcurrent_python_versionZpython_version_pathZcached_python_versionr3r3r4�$purge_cache_on_python_version_changes&�
�


�r�cCst�|jd�rdS|jS)NZdisable_network_activationF)r
�get_cfg_option_boolr\�local)r%rQr3r3r4�_should_bring_up_interfaces:sr�)�
raw_configrgc
Cs|sdSt�|��dd��dkr&dSzt�|�}Wn>tk
rr}z ttdtj	d|fd�WY�d	Sd}~XYnXt
|t�s�d
Sd|kr�|dD]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_levelr2rQ)Tz!failed to parse user data as yaml)Tz(parsed config not in cloud-config formatZwrite_files�sourceZurir()rhzfile:)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�	Exceptionrr7rs�WARNINGrz�dictr[ru)r�Zparsed_yamlr��itemZsource_dictZ
source_urir3r3r4�_should_wait_via_user_data@sD���

r�)�
datasourcergcCs�|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_reasonr3r3r4�_should_wait_on_network|s(	����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<tk
r�d	}t�t|�t|���tj|f�YnX|j�rt�d
�t��|j�s,t�|j�t |j�t!||d�t�"dt�#�|��D]\}	}t�$|	|��qNz|�%�Wn"tk
�r�t�td
�YnX|j&}
t'|�|j�r�tj(ntj)}|tj)k�rt*j+�r�tj�,|j&�-d���s�t�d�|j.�/�d}t0j1�2dt3�4��nZd}t�5|jdd�}
|
�r:t�d�d}n(|
�6d�}tj�,|��rbt�d|�d}|�7�t8||�}zD|j9|d�|tj)k�r�|j:j;|k�r�t�d||j:�dgfWSWn�tj<k
�rH|tj(k�r�t�d�nt�td�|j=�s8|j>|d�t�d|�|tj(k�r(dgfYSddgfYSnt�d|�YnXt?|�|�@�}t�d ||||�A��|tj(k�r�tB|d!d"d#�|j>|d�|tj(k�r$t*j+�r�tC|j:�\}}|�r�t�d$|�n t�d%|�t�D|j&�-d�d&�|j:j;|k�rt�d'||j:�|j:gfSt�d(||j:�|�E�|�F�tB|d)d*d#�z2|�G�jHd+|jItJgtJd,�\}}|�sr|�ItK�Wn.tk
�r�t�td-�|j:d-gfYSX|j&�6d.�}tj�,|��r�t�L|�jMd/k�r�tNtO�Pt�Q|��ddd0d1�n
t�d2�t |j�tR|t|�|jd3�}zR|}|}t�|j|�\}}||k�sF||k�rft�Sd4||�t�|j|�\}}Wn"tk
�r�t�td5�YnXt�|j�|�T�tU|j:|jd6�|j:tV|||�fS)7Nz%s.dz91_kernel_cmdline_url.cfg)rMr�r$r%�Zds_deps�reportercs��tj|f�SrJ)rLrsrtr1�Z
early_logsr3r4�<lambda>�rmzmain_init.<locals>.<lambda>�#Failed to setup output redirection!�@Logging being reset, this logger may no longer be active shortlyr1�!PID [%s] started cloud-init '%s'.z0Failed to initialize, likely bad things to come!z
.skip-networkz4Will wait for network connectivity before continuing�trustr)ZcheckZmanual_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)rQZfreqzConsuming 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\)Wr	ZDEP_FILESYSTEMZDEP_NETWORKr�r�rArMr�r r6r�Initr��read_cfgrR�skip_log_setuprIr
�fixup_outputr\Zget_output_cfgr��logexcr7r0rLrsrxrVr�
reset_logging�
setup_loggingr]r9r��getppidr5Z
initializer�r�ZDSMODE_LOCALZDSMODE_NETWORKrZMANUAL_NETWORK_WAITrv�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_warnrZ)rOrQZdeps�bootstage_name�w_msgr%ZoutfmtZerrfmtr2ZlvlZpath_helperrrr�ZmcfgZmfileZbring_up_interfacesZiidZshould_wait�reasonZranZ_resultsZcloud_cfg_pathrSZoutfmt_origZerrfmt_origr3r�r4�	main_init�sN����

�




���
����
��
 �

r�cCs�d|krt�d�dS|d}|dkr4t�d�dSt|t�sNt�d|�dS|�d�}|dkrnt�d�dSt|t�s�t�d|�dS|j�d�d	}|�	t
j�r�|tt
j�d�}nt�d
||�||kr�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�.rjz1Datasource '%s' came from unexpected module '%s'.z:used datasource '%s' from '%s' was in di_report's list: %sZdsid_missing_source)r��dslist)r7rVrzr�r�r[�list�
__module__�
rpartitionrur	Z	DS_PREFIXrUrZshow_warningr)r�r\Zdicfgr��modnamer3r3r4r��sN





���r�cCsd|j}d||f}t|�}tjg|jd�}|�t|��z|jdd�WnBtj	k
r�d|}t
�t|�t
|�|js�|gYSYnXt|�t|t|�|jd�}z|js�t�t
�|j|�Wn tk
r�t
�td�YnX|j�rt�d�t��|j�s t�|j�t|j�t||d	�t�d
t��|�|dk�rXtj 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�r1r�r%z
`--mode init`�24.1�Use `cloud-init init` instead.)rorprq)"rrr6rr�r�r�rRr�r	r�r
r�r7r0r�r�rr�rIr�r\r�rVrr�r�r]r9r�rAr�rr~rZ)rWrQrOr�r�r%r2rSr3r3r4�main_modules�sR���

�r�c
Cs�|j}t|�}tjg|jd�}|�t|��z|jdd�Wn6tj	k
rrt
�td�t
d�|jsnYdSYnXt|�t|t|�|jd�}|j}|r�t�d|�|j}|r�t�d|�t�|�}zt�t
�|jd�Wn tk
r�t
�td	�YnX|j�rt�d
�t��t�|j�t|j�t||d�|�|||�\}}	|	�rdt� d|�dS|�szt� 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�r1zRan %s but it failed!zDid not run %s, does it exist?r)!rOr6rr�r�r�rRr�r	r�r
r�r7r0r�r�r�module_argsrVZ	frequency�FREQ_SHORT_NAMESr[rIr�r\r�rr�r�r]r9Z
run_singler�)
rOrQ�mod_namer�r%rSZmod_argsZmod_freqrXrYr3r3r4�main_singles\	��
�
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|��|tkr�td	�|���giddd
�}
dd|
��|
��|
��|
��d�i}|dk�r"||||fD]}t	�|��qn,zt�t	�|��}Wntk
�rLYnX||dk�rl|
��|d|<|d}||d
<||d�r�||d�s�t�dt|�tt	���||d<ttdd�|	j��}|��}t� ||�t	j!tj�"||�|dd��zzX|||�}|dk�r8|\}}|dk	�r<t'|�|d<n|}||d�(dd�|D��Wn�tk
�r�}z2t�)d|�t*d|�||d�+t'|��W5d}~XYndt,k
�r}zD|j-�r�t�)d|�t*d|�||d�+dt'|j-��d��W5d}~XYnXW5tt	���||d<d|d
<|��}|�#�|�$�D]J}||k�r|t%t&||||��||d|<n||||d|<�qHt� ||�X|dk�r*g}|�$�D]<}t.||t/��r�||�0d��r�|�(||�0dg���q�t� |d|d|d �i�t	j!tj�"||�|dd�t1||d�S)!Nrdzstatus.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�SrJ)rzrZLogExporter)�hr3r3r4r��rmz status_wrapper.<locals>.<lambda>T)r�r�)r%r$r�r�cSsg|]}t|��qSr3)r)�.0r�r3r3r4�
<listcomp>�sz"status_wrapper.<locals>.<listcomp>zfailed stage %szfailed run of stage %sz	sys.exit(z) calledr')r�r�)2rr�rArM�normpathZrun_dirr�rs�	getLoggerr
Zensure_dirsr8r�rr�
ValueError�
STAGE_NAMEr<�copyZdel_file�json�loadsr�r�r7r��floatr:r{�filterrZexport_logsrZ
write_jsonZsym_link�relpathZ
clean_logs�keysr��setr�extendZ	exceptionr0rL�
SystemExitr�rzr�r[rU)rOrQr�Zdata_dZlink_dZstatus_pathZstatus_linkZresult_pathZresult_linkZroot_logger�_name�functorrrZ
nullstatus�status�fr�ZhandlerZpreexisting_recoverable_errorsZnew_recoverable_errorsreZretr�r�r�r�r3r3r4�status_wrapperRs�
��
����	
����


 &6
����
 ��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�rArMrvZpersist_instance_data)r%Zinstance_data_filer3r3r4r��sr�c
Csx|��}tj|j|dd�\}}}|rtzt�d|j|d�Wn8tjk
rr}zt�d||t	|��W5d}~XYnXdS)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\rZhandleZSetHostnameErrorr7rVr)r%r�r�ZcloudZhostnameZ_fqdn�_r�r3r3r4r��s ��r�cCs tj�d�ttj��d�dS)Nr*)r,�stdoutr.r��sortedrZFEATURES)rOrQr3r3r4�
main_featuressr�c	Cst��|stj}tj|�d�d�}|jddddt�	�dd�|jd	d
ddd
d�|jdddddt�
d�d�|jddddd
d�|jddddd
d�|jdd�|jdd d!�}|j
d"d#d$�}|jd%d&dd'd
d�|jdddd(d)t�
d�d�|jd"tfd*�|j
d+d,d$�}tjd-d.d/d0d1�j}|jd2d3d4d5|��d6d7d8�|jdddd(d)t�
d�d�|jd+tfd*�|j
d9d:d$�}|jd;d<d4d=d0d>�|jd?d4d@d
tt���dA�|jdBddCd
d>�|jdDdEdFdGdH�|jdddd(d)t�
d�d�|jd9tfd*�|j
dIdJd$�}|j
dKdLd$�}|jdKtfd*�|j
dMdNd$�}	|j
dOdPd$�}
|j
dQdRd$�}|j
dSdTd$�}|j
dUdVd$�}
|j
dWdXd$�}|�r�tdYdZ�|D�d�}|dMk�r�dd[lm}||	��q�|dOk�r�dd[lm}||
��q�|dQk�rdd\lm}m}||d]�|jdQ|fd*�n�|dSk�r@dd^lm}m}||�|jdS|fd*�n�|dIk�rtdd_l m}m!}||�|jd`|fd*�nf|dWk�r�ddal"m}m#}||�|jdW|fd*�n2|dUk�r�ddbl$m}m%}||
�|
jdU|fd*�n
|�&dc�|j'|dd�}t(|ded
�|j)�st*|�St)|�S)fNr)�progz	--versionz-vrz	%(prog)s z'Show program's version number and exit.)r8r�helpz--debugz-d�
store_truez:Show additional pre-action logging (default: %(default)s).F)r8r��defaultz--filez-frLrKzPUse additional yaml configuration files for subcommands: init, modules or single�rb)r8�destr��typez--forcezDForce running even if no datasource is found (use at your own risk).r�)r8r�rr�z--all-stages�
all_stageszsRun cloud-init's stages under a single process using a syncronization protocol. This is not intended for CLI usage.)rr8r�r�r�ZSubcommands�
subcommand)�titlerr%z2Initialize cloud-init and perform initial modules.)r��--localz-lz+Start in local mode (default: %(default)s).rPz(Use additional yaml configuration files.r>r�z1Activate modules using a given configuration key.z`init`r�r�Trnz--modez-mZstorez9Module configuration name to use (default: %(default)s). r�)r%r��final)r8r�r��choices�singlezRun a single module.z--namez-nzModule name to run.)r8r��requiredz--frequencyzModule frequency for this run.)r8r�r	rz--reportzEnable reporting.r��*Zargumentz0Any additional arguments to pass to this module.)�nargs�metavarr�Zqueryz;Query standardized instance metadata from the command line.rzList 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�Zposargr3r3r4�	<genexpr>�s
zmain.<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�rQr�)+rZconfigure_root_loggerr,�argv�argparse�ArgumentParser�pop�add_argumentrr=ZFileTypeZset_defaultsZadd_subparsersZ
add_parserr�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_parserrrQr3r3r4�mains�
��������
������
�������������



�




r"c	CsJt�d�t�dddd�}t�d�|d��&|jddgd	�}d
|_t|�|_W5QRX|d��$|jdgd	�}d|_t|�|_W5QRX|d��&|jdd
gd	�}d|_t|�|_W5QRX|d��&|jddgd	�}d|_t|�|_W5QRX|j	�r2d}|j
�rd|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�rzREADY=1r%rrFTr�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=CompletedN)r7r�r
Z
SocketSyncZ	sd_notifyrr�r!Zsystemd_exit_codeZexperienced_any_errorZfirst_exception)r�syncrQrr3r3r4r
s<






�

rc
CsV|j\}}|dkr,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�.t�d|�d���|||�}W5QRXW5QRXt��d|k�rRd|j	k�rRt|�}|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: '�')r8rZsetup_basic_loggingrVrsrtr�rZattach_handlersrrr�r�rOZreportrZReportEventStackr�rZTimedrZflush_eventsrU)rQrOr�ZrnameZ	report_onZrdescZretvalr3r3r4r!HsP
�

���r!�__main__)r()N)r^)TN)N)Zrr�rAr,r/rsr��typingrrrrZ	cloudinitrrrr	r
rrr
rrrrrrrZ
cloudinit.logrrZcloudinit.cmd.develrZcloudinit.configrZcloudinit.config.modulesrrrZcloudinit.lifecyclerZcloudinit.reportingrZcloudinit.settingsrrrr rZReasonr;rTr�r�r��__name__r7r0r9r6ZtimedrVrIrRrZr]rf�intr�r�r��bytes�boolr�Z
DataSourcer�r�r�r�r�r�r�r�r�r�r"rr!�exitrr3r3r3r4�<module>s����



	 
m
�=
�%y2AF
~;E


Zerion Mini Shell 1.0