HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sos/collector/transports/__pycache__/juju.cpython-310.pyc
o

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

    �juju_ssh�ubuntucCs<d}ztj|tjdd�WdStjy|�d�t�w)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_installedcCsN|j�d|��}ztj|tjdd�WdStjy&|�d|�d���w)Nz sudo chmod o+r TrzFailed to make z world-readable)�remote_execrrr
rr)r�fnamerrrr�_chmod0s��zJujuSSH._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�model�
target_option�model_option�optionrrrrDs
zJujuSSH.remote_execcCs\|�|�|j�d�\}}|rd|��nd}d|�d|�d|�d|��}t|�}|ddkS)	Nr r!rz	juju scp z -- -r r"�statusr)rr#r$r)rr�destr%�unitr'r�resrrr�_retrieve_fileKs
zJujuSSH._retrieve_fileN)r)�__name__�
__module__�__qualname__�__doc__�name�default_userrrrr�propertyrrr-rrrrrs	
	

r)r�sos.collector.exceptionsr�sos.collector.transportsr�
sos.utilitiesrrrrrr�<module>s