Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/cmd/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/cmd/__pycache__/status.cpython-310.pyc
o

TN�f�F�@s\dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
mZmZmZmZmZddlmZmZddlmZddlmZdd	lmZdd
lmZmZmZdZ ej!Gdd
�d
ej"��Z#ej!Gdd�dej"��Z$ej!Gdd�dej"��Z%e&e%j'e%j(e%j)e%j*g�Z+Gdd�de�Z,dZ-dee.de/de.fdd�Z0d@dd�Z1de#de$dee.e.ffdd�Z2d e,fd!d"�Z3de4fd#d$�Z5de/fd%d&�Z6dee%e.ffd'd(�Z7de/fd)d*�Z8de/de/fd+d,�Z9de/fd-d.�Z:de#fd/d0�Z;de.fd1d2�Z<d3d4�Z=d5d6�Z>deeeffd7d8�Z?	9dAd:eede/de,fd;d<�Z@d=d>�ZAeBd?k�r,eA�dSdS)BzGDefine 'status' utility and handler as part of cloud-init command line.�N)�deepcopy)�gmtime�sleep�strftime)�Any�Dict�List�
NamedTuple�Optional�Tuple)�safeyaml�subp)�read_cfg_paths)�uses_systemd)�Paths)�get_cmdline�	load_json�load_text_filez/etc/cloud/cloud-init.disabledc@s eZdZdZdZdZdZdZdS)�
RunningStatusz=Enum representing user-visible cloud-init application status.znot started�running�done�disabledN)�__name__�
__module__�__qualname__�__doc__�NOT_STARTED�RUNNING�DONE�DISABLED�r r �6/usr/lib/python3/dist-packages/cloudinit/cmd/status.pyrsrc@seZdZdZdZdZdZdS)�ConditionStatusz;Enum representing user-visible cloud-init condition status.�error�degraded�healthyN)rrrr�ERROR�DEGRADED�PEACHYr r r r!r"%s
r"c@s0eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
S)�
EnabledStatusz<Enum representing user-visible cloud-init boot status codes.zdisabled-by-generatorzdisabled-by-kernel-command-linezdisabled-by-marker-filez disabled-by-environment-variablezenabled-by-generatorzenabled-by-kernel-command-linezenabled-by-sysvinit�unknownN)rrrr�DISABLED_BY_GENERATOR�DISABLED_BY_KERNEL_CMDLINE�DISABLED_BY_MARKER_FILE�DISABLED_BY_ENV_VARIABLE�ENABLED_BY_GENERATOR�ENABLED_BY_KERNEL_CMDLINE�ENABLED_BY_SYSVINIT�UNKNOWNr r r r!r).sr)c@sreZdZUeed<eed<eed<eed<eeed<e	eeefed<eed<e
eed<e	ee	fed	<d
S)�
StatusDetails�running_status�condition_status�boot_status_code�description�errors�recoverable_errors�last_update�
datasource�v1N)rrrr�__annotations__r"r)�strrrr
r r r r!r3Fs
r3z�extended_status: {extended_status}
boot_status_code: {boot_code}
{last_update}detail: {description}
errors:{errors}
recoverable_errors:{recoverable_errors}�systemctl_args�wait�returncCs@	zt�dg|��j��WStjy|s�td�Ynwq)z-Query systemd with retries and return output.T�	systemctl��?)r
�stdout�strip�ProcessExecutionErrorr)r?r@r r r!�query_systemctlZs��rGcCsV|s	tjddd�}|jdtgd�ddd�|jd	d
ddd
d�|jdddddd�|S)a%Build or extend an arg parser for status utility.

    @param parser: Optional existing ArgumentParser instance representing the
        status subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    �statuszReport run status of cloud init)�progr7z--format)�json�tabular�yamlrKz5Specify output format for cloud-id (default: tabular))�type�choices�default�helpz-lz--long�
store_trueFzJReport long format of statuses including run stage name and error messages)�actionrOrPz-wz--waitz'Block waiting on cloud-init to complete)�argparse�ArgumentParser�add_argumentr>��parserr r r!�
get_parseris4	���
�rXr�	conditioncCs^|tjkrd|j�d|j��fS|tjkr)|tjtjfvr)|j|j�d|j��fS|j|jfS)z�Translate running and condition status to human readable strings.

    Returns (status, extended_status).
    Much of this is for backwards compatibility
    r#z - � )r"r&�valuer'rrr)rrYr r r!�translate_status�s
	�r\�detailsc

