%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/status.cpython-35.pyc



"�T`��@s�dZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZddlm
Z
mZmZdZdZd	Zd
ZdZdZdd
d�Zdd�Zdd�Zdd�Zdd�Zedkr�e�dS)zFDefine 'status' utility and handler as part of cloud-init commandline.�N)�gmtime�strftime�sleep)�uses_systemd)�Init)�get_cmdline�	load_file�	load_jsonz/etc/cloud/cloud-init.disabledznot runZrunning�done�errorZdisabledc	Csf|stjdddd�}|jddddd	d
dd�|jd
dddd	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.
    �prog�statusZdescriptionzReport run status of cloud initz-lz--long�action�
store_true�defaultF�helpzJReport long format of statuses including run stage name and error messagesz-wz--waitz'Block waiting on cloud-init to complete)�argparse�ArgumentParser�add_argument)�parser�r�6/usr/lib/python3/dist-packages/cloudinit/cmd/status.py�
get_parsers			rcCstdg�}|j�t|j�\}}}|jr�xU|ttfkr�tjj	d�tjj
�t|j�\}}}td�q=Wtjj	d�|jr�t
dj|��|r�t
dj|��t
dj|��nt
dj|��|tkrdSd	S)
z4Handle calls to 'cloud-init status' as a subcommand.Zds_deps�.g�?�
zstatus: {0}z	time: {0}zdetail:
{0}�r)rZread_cfg�_get_status_details�paths�wait�STATUS_ENABLED_NOT_RUN�STATUS_RUNNING�sys�stdout�write�flushrZlong�print�format�STATUS_ERROR)�name�argsZinitr
�
status_detail�timerrr�handle_status_args1s"
	
	r,cCs�d}t�j�}t�s'd}n�d|kr<d}n~tjj|�rfd}dj|�}nTd|kr�d}d}n9tjjtjj|jd	��s�d}d
}nd}||fS)aReport whether cloud-init is disabled.

    @param disable_file: The path to the cloud-init disable file.
    @param paths: An initialized cloudinit.helpers.Paths object.
    @returns: A tuple containing (bool, reason) about cloud-init's status and
    why.
    FzCloud-init enabled on sysvinitzcloud-init=enabledz<Cloud-init enabled by kernel command line cloud-init=enabledTzCloud-init disabled by {0}zcloud-init=disabledz;Cloud-init disabled by kernel parameter cloud-init=disabledZenabledz+Cloud-init disabled by cloud-init-generatorz2Cloud-init enabled by systemd cloud-init-generator)	r�splitr�os�path�existsr&�join�run_dir)Zdisable_filer�is_disabledZ
cmdline_parts�reasonrrr�_is_cloudinit_disabledIs"				$	r5cCst}d}i}tjj|jd�}tjj|jd�}tt|�\}}|rit}|}tjj|�r�tjj|�s�t	}t
t|��jdi�}g}d}	x�t
|j��D]�\}
}|
dkr|r�t	}dj|�}q�|
dkr|}q�t|t�r�|j|jd	g��|jd
�pUd}|jd�pjd}
|
dkr�|dkr�t	}t||
�}||	kr�|}	q�W|r�t}dj|�}n|tkr�|	dkr�t}|	r
td
t|	��}nd}|||fS)z�Return a 3-tuple of status, status_details and time of last event.

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

    Values are obtained from parsing paths.run_dir/status.json.
    �zstatus.jsonzresult.jsonZv1rZstagezRunning in stage: {0}Z
datasource�errors�start�finishedrz%a, %d %b %Y %H:%M:%S %z)rr.r/r1r2r5�CLOUDINIT_DISABLED_FILE�STATUS_DISABLEDr0r r	r�get�sorted�itemsr&�
isinstance�dict�extend�maxr'�STATUS_DONErr)rr
r*Z	status_v1Zstatus_fileZresult_filer3r4r7Zlatest_event�key�valuer8r9Z
event_timer+rrrresR	
rcCs)t�}tjtd|j���dS)z$Tool to report status of cloud-init.r
N)rr!�exitr,�
parse_args)rrrr�main�s	rH�__main__)�__doc__rr.r!r+rrrZcloudinit.distrosrZcloudinit.stagesrZcloudinit.utilrrr	r:rr rCr'r;rr,r5rrH�__name__rrrr�<module>s(5

Zerion Mini Shell 1.0