%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/status.cpython-36.pyc

3

�Ad�#�@sldZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZddlmZddlmZddlmZddlmZdd	lmZmZmZd
Zej Gdd�dej!��Z"ej Gd
d�dej!��Z#e$e#j%e#j&e#j'g�Z(Gdd�de�Z)dZ*ddd�Z+e,d�dd�Z-ee#e.fd�dd�Z/d eee)d�dd�Z0dd�Z1e2dk�rhe1�dS)!zFDefine 'status' utility and handler as part of cloud-init commandline.�N)�gmtime�sleep�strftime)�Any�Dict�List�
NamedTuple�Optional�Tuple�Union)�safeyaml)�read_cfg_paths)�uses_systemd)�Paths)�get_cmdline�	load_file�	load_jsonz/etc/cloud/cloud-init.disabledc@s$eZdZdZdZdZdZdZdZdS)�UXAppStatusz=Enum representing user-visible cloud-init application status.znot runZrunning�done�error�disabledN)	�__name__�
__module__�__qualname__�__doc__�NOT_RUN�RUNNING�DONE�ERROR�DISABLED�r r �6/usr/lib/python3/dist-packages/cloudinit/cmd/status.pyrsrc@s,eZdZdZdZdZdZdZdZdZ	dZ
d	S)
�UXAppBootStatusCodez<Enum representing user-visible cloud-init boot status codes.zdisabled-by-generatorzdisabled-by-kernel-cmdlinezdisabled-by-marker-filezenabled-by-generatorzenabled-by-kernel-cmdlinezenabled-by-sysvinit�unknownN)rrrr�DISABLED_BY_GENERATOR�DISABLED_BY_KERNEL_CMDLINE�DISABLED_BY_MARKER_FILE�ENABLED_BY_GENERATOR�ENABLED_BY_KERNEL_CMDLINE�ENABLED_BY_SYSVINIT�UNKNOWNr r r r!r"'sr"c@s.eZdZUeeee	e
eee
dS)�
StatusDetailsN)rrrr�statusr"�boot_status_code�str�descriptionr�errors�last_updater	�
datasourcer r r r!r+=s
r+z@boot_status_code: {boot_code}
{last_update}detail:
{description}cCsX|stjddd�}|jdtdddgddd	�|jd
ddd
dd�|jdddd
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.
    r,zReport run status of cloud init)�progr/z--format�json�tabular�yamlz5Specify 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)�actionr9r:z-wz--waitz'Block waiting on cloud-init to complete)�argparse�ArgumentParser�add_argumentr.)�parserr r r!�
get_parserLs,	
rA)�returncCs\t�}t|�}|jr\xF|jtjtjfkrZ|jdkrHtj	j
d�tj	j�t|�}td�qW|j
|jj|jj|j|j|jd�}dtj|�i|d<d|d<|jdk�r|jr�dnd	}t|�d
|jj���|j�rF|jr�d|j�d�}nd	}ttj||jj|j|d��n>|jd
k�r,ttj|dddd��n|jdk�rFttj|��|jtjk�rXdSdS)z4Handle calls to 'cloud-init status' as a subcommand.r5�.g�?)r2r-r,Zdetailr0r1�1ZschemasZ_schema_version�
�zstatus: z
last_update: )�prefixZ	boot_coder/r1r4�T�,�: )�indentZ	sort_keysZ
separatorsr6�r)rIrJ)r
�get_status_details�waitr,rrr�format�sys�stdout�write�flushrr2r-�valuer/r0r1�copy�deepcopy�printZlong�TABULAR_LONG_TMPLr4�dumpsrr)�name�args�pathsZdetailsZdetails_dictrGr1r r r!�handle_status_argstsJ


r]cCs�t�j�}t�stj}d}n�d|kr0tj}d}n�tjj|�rNtj	}dj
|�}nfd|krbtj}d}nRtjjtjj|j
d��r�tj}d}n.tjjtjj|j
d	��r�tj}d
}n
tj}d}||fS)a
Report 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.
    @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}zcloud-init=disabledz;Cloud-init disabled by kernel parameter cloud-init=disabledrz+Cloud-init disabled by cloud-init-generatorZenabledz2Cloud-init enabled by systemd cloud-init-generatorz'Systemd generator may not have run yet.)r�splitrr"r)r(�os�path�existsr&rOr%�join�run_dirr$r'r*)Zdisable_filer\Z
cmdline_partsZbootstatus_code�reasonr r r!�get_bootstatus�s,
re)r\rBcCs�|pt�}tj}g}d}i}tjj|jd�}tjj|jd�}tt|�\}}|t	krXtj
}tjj|�r�tjj|�svtj}t
t|��jdi�}d}	x�t|j��D]�\}
}|
dkr�|r�tj}dj|�}q�|
dk�r|d	kr�|}q�|}|jd
�\}}
}
|j�jdd�}q�t|t�r�|j|jdg��|jd��p*d}|jd
��p:d}|dk�rV|dk�rVtj}t||�}||	kr�|}	q�W|�r�tj}dj|�}n|tjk�r�|	dk�r�tj}|	�r�tdt|	��nd}t||||||�S)z�Return a dict with status, details and errors.

    @param paths: An initialized cloudinit.helpers.paths object.

    Values are obtained from parsing paths.run_dir/status.json.
    rFzstatus.jsonzresult.jsonZv1rZstagezRunning in stage: {0}r2N� r0�start�finishedrEz%a, %d %b %Y %H:%M:%S %z)r
rrr_r`rbrcre�CLOUDINIT_DISABLED_FILE�DISABLED_BOOT_CODESrrarrr�get�sorted�itemsrO�	partition�lower�replace�
isinstance�dict�extend�maxrrrrr+)r\r,r0r2Z	status_v1Zstatus_fileZresult_filer-r/Zlatest_event�keyrTZds�_rgrhZ
event_timer1r r r!rM�s\



rMcCst�}tjtd|j���dS)z$Tool to report status of cloud-init.r,N)rArP�exitr]�
parse_args)r@r r r!�mainsry�__main__)N)N)3rr=rU�enumr4r_rPZtimerrrZtypingrrrrr	r
rZ	cloudinitrZcloudinit.cmd.develr
Zcloudinit.distrosrZcloudinit.helpersrZcloudinit.utilrrrri�unique�Enumrr"�	frozensetr$r%r&rjr+rXrA�intr]r.rerMryrr r r r!�<module>s>$




(2!A


Zerion Mini Shell 1.0