Ë
    i©¹dˆ  ã                   óF   — d dl Z d dlmZ d dlmZ d dlmZ  G d„ de«      Zy)é    N)ÚContainerRuntime)Úsos_get_command_output)Úquotec                   ó2   — e Zd ZdZdZdZd„ Zd	d„Zd„ Zd„ 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_copy   s   € Øó    c                 ó  — g }| j                   ›d|rdnd›d�}| j                  rgt        || j                  j                  ¬«      }|d   dk(  r>t        j                  |d   «      }|d	   D ]  }|j                  |d
   |d   d   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_containers   sœ   € ð ˆ
Ø%)§[£[¹'±$ÀrÑ2IÐJˆØ�;Š;Ü(¨°d·k±k×6IÑ6IÔJˆCØ�8‰} Ò!ÜŸ:™: c¨(¡mÓ4�Ø!)¨,Ñ!7ò J�Ià×%Ñ%Ø" 4™¨)°JÑ*?ÀÑ*GÐHõJðJð Ðr   c                 óÄ  — g }| j                   rÑt        d| j                  z  | j                  j                  ¬«      }|d   dk(  r›t        j                  |d   «      }|d   D ]{  }t        |d   «      dkD  r!|d   D ]  }|j                  ||d   f«       Œ Œ5t        |d	   «      dk(  rd
}n|d	   d   j                  d«      d   }|j                  |dz   |d   f«       Œ} |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 jsonr   r   r   r   ÚimagesÚrepoTagsr   ÚrepoDigestsz<none>ú@z:<none>)
r   r   r   r   r   r   r   Úlenr    Úsplit)r   r(   r#   r$   ÚimageÚrepo_tagÚ
image_names          r   Ú
get_imageszCrioContainerRuntime.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ð ˆr   c                 ót   — |rt        |«      }n|}| j                  |«      }|�| j                  ›d|›d|›�S dS )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_cmdE   sM   € ñ Ü˜s›‰JàˆJØ×1Ñ1°)Ó<ˆà,8Ð,Dð "Ÿ\›\ª<Ù'ð)ð 	MØJLð	Mr   N)F)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r&   r1   r:   r   r   r   r   r      s$   „ Ù7à€DØ€Fòóò$ó2Mr   r   )r   Úsos.policies.runtimesr   Úsos.utilitiesr   Úpipesr   r   r   r   r   ú<module>rB      s$   ðó å 2Ý 0Ý ôIMÐ+õ IMr   