Current File : //usr/lib/python3/dist-packages/sos/policies/runtimes/__pycache__/crio.cpython-312.pyc
�

-�_gm
��F�ddlZddlmZddlmZddlmZGd�de�Zy)�N)�quote)�ContainerRuntime)�sos_get_command_outputc�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����
��+�+��d�7�4��";�8�D���;�;�(��d�k�k�6I�6I�J�C��8�}��!��:�:�c�(�m�4��!)�,�!7�J�I��%�%�"�4��)�J�*?��*G�H�J�J��rc���g}|jr�t|j�d�|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 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������;�;�(�D�K�K�=��)H�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_cmdEsR����s��J��J��1�1�)�<���+��<�<�.��,��q���=�	5�13�	5rN)F)
�__name__�
__module__�__qualname__�__doc__rrrr&r1r:rrr
rrs#��7��D�
�F���$�25rr)r�shlexr�sos.policies.runtimesr�
sos.utilitiesrrrrr
�<module>rBs"����2�0�I5�+�I5r