Csjt|j|j�\}}|j|jj|||j|j|j|j	d�|j
�}dt|�i|d<d|d<|jdkr�|j
r4dnd}|d}t|�d	|���|jr�|�d
�rTd|d
�d�}nd}|drcd
d
�|d�nd}|drydd�dd�|d��D��nd}	ttj|d||d|d|||	d��dSdS|jdkr�ttj|dddd��dS|jdkr�tt�|��dSdS)zPrint status out to the CLI.)r;r6rH�extended_status�detailr8r9r:�1�schemas�_schema_versionrK�
�rHzstatus: r:z
last_update: r8�
	- z []r9cSs.g|]\}}|�d�d�dd�|D���qS)z:
	- recSsg|]}|�dd��qS)rcrZ)�replace)�.0�ir r r!�
<listcomp>�sz+print_status.<locals>.<listcomp>.<listcomp>)�join)rg�k�vr r r!ri�s���z print_status.<locals>.<listcomp>z {}r^r6r_)r^�prefix�	boot_coder7r:r8r9rJ�T)�,z: )�indent�	sort_keys�
separatorsrLN)r\r4r5r;r6r[r7r8r9r:r<r�formatr@�print�long�getrj�items�TABULAR_LONG_TMPLrJ�dumpsr)
�argsr]rHr^�details_dictrm�stater:�
errors_output�recoverable_errors_outputr r r!�print_status�sv��	�

���
���	����
!��
�r�cCs�t�}t||j�}|jr8|jtjtjfvr8|jdkr%tj	�
d�tj	��t||j�}td�|jtjtjfvst
||�|jtjkrEdS|jtjkrMdSdS)z4Handle calls to 'cloud-init status' as a subcommand.rK�.rC�r)r�get_status_detailsr@r4rrrrt�sysrD�write�flushrr�r5r"r&r')�namer{�pathsr]r r r!�handle_status_args�s,�

��

r�cCs8ztdg|d�}Wd|vStjyd}Yd|vSw)z?Return whether cloud-init is disabled via environment variable.zshow-environment�r@rd�cloud-init=disabled)rGr
rF)r@�envr r r!�_disabled_via_environments��r�cCst���}t�stj}d}||fSd|vrtj}d}||fStj�|�r0tj	}d�
|�}||fSd|vr=tj}d}||fSdtj�
dd�vsNt�rWt|d	�rWtj}d
}||fStj�tj�|jd��rltj}d}||fStj�tj�|jd
��r�tj}d}||fStj}d}||fS)aXReport whether cloud-init current boot status

    @param disable_file: The path to the cloud-init disable file.
    @param paths: An initialized cloudinit.helpers.Paths object.
    @param wait: If user has indicated to wait for cloud-init to complete.
    @returns: A tuple containing (code, reason) about cloud-init's status and
    why.
    zCloud-init enabled on sysvinitzcloud-init=enabledz<Cloud-init enabled by kernel command line cloud-init=enabledzCloud-init disabled by {0}r�z;Cloud-init disabled by kernel parameter cloud-init=disabled�KERNEL_CMDLINErdr�zNCloud-init disabled by environment variable KERNEL_CMDLINE=cloud-init=disabledrz+Cloud-init disabled by cloud-init-generator�enabledz2Cloud-init enabled by systemd cloud-init-generatorz'Systemd generator may not have run yet.)r�splitrr)r1r0�os�path�existsr-rtr,�environrwr�r.rj�run_dirr+r/r2)�disable_filer�r@�
cmdline_parts�bootstatus_code�reasonr r r!�get_bootstatussJ
	��
