관리-도구
편집 파일: main.cpython-39.opt-1.pyc
a ����'�Dg������������������������@���s���d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlmZm Z m Z mZ�d�dlm Z �d�dlmZ�d�dlmZ�d�dlmZ�d�dlmZ�d�dlmZ�d�d lmZ�d�d lmZ�d�dlmZ�d�dlmZ�d�d lmZ�d�dlmZ�d�dlmZ�d�dlmZ�d�dlmZmZ�d�dlmZ�d�dl m!Z!�d�dl"m#Z#�d�dl$m%Z%�d�dl&m'Z'�d�dl(m)Z)�d�dl*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/gdf�d)�d*d+��Z=d,d-��Z>e#d.�d/d0�Z?d1d2��Z@d^d4d5�ZAd_e eBe/f�d7�d8d9�ZCd:d;��ZDd<d=��ZEeee/eFf��e eGe0f�d>�d?d@�ZHeejI�e eGe0f�dA�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 StagezConfig StagezFinal Stage)� init-local�init�modules-config� modules-final��c�����������������C���sV���|�rt�j�d|����t�j�d��t�j�d��tjt�jd��t�j�d��t�j�d��d�S�)N�%s z<------------------------------------------------------------� )�file)�sys�stderr�write� traceback� print_exc��msg��r2����6/usr/lib/python3.9/site-packages/cloudinit/cmd/main.pyr/���T���s����r/���c�����������������C���s&���|st�|��}tjd|�ddtd��|S�)Nr(���FT)Zconsoler,����log)�welcome_formatr���Z multi_log�LOG)�actionr1���r2���r2���r3����welcome^���s����r8���c�����������������C���s���t�jt���t���t���|�d�S�)N)r����uptimeZ timestampr7���)�WELCOME_MSG_TPL�formatr����version_stringr���r9���Ztime_rfc2822�r7���r2���r2���r3���r5���e���s�����r5���� Closing stdin)�loggerc�����������������C���sf���t��tj����sZ|�d��tt�j��&}t��|���tj�����W�d����qb1�sN0����Y��n|�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?����fpr2���r2���r3����close_stdinn���s ����6rH���c�����������������C���s.���g�}|�j�r*|�j�D�]}|�tj�|j���q|S��N)�files�appendr@����path�realpath�name)�argsZfn_cfgsZfhr2���r2���r3����extract_fns}���s ���� rP���)�modsc�����������������C���sv���t�|�}|��|�\}}t|�t|��}|dkrXd||f�}tj�d|���t�|��g�S�t�dt|�t|���|S�d�S�)Nr���z)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_attemptedr1���r2���r2���r3����run_module_section����s����� �rY���c�����������������C���s���|���d�rt�|���d���d�S�)Nr���)�getr���Zupdate_configuration)�cfgr2���r2���r3����apply_reporting_cfg����s���� r\�����cloud-config-url�urlc�����������������C���s@���t��|��}|D�]}||v�r|||�f��S�qtd|�|f���d�S�)Nz!No keys (%s) found in string '%s')r���Zkeyval_str_to_dict�KeyError)�cmdline�names�data�keyr2���r2���r3����parse_cmdline_url����s ���� re���T)�returnc�������������� ���C���s2��|du�rt����}zt|�\}}W�n�ty<���tjdf�Y�S�0�|�d�}|r�tj� |��r�|rzd|�|f�}tj }|r�tj}nd|�|f�}tj}||fS�|dddd �}|s�|r�tj}d |d<�ntj}d|d<�d} d } �ztj f�i�|��}d}|����r�d} t|tj��rHz|t|jt| �d��7�}W�n�t�y4���Y�n0�|�| ��sZd} n|j�| ��sZd} | �r�|dk�r�tjddddd�W�S�n2|dk�r�tj}ntj }|d|��dt| ����fW�S�n|d||jf�fW�S�||j�} W�n8�tj�y�}�z|d||f�fW��Y�d}~S�d}~0�0�t�j|�| dd��tj d|||�f�fS�)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_cmdlinere���r`����logging�DEBUG� startswithr@���rL����exists�INFO�WARNr���Zread_file_or_url�ok� isinstanceZUrlResponse�nextZiter_contentrS���� StopIteration�contentsr���� deprecate�str�codeZUrlError� write_file)rL����networkra���Zcmdline_namer_���Z path_is_local�m�level�kwargsrc����headerZrespZsniffed_contentZis_cloud_cfg�er2���r2���r3����attempt_cmdline_url����s����� ���� � � ��&��r����c�����������������C���s����dt�jjt�jjf�}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.%drc���zpython-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_cpathrv���r����load_text_filer6���rT����purge_cacher����� get_ipath_cur�info)r$���Zcurrent_python_versionZpython_version_pathZcached_python_versionr2���r2���r3����$purge_cache_on_python_version_change��s$������ �r����c�����������������C���s���t��|�jd�rdS�|j�S�)NZdisable_network_activationF)r����get_cfg_option_boolr[����local)r$���rO���r2���r2���r3����_should_bring_up_interfaces5��s����r����)� raw_configrf���c�������������� ���C���s����|�sdS�t��|����dd���dkr&dS�zt�|��}W�n:�tyn�}�z"ttdtj d|d��W�Y�d}~d S�d}~0�0�d |v�r�|d �D�]2}|� d�p�i�}|� dd �}|r�|�d�s��dS�q�dS�|� d�r�dS�|� di��� d�r�dS�|� d�r�dS�dS�)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?���r���Zrequested_levelr1���rO���)Tz!failed to parse user data as yamlZwrite_files�sourceZurir'���)rg���zfile:)Tz!write_files with source uri found)Fz$write_files without source uri foundZbootcmd)Tz bootcmd foundZrandom_seedZcommand)Tzrandom_seed command foundZmounts)Tzmounts found)Fz8cloud-config does not contain network requiring elements)r���Ztype_from_starts_with�strip�yaml� safe_load� Exceptionr���r6���rs����WARNINGrZ���ru���)r����Zparsed_yamlr�����itemZsource_dictZ source_urir2���r2���r3����_should_wait_via_user_data;��s@������� r����)� datasourcerf���c�����������������C���s����|�sdS�t�|�����\}}|r*d|��d�fS�t�|�����\}}|rLd|��d�fS�t�|�����\}}|rnd|��d�fS�dd|��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_reasonr2���r2���r3����_should_wait_on_networkp��s0���� ������r����c��������������������s���t�jt�jg}|jrt�jg}ttj�dt�d�|j�d�g��|jrDdnd}t |�}t j||jd�}|� t|���d�}d�}z@|js�t��fdd���t�|j|��\}}nt�|j|��\}}W�n:�ty����d }t�t|��t|�����tj|f��Y�n0�|j�rt�d ��t����|j�s*t�|j��t |j��t!|�|d��t�"dt�#��|����D�]\} }t�$| |���qLz|�%���W�n �t�y����t�td ��Y�n0�|j&} t'|��|j�r�t�j(nt�j)}|t�j)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��|t�j)k�r�|j8j9|k�r�t�d||j8��d�g�fW�S�W�n��t�j:�y:���|t�j(k�r�t�d��nt�td��|j;�s*|j<|d��t�d|��|t�j(k�rd�g�f�Y�S�d�dgf�Y�S�nt�d|��Y�n0�t=|��|�>��}t�d ||�||�?����|t�j(k�r|t@|d!d"d#��|j<|d��|t�j(k�rtA|j8�\}}|�r�t�d$|��n t�d%|��t�B|j&�+d�d&��|j8j9|k�r�t�d'||j8��|j8g�fS�t�d(||j8��|�C���|�D���t@|d)d*d#��z2|�E��jFd+|jGtHgtHd,�\}}|�s\|�GtI��W�n,�t�y����t�td-��|j8d-gf�Y�S�0�|j&�4d.�}tj�*|��r�t�J|�jKd/k�r�tLtM�Nt�O|��ddd0d1��n t�d2��t |j��tP|t|�|jd3�}zR|}|}t�|j|��\}}||k�s.||k�rNt�Qd4||��t�|j|��\}}W�n �t�yp���t�td5��Y�n0�t�|j��|�R���tS|j8|jd6��|j8tT||�|��fS�)7Nz%s.dz91_kernel_cmdline_url.cfg)rL���r����r#���r$����Zds_deps�reporterc��������������������s�������tj|�f�S�rI���)rK���rs���rt���r0����Z early_logsr2���r3����<lambda>���rm���zmain_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)rO���ZfreqzConsuming user data failed!Zcloud_configr���T)�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[���)Ur���ZDEP_FILESYSTEMZDEP_NETWORKr����r����r@���rL���r����r���r5���r ����Initr�����read_cfgrP����skip_log_setuprH���r����fixup_outputr[���Zget_output_cfgr�����logexcr6���r/���rK���rs���rx���rT���r���� reset_logging� setup_loggingr\���r8���r�����getppidr4���Z initializer����r����ZDSMODE_LOCALZDSMODE_NETWORKrv����get_runpathZdistroZwait_for_networkr+���r,���r-���r���Z 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����r���r����stat�st_sizer���r����r����r����r����warningZactivate_datasource�di_report_warnrY���)rN���rO���Zdeps�bootstage_name�w_msgr$���ZoutfmtZerrfmtr1���ZlvlZpath_helperrr���r����ZmcfgZmfileZbring_up_interfacesZiidZshould_wait�reasonZranZ_resultsZcloud_cfg_pathrQ���Zoutfmt_origZerrfmt_origr2���r����r3���� main_init���sB������� ��� ���� �� � r����c�����������������C���s����d|vrt��d��d�S�|d�}|d�u�r4t��d��d�S�t|t�sNt��d|��d�S�|�d�}|d�u�rnt��d��d�S�t|t�s�t��d|��d�S�|�j�d�d �}|� t j�r�|tt j�d���}nt��d |�|��||v�r�t��d|�||��d�S�t jd||t|�d ��d�S�)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�.ri���z1Datasource '%s' came from unexpected module '%s'.z:used datasource '%s' from '%s' was in di_report's list: %sZdsid_missing_source)r�����dslist)r6���rT���rz����dictr����rZ����list� __module__� rpartitionru���r���Z DS_PREFIXrS���r���Zshow_warningr���)r����r[���Zdicfgr�����modnamer2���r2���r3���r�������sH���� ���r����c�����������������C���s^��|j�}d|�|f�}t|�}tjg�|jd�}|�t|���z|jdd��W�n@�tj y����d|�}t �t|��t |��|js�|g�Y�S�Y�n0�t|��t|t|�|jd�}z|js�t���t �|j|��W�n�ty����t �td��Y�n0�|jr�t�d��t����|j�st�|j��t|j��t||d ��t�d t���|��|dk�rRtj dd dd��t!|||�S�)Nz%s:%sr����r����r����zGCan not apply stage %s, no datasource found! Likely bad things to come!r����r����r����r0���r����r$���z `--mode init`�24.1�Use `cloud-init init` instead.)ro���rp���rq���)"rr���r5���r ���r����r����r����rP���r����r���r����r���r����r6���r/���r����r����r���r����rH���r����r[���r����rT���r���r����r����r\���r8���r����r@���r����r���r~���rY���)rU���rO���rN���r����r����r$���r1���rQ���r2���r2���r3����main_modules���sR������� �r����c����������� ������C���s~��|j�}t|��}tjg�|jd�}|�t|���z|jdd��W�n4�tj yp���t �td��t d��|jslY�dS�Y�n0�t|��t|t|�|jd�}|j}|r�t�d|��|j}|r�t�d|��t�|�}zt���t �|jd���W�n�ty����t �td ��Y�n0�|j�rt�d ��t����t�|j��t|j��t|�|d��|�|||�\}} | �r`t� d|��dS�|�svt� d |��dS�dS�d�S�)Nr����r����r����z;Failed to fetch your datasource, likely bad things to come!rl���r����zUsing passed in arguments %szUsing passed in frequency %sr����r����r0���zRan %s but it failed!zDid not run %s, does it exist?r���)!rN���r5���r ���r����r����r����rP���r����r���r����r���r����r6���r/���r����r����r����module_argsrT���Z frequency�FREQ_SHORT_NAMESrZ���rH���r����r[���r����r���r����r����r\���r8���Z run_singler����) rN���rO����mod_namer����r$���rQ���Zmod_argsZmod_freqrW���rX���r2���r2���r3����main_single���sZ���� �� � r����c�����������������C���s���t���}|�d�}tj�|j�}tj�|d�}tj�|d�}tj�|d�}tj�|d�}t���} t � ||f��|j\} }|�dkr�|jr�d}q�d}n |�dkr�d|j �}ntd|����|tvr�td �|���g�i�d�d�d �} dd�| ���| ���| ���| ���d�i}|dk�r"||||fD�]}t �|���qn*zt�t �|��}W�n�t�yJ���Y�n0�||d�v�rj| ���|d�|<�|d�}||d <�||�d��r�||�d��s�t�dt|���tt ����||�d<�ttdd��| j��}|���}t� ||��t j!tj�"||�|dd���z�zX||�|�}|dv��r6|\}}|d�u�r:t#|�|d<�n|}||�d��$dd��|D����W�n��t�y��}�z:t�%d|��t&d|���||�d��'t#|���W�Y�d�}~nnd�}~0��t(�y�}�zL|j)�r�t�%d|��t&d|���||�d��'dt#|j)���d���W�Y�d�}~n d�}~0�0�W�tt ����||�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�)!Nrc���zstatus.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?c�����������������S���s���t�|�tj�S�rI���)rz���r���ZLogExporter)�hr2���r2���r3���r�������rm���z status_wrapper.<locals>.<lambda>T)r����)r$���r#���r����r����c�����������������S���s���g�|�]}t�|��qS�r2���)r���)�.0r����r2���r2���r3���� <listcomp>���rm���z"status_wrapper.<locals>.<listcomp>zfailed stage %szfailed run of stage %sz sys.exit(z) calledr����r&���)r����r����)2r���r����r@���rL����normpathZrun_dirr����rs���� getLoggerr���Zensure_dirsr7���r����rr���� ValueError� STAGE_NAMEr;����copyZdel_file�json�loadsr����r����r6���r�����floatr9���r{����filterr���Zexport_logsr���Z write_jsonZsym_link�relpathr����extend� exceptionr/���rK���� SystemExitr����Z clean_logs�keysr�����setrz���r����rZ���rS���)rN���rO���r����Zdata_dZlink_dZstatus_pathZstatus_link�result_pathZresult_linkZroot_logger�_name�functorrr���Z nullstatus�status�fr����ZhandlerZpreexisting_recoverable_errors�retr����r����r����Znew_recoverable_errorsrd���r����r2���r2���r3����status_wrapperC��s��� �� ���� � ��� *8 ����� ���� ��r����)r$���c�����������������C���s6���|�j�r2|�jr2|�j�d�}tj�|�s2|�j�jdd��dS�)zCWrite instance-data.json file if absent and datasource is restored.Z instance_dataF)Zwrite_cacheN)r����Zds_restoredr����r����r@���rL���rv���Zpersist_instance_data)r$���Zinstance_data_filer2���r2���r3���r�������s����r����c�������������� ���C���sz���|�����}tj|�j|dd�\}}}|rvzt�d|�j|d��W�n:�tjyt�}�z t�d||t |���W�Y�d}~n d}~0�0�dS�)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_onlyZset_hostnameNzGFailed setting hostname in %s stage. Will retry in %s stage. Error: %s.) r����r���Zget_hostname_fqdnr[���r���ZhandleZSetHostnameErrorr6���rT���r���)r$���r����r����Zcloud�hostnameZ_fqdn�_r����r2���r2���r3���r�������s������r����c�����������������C���s ���t�j�d�ttj��d���d�S�)Nr)���)r+����stdoutr-���r�����sortedr���ZFEATURES)rN���rO���r2���r2���r3���� main_features���s����r����c�������������� ���C���s���t�����|�stj}�tj|��d�d�}|jddddt� ���dd��|jd d ddd d��|jddddd d��|jddddd d��|j d�d��|jddd�}|jddd�}|jdddd d d��|jd!d"d#d$d%t� d&�d'��|j dtfd(��|jd)d*d�}tjd+d,d-d.d/�j}|jd0d1d2d3|���d4d5d6��|jd!d"d#d$d%t� d&�d'��|j d)tfd(��|jd7d8d�}|jd9d:d2d;d.d<��|jd=d2d>d tt����d?��|jd@ddAd d<��|jdBdCdDdEdF��|jd!d"d#d$d%t� d&�d'��|j d7tfd(��|jdGdHd�}|jdIdJd�}|j dItfd(��|jdKdLd�} |jdMdNd�} |jdOdPd�}|jdQdRd�}|jdSdTd�} |jdUdVd�}|��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*|�S�t)|�S�)dNr���)�progz --versionz-vr���z %(prog)s z'Show program's version number and exit.)r7���r����helpz--debugz-d� store_truez:Show additional pre-action logging (default: %(default)s).F)r7���r���defaultz--forcezDForce running even if no datasource is found (use at your own risk).r����)r7���r���destr��z--all-stages� all_stageszsRun cloud-init's stages under a single process using a syncronization protocol. This is not intended for CLI usage.)r��r7���r��r��r����ZSubcommands� subcommand)�titler��r$���z2Initialize cloud-init and perform initial modules.)r���--localz-lz+Start in local mode (default: %(default)s).z--filez-frK���rJ���z(Use additional yaml configuration files.�rb)r7���r��r���typer=���r����z1Activate modules using a given configuration key.z`init`r����r����Trn���z--modez-m�storez9Module configuration name to use (default: %(default)s). r����)r$���r�����final)r7���r��r���choices�singlezRun a single module.z--namez-nzModule name to run.)r7���r���requiredz--frequencyzModule frequency for this run.)r7���r��r��r ��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.zcollect-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.c�����������������s���s���|�]}|��d��s|V��qdS�)�-N)ru���)r����Zposargr2���r2���r3���� <genexpr>���rm���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�rO���r����)+r���Zconfigure_root_loggerr+����argv�argparse�ArgumentParser�pop�add_argumentr���r<����set_defaults�add_subparsers� add_parser�FileTyper����r���r~����messager����r����r����r����r����r����r{���Zcloudinit.analyzer��Zcloudinit.cmd.devel.parserZcloudinit.cmd.devel.logsr��Zcloudinit.cmd.cleanr��Zcloudinit.cmd.queryr���cloudinit.config.schemar��Zcloudinit.cmd.statusr���error� parse_args�setattrr���sub_main)Z sysv_argsr��Z subparsersZparser_initZ parser_modZ extra_helpZ parser_singleZparser_queryZparser_featuresZparser_analyzeZparser_develZparser_collect_logsZparser_cleanZ parser_statusZ parser_schemar��Zanalyze_parserZdevel_parserZlogs_parserr��Zclean_parserr��Zquery_parserZhandle_query_argsZ schema_parserr��Z status_parserr��rO���r2���r2���r3����main��sp��� ������� ������� ������������� � r.��c�����������������C���s���t��d��t�dddd�}t�d��|d��0�|�jddgd �}d |_t|�|_W�d����n1�sb0����Y��|d��.�|�jdgd �}d|_t|�|_W�d����n1�s�0����Y��|d��0�|�jd dgd �}d|_t|�|_W�d����n1�s�0����Y��|d��0�|�jd dgd �}d|_t|�|_W�d����n1��s:0����Y��|j �r�d}|j �rdd|j ���}t�d|��d���t�d��dS�t�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$���r��r��FNTr����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=1rl���zSTATUS=Completed)r6���r����r ���Z SocketSyncZ sd_notifyr+��r����r-��Zsystemd_exit_codeZexperienced_any_errorZfirst_exception)r���syncrO���r(��r2���r2���r3���r�����s<���� ( ( ( * � r��c�������������� ���C���s���|�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�N�t�d|��d����|||��}W�d�����n1��s.0����Y��W�d�����n1��sN0����Y��t����d|k�r~d|�j k�r~t|�}|S�)N)r$���r����r$���r����T)r#���zsearching for local datasources)zinit-networkz!searching for network datasourcesr����zrunning modules for %sr��z single/%szrunning single module %szrunning 'cloud-init %s'F)Zreporting_enabledzcloud-init stage: '�')r7���r���Zsetup_basic_loggingrT���rs���rt���r����r���Zattach_handlersrr���r����r����rN����reportr���ZReportEventStackr����r ���ZTimedr���Zflush_eventsrS���)rO���rN���r����ZrnameZ report_onZrdescZretvalr2���r2���r3���r-��.��sL���� � ���Jr-���__main__)r'���)N)r]���)TN)N)Yr ��r����r@���r+���r.���rs���r�����typingr���r���r���r���Z cloudinitr���r���r���r ���r ���r���r���r ���r���r���r���r���r���r���Z cloudinit.logr���r���Zcloudinit.cmd.develr���Zcloudinit.configr���Zcloudinit.config.modulesr���r)��r���Zcloudinit.lifecycler���Zcloudinit.reportingr���Zcloudinit.settingsr���r���r���r���r���ZReasonr:���rR���r����r����r�����__name__r6���r/���r8���r5���ZtimedrT���rH���rP���rY���r\���re����intr����r����r�����bytes�boolr����Z DataSourcer����r����r����r����r����r����r����r����r����r����r.��r��r-���exitr��r2���r2���r2���r3����<module>���s������� m �6 �%�v2AF� �s;E