HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/sos/collector/transports/__pycache__/juju.cpython-39.opt-1.pyc
a

\��h�@s@ddlZddlmZddlmZddlmZGdd�de�ZdS)�N)�JujuNotInstalledException)�RemoteTransport)�sos_get_command_outputc@sbeZdZdZdZdZdd�Zdd�Zdd	d
�Zdd�Z	e
d
d��Ze
dd��Zdd�Z
dd�ZdS)�JujuSSHa
    A "transport" that leverages `juju ssh` to perform commands on the remote
    hosts.

    This transport is expected to be used in juju managed environment, and the
    user should have the necessary credential for accessing the controller.
    When using this transport, the --nodes option will be expected to be a
    comma separated machine IDs, **not** IP addr, since `juju ssh` identifies
    the ssh target by machine ID.

    Examples:

    sos collect --nodes 0,1,2 --no-local --transport juju --batch

    Zjuju_sshZubuntuc
CsVd}ztj|tjdd�Wn6tjyP}z|�d�t|�WYd}~n
d}~00dS)Nzjuju versionT��stderr�shellzFailed to check `juju` version)�
subprocess�check_output�STDOUT�CalledProcessError�	log_errorr)�self�cmd�err�r�A/usr/lib/python3.9/site-packages/sos/collector/transports/juju.py�_check_juju_installed's
zJujuSSH._check_juju_installedcCsT|j�d|��}ztj|tjdd�Wn(tjyN|�d|�d���Yn0dS)Nz sudo chmod o+r TrzFailed to make z world-readable)�remote_execr	r
rrr
)r�fnamerrrr�_chmod0szJujuSSH._chmod�cCs|��|_|jS�N)r�
_connected)r�passwordrrr�_connect9s
zJujuSSH._connectcCsdS)NTr�rrrr�_disconnect=szJujuSSH._disconnectcCs|jSr)rrrrr�	connected@szJujuSSH.connectedcCs:|j�d�\}}|rd|��nd}|�d|��}d|��S)N�:�-m r� z	juju ssh )�address�split)r�modelZ
target_option�model_option�optionrrrrDszJujuSSH.remote_execcCsV|j�d�\}}|rd|��nd}d|�d|�d|�d|��}t|dd�}|d	d
kS)Nrr r�	juju scp z -- r!�)�timeout�statusr)r"r#r�rr�destr$Zunitr%r�resrrr�_copy_file_to_remoteKs
zJujuSSH._copy_file_to_remotecCs\|�|�|j�d�\}}|r(d|��nd}d|�d|�d|�d|��}t|�}|ddkS)	Nrr rr'z -- -r r!r*r)rr"r#rr+rrr�_retrieve_fileRs
zJujuSSH._retrieve_fileN)r)�__name__�
__module__�__qualname__�__doc__�nameZdefault_userrrrr�propertyrrr.r/rrrrrs		


r)r	Zsos.collector.exceptionsrZsos.collector.transportsrZ
sos.utilitiesrrrrrr�<module>s