HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/cloudinit/analyze/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/cloudinit/analyze/__pycache__/show.cpython-311.pyc
�

܍~cm0��j�ddlZddlZddlZddlZddlZddlmZmZddlm	Z	dddddd	d
ddd
dd�Z
d�d�e
���D����Z
dZdZdZedddfZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �ZGd!�d"��Zd#�Zd$�Zd%�Z 				d+d(�Z!d)�Z"d*�Z#dS),�N)�subp�util)�uses_systemd�delta�description�elapsed�
event_type�indent�level�name�origin�result�	timestamp�
total_time)z%dz%Dz%Ez%ez%Iz%lz%nz%oz%rz%tz%T� c�h�g|]/\}}d�|�dd��|����0S)z{0}: {1}�%z%%)�format�replace��.0�k�vs   �8/usr/lib/python3/dist-packages/cloudinit/analyze/show.py�
<listcomp>r2s:��O�O�O�D�A�q�Z���q�y�y��d�+�+�Q�/�/�O�O�O��
successful�failure�	container���c���t���D]@\}}||vr7|dvr|�|d|z��}�'|�|d|z��}�A|jdi|��S)N)rrrz
{%s:08.5f}z{%s}�)�
format_key�itemsrr)�msg�event�i�js    r�
format_recordr):s���� � �"�"�1�1���1���8�8��5�5�5��k�k�!�\�A�%5�6�6����k�k�!�V�a�Z�0�0����3�:������rc�v�td�|���D����}|d}g}|D]�}|d}tj�|��}tj|d���d��}tj	||��|�
|����|S)Nc3�,K�|]\}}|dv�	||fV��dS))�contentNr"rs   r�	<genexpr>z#dump_event_files.<locals>.<genexpr>Fs4����L�L�d�a��q��7K�7K�A�q�6�7K�7K�7K�7K�L�Lr�files�pathr,�ascii)�dictr$�osr/�basename�base64�	b64decode�decoder�
write_file�append)r&r,r.�saved�f�fname�fn_local�fcontents        r�dump_event_filesr>Es����L�L�e�k�k�m�m�L�L�L�L�L�G��G��E��E�
�����&�	���7�#�#�E�*�*���#�A�i�L�1�1�8�8��A�A�����(�+�+�+�
���X������Lrc�4�|r|�d��SdS)Nr��get�r&s r�
event_namerCSs!���!��y�y�� � � ��4rc�4�|r|�d��SdS)Nr	r@rBs rr	r	Ys!���'��y�y��&�&�&��4rc�Z�|r(t|���d��dSdS)N�/r)rC�splitrBs r�event_parentrH_s0���/��%� � �&�&�s�+�+�A�.�.��4rc�F�t|�d����S�Nr)�floatrArBs r�event_timestamprLes������;�'�'�(�(�(rc�Z�tj�t|����S�N)�datetime�utcfromtimestamprLrBs r�event_datetimerQis!����-�-�o�e�.D�.D�E�E�Erc�0�||z
���SrN)�
total_seconds)�t1�t2s  r�
delta_secondsrVms����G�"�"�$�$�$rc�V�tt|��t|����SrN)rVrQ)�start�finishs  r�event_durationrZqs"�����.�.��v�0F�0F�G�G�Grc	�
�|���}|�t||��t|t	|����ddt|���d��dz
zzdzd���|S)N�|rrF�z`->)rrr
)�copy�updaterZrVrQrC�count)�
start_timerXrY�records    r�event_recordrcus���
�[�[�]�]�F�
�M�M�#�E�6�2�2�$�Z���1F�1F�G�G��C�:�e�#4�#4�#:�#:�3�#?�#?�!�#C�D�D�u�L�	
�	
�����Mrc��d|zS)NzTotal Time: %3.5f seconds
r")rs r�total_time_recordre�s
��(�:�5�5rc�&�eZdZdZdd�Zd�Zd�ZdS)�SystemctlReaderzQ
    Class for dealing with all systemctl subp calls in a consistent manner.
    Nc���d|_tjd��dg|_|r|j�|��|j�d|g��|���|_dS)N�	systemctl�showz-p)�epochr�which�argsr8�extendr)�self�property�	parameters   r�__init__zSystemctlReader.__init__�sm����
��Z��,�,�f�5��	��	(��I���Y�'�'�'��	���$��)�*�*�*��y�y�{�{����rc��	tj|jd���\}}|r|S||_dS#t$r}|cYd}~Sd}~wwxYw)z�
        Make a subp call based on set args and handle errors by setting
        failure code

        :return: whether the subp call failed or not
        T��captureN)rrmrk�	Exception)ro�value�err�systemctl_fails    rrzSystemctlReader.subp�sn��	"���4�9�d�;�;�;�J�E�3��
��
��D�J��4���	"�	"�	"�!�!�!�!�!�!�!�����	"���s�!-�-�
A�>�A�Ac���|jr'td�|j�����|j�d��d}t|��dzS)z{
        If subp call succeeded, return the timestamp from subp as a float.

        :return: timestamp as a float
        zBSubprocess call to systemctl has failed, returning error code ({})�=r]i@B)r�RuntimeErrorrrkrGrK)rors  r�parse_epoch_as_floatz$SystemctlReader.parse_epoch_as_float�sc���<�	��,�,2�F�4�<�,@�,@���
��J�$�$�S�)�)�!�,�	��Y���'�)�)rrN)�__name__�
__module__�__qualname__�__doc__rrrr}r"rrrgrg�sP��������	#�	#�	#�	#�"�"�"� *�*�*�*�*rrgc���t��rt��Stj��s-dtj��d���vrt
��StS)a)
    Determine which init system a particular linux distro is using.
    Each init system (systemd, etc) has a different way of
    providing timestamps.

    :return: timestamps of kernelboot, kernelendboot, and cloud-initstart
    or TIMESTAMP_UNKNOWN if the timestamps cannot be retrieved.
    �gentoo�system)r�gather_timestamps_using_systemdr�
is_FreeBSD�system_info�lower�gather_timestamps_using_dmesg�TIMESTAMP_UNKNOWNr"rr�dist_check_timestampr��sf���~�~�1�.�0�0�0�����/�H��(8�(:�(:�8�(D�(J�(J�(L�(L�L�L�,�.�.�.��rc�F�	tjdgd���\}}|d���}|D]�}|�d���d��dkr�|�d�����}|d�d	��}t
|��}t
tj����t
tj	����z
}||z}t|||fcS��n#t$rYnwxYwtS)
a
    Gather timestamps that corresponds to kernel begin initialization,
    kernel finish initialization using dmesg as opposed to systemctl

    :return: the two timestamps plus a dummy timestamp to keep consistency
    with gather_timestamps_using_systemd
    �dmesgTrtrzUTF-8�userr r]�])
r�
splitlinesr6�findrG�striprK�timer�uptime�SUCCESS_CODErvr�)	�data�_�
split_entriesr'�splitup�stripped�user_space_timestamp�kernel_start�
kernel_ends	         rr�r��s)��
��)�W�I�t�4�4�4���a��Q��*�*�,�,�
��
	J�
	J�A��x�x�� � �%�%�f�-�-��3�3��(�(�7�+�+�1�1�3�3��"�1�:�+�+�C�0�0��(-�X���$�$�T�Y�[�[�1�1�E�$�+�-�-�4H�4H�H��)�,@�@�
�$�\�:�z�I�I�I�I�4�
	J���
�
�
���
�����s�DD�
D�
D�Dc���ttj����ttj����z
}	t	d�����}t	dd�����}|}t}tj��r�ttj����ttj����z
}	tj
d��}|j}n5#t$r(}td�|����|�d}~wwxYwt}||z}||z}n-#t $r }	t#|	��t$cYd}	~	Sd}	~	wwxYw||||fS)z�
    Gather timestamps that corresponds to kernel begin initialization,
    kernel finish initialization. and cloud-init systemd unit activation

    :return: the three timestamps
    �UserspaceTimestampMonotonic�InactiveExitTimestampMonotoniczcloud-init-localz/proc/1/cmdlinezBCould not determine container boot time from /proc/1/cmdline. ({})N)rKr�rr�rgr}r��is_container�	monotonicr2�stat�st_atime�OSErrorr|r�CONTAINER_CODErv�printr�)
r��delta_k_end�
delta_ci_s�	base_time�status�	file_statrxr��cloudinit_sysd�es
          rr�r��s��������%�%��d�k�m�m�(<�(<�<�L�"!�%�)�
�
�
�
�
 �
 �	�%�,�.@�
�
�
�
�
 �
 �	�!�	�������	$��d�i�k�k�*�*�U�4�>�3C�3C�-D�-D�D�I�
��G�$5�6�6�	�(�1�����
�
�
�"�6�6<�f�S�k�k���������
����
$�F���,�
�"�Z�/�����!�!�!�	�a���� � � � � � � �����!�����<��^�;�;sC�B E�$D�?E�
D2�
#D-�-D2�2E�
E1�E,�&E1�,E1F�(%n) %d seconds in %I%Dc���t|d����}g}d}d}i}	g}
g}tdt|����D�]�}||}
	||dz}n#t$rd}YnwxYwt	|
��dk�r$|rV|
�d��d	kr=|�t|����|
�|��g}d}d}|�!t|
��}||	t|
��<t|
��t|��krGt	|��d
kr2|�t|t||
|�������� |�d|
�d��z��|�|
����b|�
��}t|
��t|��krQt|||
��}|�td|��d
z��||�d��z
}���|�|�����|�t|����|
�|��|
S)a2
    Take in raw events and create parent-child dependencies between events
    in order to order events in chronological order.

    :param events: JSONs from dump that represents events taken from logs
    :param blame_sort: whether to sort by timestamp or by time taken.
    :param print_format: formatting to represent event, time stamp,
    and time taken by the event in one line
    :param dump_files: whether to dump files into JSONs
    :param log_datafiles: whether or not to log events generated

    :return: boot records ordered chronologically
    c��|dSrJr")�xs r�<lambda>z"generate_records.<locals>.<lambda>3s
���;��r)�keyNgrr]rXrz
init-localrYzStarting stage: %szFinished stage: (%n) %d seconds�
r)�sorted�range�len�
IndexErrorr	rAr8rerQrHrCr)rc�pop)�events�
blame_sort�print_format�
dump_files�
log_datafiles�
sorted_events�recordsrar�stage_start_time�boot_records�unprocessedr�r&�next_evt�prev_evtrbs                 r�generate_recordsr�s���*�6�'?�'?�@�@�@�M��G��J��J����L��K�
�1�c�-�(�(�
)�
)�,-�,-���q�	��	��a�!�e�}�H�H���	�	�	��H�H�H�	�����e����'�'��
!�5�9�9�V�,�,��<�<����0��<�<�=�=�=��#�#�G�,�,�,���!�
� �
��!�+�E�2�2�
�8B� ��e�!4�!4�5��%� � �J�x�$8�$8�8�8��h�'�'�8�3�3��N�N�%�(�(��U�H�E�E����������3�e�i�i��6G�6G�G�H�H�H��"�"�5�)�)�)��"���(�(�H��%� � �J�x�$8�$8�8�8�%�j�(�E�B�B�����!�"C�V�L�L�������f�j�j��1�1�1�
�
��"�"�8�,�,�,�,��N�N�$�Z�0�0�1�1�1����� � � ��s�A�A#�"A#c�$�t||���S)a<
    A passthrough method that makes it easier to call generate_records()

    :param events: JSONs from dump that represents events taken from logs
    :param print_format: formatting to represent event, time stamp,
    and time taken by the event in one line

    :return: boot records ordered chronologically
    )r�)r�)r�r�s  r�show_eventsr�ns���F��>�>�>�>rc��|���}	tj|��|fS#t$rd|fcYSwxYw)z�
    Takes in a log file, read it, and convert to json.

    :param infile: The Log file to be read

    :return: json version of logfile, raw file
    N)�read�json�loads�
ValueError)�infiler�s  r�load_events_infiler�{sV���;�;�=�=�D���z�$����%�%�������T�z�������s�,�=�=)Fr�FF)$r4rOr�r2r��	cloudinitrr�cloudinit.distrosrr#�joinr$�formatting_helpr��	FAIL_CODEr�r�r)r>rCr	rHrLrQrVrZrcrergr�r�r�r�r�r�r"rr�<module>r�s0���
�
�
���������	�	�	�	����� � � � � � � � �*�*�*�*�*�*�,�
�
�
�
�
�
�
�
�
�
���
��(�(�O�O�J�<L�<L�<N�<N�O�O�O�������	�����B��+�����������������)�)�)�F�F�F�%�%�%�H�H�H�
�
�
�6�6�6�2*�2*�2*�2*�2*�2*�2*�2*�j���,���>+<�+<�+<�`�*���M�M�M�M�`
?�
?�
?�����r