%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/sos/policies/runtimes/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/sos/policies/runtimes/__pycache__/crio.cpython-312.pyc

�

i��d�
��F�ddlZddlmZddlmZddlmZGd�de�Zy)�N)�ContainerRuntime)�sos_get_command_output)�quotec�2�eZdZdZdZdZd�Zd	d�Zd�Zd�Z	y)
�CrioContainerRuntimez-Runtime class to use for systems running crio�crio�crictlc��y)NF�)�selfs �</usr/lib/python3/dist-packages/sos/policies/runtimes/crio.py�check_can_copyz#CrioContainerRuntime.check_can_copys���c��g}|j�d|rdnd�d�}|jrgt||jj��}|ddk(r>tj|d�}|d	D]}|j|d
|ddf�� |S)
z�Get a list of containers present on the system.

        :param get_all: If set, include stopped containers as well
        :type get_all: ``bool``
        z ps z-a�z -o json��chroot�statusr�output�
containers�id�metadata�name)�binary�activer�policy�sysroot�json�loads�append)r�get_allr�_cmd�out�out_json�	containers       r
�get_containersz#CrioContainerRuntime.get_containerss����
�%)�[�[�'�$�r�2I�J���;�;�(��d�k�k�6I�6I�J�C��8�}��!��:�:�c�(�m�4��!)�,�!7�J�I��%�%�"�4��)�J�*?��*G�H�J�J��rc���g}|jr�td|jz|jj��}|ddk(r�tj|d�}|dD]{}t|d�dkDr!|dD]}|j||df���5t|d	�dk(rd
}n|d	djd�d}|j|dz|df��}|S)
z�Get a list of images present on the system

        :returns: A list of 2-tuples containing (image_name, image_id)
        :rtype: ``list``
        z%s images -o jsonrrrr�images�repoTagsr�repoDigestsz<none>�@z:<none>)
rrrrrrr�lenr �split)rr(r#r$�image�repo_tag�
image_names       r
�
get_imageszCrioContainerRuntime.get_images,s������;�;�(�)<�t�{�{�)J�04���0C�0C�E�C��8�}��!��:�:�c�(�m�4��%�h�/�
M�E��5��,�-��1�(-�j�(9�C�H�"�M�M�8�U�4�[�*A�B�C��u�]�3�4��9�)1�J�).�}�)=�a�)@�)F�)F�s�)K�A�)N�J��
�
�z�I�'=�u�T�{�&K�L�
M��
rc�t�|rt|�}n|}|j|�}|�|j�d|�d|��SdS)a�Format a command to run inside a container using the runtime

        :param container: The name or ID of the container in which to run
        :type container: ``str``

        :param cmd: The command to run inside `container`
        :type cmd: ``str``

        :param quotecmd: Whether the cmd should be quoted.
        :type quotecmd: ``bool``

        :returns: Formatted string to run `cmd` inside `container`
        :rtype: ``str``
        � r)r�get_container_by_name�run_cmd)rr%�cmd�quotecmd�
quoted_cmd�container_ids      r
�fmt_container_cmdz&CrioContainerRuntime.fmt_container_cmdEsM����s��J��J��1�1�)�<��,8�,D�"�\�\�<�'�)�	M�JL�	MrN)F)
�__name__�
__module__�__qualname__�__doc__rrrr&r1r:rrr
rrs$��7��D�
�F���$�2Mrr)r�sos.policies.runtimesr�
sos.utilitiesr�pipesrrrrr
�<module>rBs$���2�0��IM�+�IMr

Zerion Mini Shell 1.0