+
    iI  c                   sH    ^ RI t ^ RIHt ^ RIHt ^ RIHt  ! R R]4      tR# )i    N)ContainerRuntime)sos_get_command_output)is_executablec                   sX   a  ] tR t^t o RtRtRtR tRR ltR t	R t
R tRR
 ltRtV tR	# )LxdContainerRuntimez,Runtime class to use for systems running LXDlxdlxcc                sf   \        R V P                  P                  4      '       d   V P                  P                  P	                  R4      '       d`   V P                  P
                  P                  R4      '       g,   V P                  P
                  P                  R4      '       d
   RV n        R# R# )r   r   zsnap.lxd.daemonTF)r   policysysrootZpackage_managerZpkg_by_nameZinit_systemZ
is_runningactive)selfs   &>/usr/lib/python3.14/site-packages/sos/policies/runtimes/lxd.pycheck_is_activeZ#LxdContainerRuntime.check_is_active   sx    %!4!455++77>>((33E::((334EFFDK    c                st   . pV P                    R2pV P                  '       d   \        W0P                  P                  R7      pVR,          ^ 8X  dg   \
        P                  ! VR,          4      pV FC  pVR,          R8X  g   V'       g   K  VP                  VR,          R,          VR,          34       KE  	  V# )	zGet a list of containers present on the system.

:param get_all: If set, include stopped containers as well
:type get_all: ``bool``
z list --format jsonZchrootstatusoutputZRunningZexpanded_configzvolatile.uuidname)binaryr   r   r   r   jsonloadsappend)r	   Zget_allZ
containersZ_cmdoutout_json	containers   &&     r
   get_containersZ"LxdContainerRuntime.get_containers"   s     
++12;;;(kk6I6IJC8}!::c(m4!)I *i777"))&'89/J&v.01 "* r   c                sT   . pV P                   '       d   \        V P                   R2V P                  P                  R7      pVR,          ^ 8X  dX   \
        P                  ! VR,          4      pV F4  pRV9   g   K  VP                  VR,          R,          VR,          34       K6  	  V# )z|Get a list of images present on the system

:returns: A list of 2-tuples containing (image_name, image_id)
:rtype: ``list``
z image list --format jsonr   r   r   Zupdate_sourceZaliasZfingerprintr   r   r   r   r   r   r   r   )r	   Zimagesr   r   ents   &    r
   
get_imagesZLxdContainerRuntime.get_images:   s     ;;;(;;-89{{**C 8}!::c(m4#C&#-09.'0 1 $ r   c                s`   . pRpV P                   '       Ed   \        V P                   R2V P                  P                  R7      pVR,          ^ 8X  d^   \
        P                  ! VR,          4      pV F:  pVR,          R8X  g   K  RVR,          9   g   K#  VR,          R,          R	,          p M	  \        V P                   R
V R2V P                  P                  R7      pVR,          ^ 8X  d?   \
        P                  ! VR,          4      pV F  pVP                  VR,          4       K  	  V# )zuGet a list of container volumes present on the system

:returns: A list of volume IDs on the system
:rtype: ``list``
Zdefaultz profile list --format jsonr   r   r   r   ZrootZdevicesZpoolz storage volume list z --format jsonr   )r	   ZvolsZstg_poolr   r   Zprofiler   s   &      r
   get_volumesZLxdContainerRuntime.get_volumesP   s    ;;; );;-:;{{**C 8}!::c(m4'G94"gi&88#*9#5f#=f#E	  ( );;-4XJnM{{**C 8}!::c(m4#CKKF, $r   c                s&    V P                    RV R2# )zGet the command string used to dump container logs from the
runtime

:param container: The name or ID of the container to get logs for
:type container: ``str``

:returns: Formatted runtime command to get logs from `container`
:type: ``str``
z info z --show-log)r   )r	   r   s   &&r
   get_logs_commandZ$LxdContainerRuntime.get_logs_commandq   s     ++fYK{;;r   Nc                sl    V'       d   V P                    RV RV RV 2# V P                   RV V RV 2# )a  Generate the command string used to copy a file out of a container
by way of the runtime.

:param container:   The name or ID of the container
:type container:    ``str``

:param path:        The path to copy from the container. Note that at
                    this time, no supported runtime supports globbing
:type path:         ``str``

:param dest:        The destination on the *host* filesystem to write
                    the file to
:type dest:         ``str``

:param sizelimit:   Limit the collection to the last X bytes of the
                    file at PATH
:type sizelimit:    ``int``

:returns:   Formatted runtime command to copy a file from a container
:rtype:     ``str``
Z z	 tail -c z file pull )Zrun_cmdr   )r	   r   ZpathZdestZ	sizelimits   &&&&&r
   get_copy_commandZ$LxdContainerRuntime.get_copy_command}   sG    , ll^1YKy1TFKK++k)TF!D6BBr   )r   )F)N)Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r   r   r   r   r   r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r
   r   r      s8     6DF0,B
<C Cr   r   )r   Zsos.policies.runtimesr    Zsos.utilitiesr   r   r   ) r   r
   <module>r      s$     2 0 'CC* CCr   