�����
���r�cCstt��jtvS�N)r�rr6�DISABLED_BOOT_CODESr r r r!�is_cloud_init_enabled8s
��r�cCs�dD]y}ztdd|g|d�}Wn tjy/}ztd|j��tjd�WYd}~dSd}~wwtd	d
�|��D��}|d�d�sK|dd
ksKdS|ddkrj|ddkrXq|ddkrg|ddkrgdSdS|ddksv|ddkrydSdSdS)z2Return if systemd units report a cloud-init error.)zcloud-final.servicezcloud-config.servicezcloud-init.servicezcloud-init-local.service�showz5--property=ActiveState,UnitFileState,SubState,MainPIDr�z^Failed to get status from systemd. Cloud-init status may be inaccurate. Error from systemctl: )�fileNFcSs g|]}dd�|�d�D��qS)cSsg|]}|���qSr )rE)rg�xr r r!riZsz-systemd_failed.<locals>.<listcomp>.<listcomp>�=)r�)rg�rr r r!riZs z"systemd_failed.<locals>.<listcomp>�
UnitFileStater��staticT�ActiveState�active�SubState�exitedr�MainPID�0�failed)	rGr
rFru�stderrr��dict�
splitlines�
startswith)r@�servicerD�e�statesr r r!�systemd_failed?sH�
�����	���r�cCstj�|�otj�|�S)z%Return True if cloud-init is running.)r�r�r�)�status_file�result_filer r r!�
is_runningysr�cCs2|tvrtjSt||�rtjS|dkrtjStjS)z(Return the running status of cloud-init.r)r�rrr�rrr)r�r�r6�latest_eventr r r!�get_running_status~s
r�cCs4|�dd�}|r|�d�\}}}|���dd�}|S)zyGet the datasource from status.json.

    Return a lowercased non-prefixed version. So "DataSourceEc2" becomes "ec2"
    r;rdrZ)rw�	partition�lowerrf)�	status_v1r;�ds�_r r r!�get_datasource�s
r�cCs.|�d�}|r	|S|�d�rd|d��S|S)z�Return a description of the current status.

    If we have a datasource, return that. If we're running in a particular
    stage, return that. Otherwise, return the boot_description.
    r;�stagezRunning in stage: )rw)r��boot_descriptionr;r r r!�get_description�s

r�cCs@d}|��D]}t|t�rt||�d�pd|�d�pd�}q|S)z,Return the latest event time from status_v1.r�start�finished)�values�
isinstancer��maxrw)r�r��
stage_infor r r!�get_latest_event�s
��r�cCs�g}i}t|���D]5\}}t|t�r?|�|�dg��|�di�}|��D]}||vr5t||�||<q&||�||�q&q
||fS)z>Return a list of errors and recoverable_errors from status_v1.r8r9)�sortedrxr�r��extendrw�keysr)r�r8r9�_keyr��current_recoverable_errors�err_typer r r!�
get_errors�s$
�
���r�Fr�c
Cstj}|pt�}tj�|jd�}tj�|jd�}tt||�\}}i}tj�	|�r2t
t|���di�}t
|�}t||�}	t|�}
|
rHtdt|
��nd}t|�\}}
|rVtj}n|
r[tj}t||||
�}|tjkr|t�r|t|d�r|tj}tj}d}	|�d�|�d	d
�t||||	||
|||�	S)aReturn a dict with status, details and errors.

    @param paths: An initialized cloudinit.helpers.paths object.
    @param wait: If user has indicated to wait for cloud-init to complete.

    Values are obtained from parsing paths.run_dir/status.json.
    zstatus.jsonzresult.jsonr<z%a, %d %b %Y %H:%M:%S %zrdr�z"Failed due to systemd unit failurez�Failed due to systemd unit failure. Ensure all cloud-init services are enabled, and check 'systemctl' or 'journalctl' for more information.r;N)r"r(rr�r�rjr�r��CLOUDINIT_DISABLED_FILEr�rrrwr�r�r�rrr�r&r'r�rrrr�r�append�popr3)r�r@r5r�r�r6r�r�r;r7r�r:r8r9r4r r r!r��s`

�
���
����r�cCst�}t�td|����dS)z$Tool to report status of cloud-init.rHN)rXr��exitr��
parse_argsrVr r r!�mainsr��__main__r�)NF)CrrS�enumrJr�r��copyr�timerrr�typingrrrr	r
r�	cloudinitrr
�cloudinit.cmd.develr�cloudinit.distrosr�cloudinit.helpersr�cloudinit.utilrrrr��unique�Enumrr"r)�	frozensetr+r,r-r.r�r3ryr>�boolrGrXr\r��intr�r�r�r�r�r�r�r�r�r�r�r�r�rr r r r!�<module>s� 	
��
��
�
(��

�E	*:
�
���
�G

�

Spamworldpro Mini