HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/sos/collector/transports/__pycache__/juju.cpython-38.pyc
U

i��d�
�@s@ddlZddlmZddlmZddlmZGdd�de�ZdS)�N)�JujuNotInstalledException)�RemoteTransport)�sos_get_command_outputc@sZeZdZdZdZdZdd�Zdd�Zdd	d
�Zdd�Z	e
d
d��Ze
dd��Zdd�Z
dS)�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_sshZubuntucCsDd}ztj|tjdd�Wn$tjk
r>|�d�t�YnXdS)Nzjuju versionT��stderr�shellzFailed to check `juju` version)�
subprocess�check_output�STDOUT�CalledProcessError�	log_errorr)�self�cmd�r�?/usr/lib/python3/dist-packages/sos/collector/transports/juju.py�_check_juju_installed's

zJujuSSH._check_juju_installedcCsV|j�d|��}ztj|tjdd�Wn*tjk
rP|�d|�d���YnXdS)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)rZpasswordrrr�_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_optionZoptionrrrrDszJujuSSH.remote_execcCs\|�|�|j�d�\}}|r(d|��nd}d|�d|�d|�d|��}t|�}|ddkS)	Nrrrz	juju scp z -- -r rZstatusr)rr r!r)rr�destr"Zunitr#r�resrrr�_retrieve_fileKs
zJujuSSH._retrieve_fileN)r)�__name__�
__module__�__qualname__�__doc__�nameZdefault_userrrrr�propertyrrr&rrrrrs		


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