/usr/lib/python3/dist-packages/sos/policies/runtimes/__pycache__
Edit: /usr/lib/python3/dist-packages/sos/policies/runtimes/__pycache__/lxd.cpython-310.pyc (4389B)
o
G%@iI @ s@ d dl Z d dlmZ d dlmZ d dlmZ G dd deZdS ) N)ContainerRuntime)sos_get_command_output)
is_executablec @ sL e Zd ZdZdZdZdd ZdddZd d
Zdd Z d
d Z
dddZdS )LxdContainerRuntimez,Runtime class to use for systems running LXDlxdlxcc C sF t d| jjr!| jjdr!| jjds| jjdr!d| _dS dS )Nr r zsnap.lxd.daemonTF)r policysysrootpackage_managerpkg_by_nameinit_system
is_runningactive)self r ;/usr/lib/python3/dist-packages/sos/policies/runtimes/lxd.pycheck_is_active s z#LxdContainerRuntime.check_is_activeFc C sx g }| j d}| jr:t|| jjd}|d dkr:t|d }|D ]}|d dks,|r9||d d |d f q"|S )
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 jsonchrootstatusr outputRunningexpanded_configz
volatile.uuidname)binaryr r r r jsonloadsappend)r get_all
containers_cmdoutout_json containerr r r get_containers" s
z"LxdContainerRuntime.get_containersc C sl g }| j r4t| j d| jjd}|d dkr4t|d }|D ]}d|v r3||d d |d f q |S ) zGet 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 r
update_sourcealiasfingerprintr r r r r r r r )r imagesr! r" entr r r
get_images: s
zLxdContainerRuntime.get_imagesc C s g }d}| j rct| j d| jjd}|d dkr;t|d }|D ]}|d dkr:d|d v r:|d d d
} nq"t| j d| d| jjd}|d dkrct|d }|D ] }||d qY|S )
zGet a list of container volumes present on the system
:returns: A list of volume IDs on the system
:rtype: ``list``
defaultz profile list --format jsonr r r r r rootdevicespoolz storage volume list z --format jsonr( )r volsstg_poolr! r" profiler* r r r get_volumesP s0
zLxdContainerRuntime.get_volumesc C s | j d| dS )a! Get 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# r r r get_logs_commandq s
z$LxdContainerRuntime.get_logs_commandNc C s: |r| j d| d| d| S | j d| | d| S )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 tail -c z file pull )run_cmdr )r r# pathdest sizelimitr r r get_copy_command} s z$LxdContainerRuntime.get_copy_command)F)N)__name__
__module____qualname____doc__r r r r$ r+ r3 r4 r: r r r r r s
!r )r sos.policies.runtimesr
sos.utilitiesr r r r r r r
s