id FddlZddlmZddlmZddlmZGddeZy)N)JujuNotInstalledException)RemoteTransport)sos_get_command_outputcXeZdZdZdZdZdZdZd dZdZ e dZ e d Z d Z y ) 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_sshubuntucd} tj|tjdy#tj$r|j dt wxYw)Nz juju versionTstderrshellzFailed to check `juju` version) subprocess check_outputSTDOUTCalledProcessError log_errorr)selfcmds ?/usr/lib/python3/dist-packages/sos/collector/transports/juju.py_check_juju_installedzJujuSSH._check_juju_installed'sS ,  # #C 0A0A N,, , NN; <+ + ,s &++Ac|jd|} tj|tjdy#tj$r|j d|dwxYw)Nz sudo chmod o+r Tr zFailed to make z world-readable) remote_execrrrrr)rfnamers r_chmodzJujuSSH._chmod0sk!!""25':   # #C 0A0A N,,  NN_UG?C D  s &:*A$cD|j|_|jSN)r _connected)rpasswords r_connectzJujuSSH._connect9s446cy)NTrs r _disconnectzJujuSSH._disconnect=sr c|jSr)rr#s r connectedzJujuSSH.connected@s r ch|jjd\}}|rd|nd}|d|}d|S)N:-m  z juju ssh )addresssplit)rmodel target_option model_optionoptions rrzJujuSSH.remote_execDsG#||11#6}(-UG}2  >=/26(##r c|j||jjd\}}|rd|nd}d|d|d|d|}t|}|ddk(S) Nr(r)r*z juju scp z -- -r r+statusr)rr,r-r)rrdestr.unitr0rress r_retrieve_filezJujuSSH._retrieve_fileKsl Ell((- t(-UG}2 ,wtfAeWAdVD$S)8}!!r N)r*)__name__ __module__ __qualname____doc__name default_userrrrr$propertyr&rr7r"r rrrsT DL$$ "r r)rsos.collector.exceptionsrsos.collector.transportsr sos.utilitiesrrr"r rrBs>40>"o>"r