https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sos/policies/runtimes/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sos/policies/runtimes/__pycache__/lxd.cpython-310.pyc
o

-�_gI�@s@ddlZddlmZddlmZddlmZGdd�de�ZdS)�N)�ContainerRuntime)�sos_get_command_output)�
is_executablec@sLeZdZdZdZdZdd�Zddd�Zd	d
�Zdd�Z	d
d�Z
ddd�ZdS)�LxdContainerRuntimez,Runtime class to use for systems running LXD�lxd�lxccCsFtd|jj�r!|jj�d�r!|jj�d�s|jj�d�r!d|_dSdS)Nrrzsnap.lxd.daemonTF)r�policy�sysroot�package_manager�pkg_by_name�init_system�
is_running�active)�self�r�;/usr/lib/python3/dist-packages/sos/policies/runtimes/lxd.py�check_is_actives���z#LxdContainerRuntime.check_is_activeFcCsxg}|j�d�}|jr:t||jjd�}|ddkr:t�|d�}|D]}|ddks,|r9|�|dd|d	f�q"|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 list --format json��chroot�statusr�output�Running�expanded_configz
volatile.uuid�name)�binaryrrrr	�json�loads�append)r�get_all�
containers�_cmd�out�out_json�	containerrrr�get_containers"s
���z"LxdContainerRuntime.get_containerscCslg}|jr4t|j�d�|jjd�}|ddkr4t�|d�}|D]}d|vr3|�|dd|df�q |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 image list --format jsonrrrr�
update_source�alias�fingerprint�rrrrr	rrr)r�imagesr!r"�entrrr�
get_images:s 
�
��zLxdContainerRuntime.get_imagescCs�g}d}|jrct|j�d�|jjd�}|ddkr;t�|d�}|D]}|ddkr:d|d	vr:|d	dd
}nq"t|j�d|�d�|jjd�}|ddkrct�|d�}|D]	}|�|d�qY|S)
z�Get a list of container volumes present on the system

        :returns: A list of volume IDs on the system
        :rtype: ``list``
        �defaultz profile list --format jsonrrrrr�root�devices�poolz storage volume list z --format jsonr()r�vols�stg_poolr!r"�profiler*rrr�get_volumesPs0
���zLxdContainerRuntime.get_volumescCs|j�d|�d�S)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)rr#rrr�get_logs_commandqs
z$LxdContainerRuntime.get_logs_commandNcCs:|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)rr#�path�dest�	sizelimitrrr�get_copy_command}sz$LxdContainerRuntime.get_copy_command)F)N)�__name__�
__module__�__qualname__�__doc__rrrr$r+r3r4r:rrrrrs

!r)r�sos.policies.runtimesr�
sos.utilitiesrrrrrrr�<module>s



https://t.me/RX1948 - 2025