/usr/lib/python3/dist-packages/sos/collector/transports/__pycache__
NameSizeModeActions
control_persist.cpython-310.pyc70450644editdlrm
juju.cpython-310.pyc31240644editdlrm
local.cpython-310.pyc18730644editdlrm
oc.cpython-310.pyc65060644editdlrm
saltstack.cpython-310.pyc56970644editdlrm
__init__.cpython-310.pyc148720644editdlrm
Edit: /usr/lib/python3/dist-packages/sos/collector/transports/__pycache__/saltstack.cpython-310.pyc (5697B)
o G%@i8@s`ddlZddlZddlZddlZddlmZddlmZmZddl m Z m Z GdddeZ dS)N)RemoteTransport)ConnectionException#SaltStackMasterUnsupportedException) is_executablesos_get_command_outputcseZdZdZdZddZ  dfdd Zd d Zd d Ze ddZ dddZ dddZ ddZ e ddZddZddZZS)SaltStackMasterz A transport for collect that leverages SaltStack's Master Pub/Sub functionality to send commands to minions. This transport will by default assume the use cmd.shell module to execute commands on the minions. saltstackcCstt|dS)Nr)listjsonloadsvalues)self json_outputrD/usr/lib/python3/dist-packages/sos/collector/transports/saltstack.py_convert_output_json!sz$SaltStackMaster._convert_output_jsonFNcsVt|||||}tt||d|d<Wd|S1s$wY|S)z Run a command on the remote host using SaltStack Master. If the output is json, convert it to a string. outputN)super run_command contextlibsuppress Exceptionr)r cmdtimeout need_rootenv use_shellret __class__rrr$s   zSaltStackMaster.run_commandcCs.d|d|d|}t|dd}|ddkS)zO Execute cp.get_file on the remote host using SaltStack Master zsalt-cp  rstatusr)r)r nodefnamedestrresrrr_salt_copy_file0s  zSaltStackMaster._salt_copy_filecCsZd|d|}t|}|ddkr+d|jd}tj||d}t||dSd S) zK Execute cp.push on the remote host using SaltStack Master salt z cp.push r$rz/var/cache/salt/master/minions/z/files/TF)raddressospathjoinlstripshutilmove)r r%r&r'rr(cachedir cachedir_filerrr_salt_retrieve_file8s  z#SaltStackMaster._salt_retrieve_filecCs|jddd}|ddkS)z>Check if the remote host is responding using SaltStack Master.echo Connected r#r$r)r)r uprrr connectedEs zSaltStackMaster.connectedcCs(d}t|}|ddkr|ddkSt)aChecks to see if the local system supported SaltStack Master. This check relies on feedback from the salt binary. The command being run should always generate stderr output, but depending on what that output reads we can determine if SaltStack Master is supported or not. For our purposes, a host that does not support SaltStack Master is not able to run sos collect. Returns True if SaltStack Master is supported, else raise Exception zsalt-run manage.statusr$r)rr)r passwordrr(rrr_check_for_saltstackLs   z$SaltStackMaster._check_for_saltstackcCs|tds |ddSz|Wn ty|dw|dd}|j|dd}|d d kr8t|j|d d kS) aDConnect to the remote host using SaltStack Master. This method will attempt to connect to the remote host using SaltStack Master. If the connection fails, an exception will be raised. If the connection is successful, the connection will be stored in the self._connection attribute. saltz salt command is not executable. Fz$Transport is not locally supported. z4Transport is locally supported and service running. r6rr#r$r)r log_errorr;rlog_inforr,)r r:rresultrrr_connect`s        zSaltStackMaster._connectcCsdS)NTr)r rrr _disconnectyszSaltStackMaster._disconnectcCsd}d|d|jdS)z7The remote execution command to use for this transport.z--out json --static --no-colorr*r!z cmd.exec_code sh )r,)r salt_argsrrr remote_exec|szSaltStackMaster.remote_execcC|jr ||j||SdS)aCopy a file to the remote host using SaltStack Master Parameters fname The path to the file on the master dest The path to the destination directory on the remote host Returns True if the file was copied, else False F)r9r)r,r r&r'rrr_copy_file_to_remote  z$SaltStackMaster._copy_file_to_remotecCrE)aRetrieve a file from the remote host using saltstack Parameters fname The path to the file on the remote host dest The path to the destination directory on the master Returns True if the file was retrieved, else False F)r9r5r,rFrrr_retrieve_filerHzSaltStackMaster._retrieve_file)rFNF)N)__name__ __module__ __qualname____doc__namerrr)r5propertyr9r;rArBrDrGrI __classcell__rrrrrs$     r) rr r-r1sos.collector.transportsrsos.collector.exceptionsrr sos.utilitiesrrrrrrrs