/usr/lib/python3/dist-packages/sos/collector/clusters/__pycache__
NameSizeModeActions
ceph.cpython-310.pyc23710644editdlrm
jbon.cpython-310.pyc10400644editdlrm
juju.cpython-310.pyc72680644editdlrm
kubernetes.cpython-310.pyc17110644editdlrm
ocp.cpython-310.pyc119650644editdlrm
openstack.cpython-310.pyc26140644editdlrm
ovirt.cpython-310.pyc77720644editdlrm
pacemaker.cpython-310.pyc33030644editdlrm
saltstack.cpython-310.pyc27210644editdlrm
satellite.cpython-310.pyc17420644editdlrm
__init__.cpython-310.pyc153440644editdlrm
Edit: /usr/lib/python3/dist-packages/sos/collector/clusters/__pycache__/juju.cpython-310.pyc (7268B)
o G%@i!@sbddlZddlZddlZddlmZddlmZddlmZd ddZddZ Gd d d eZ dS) N)Cluster)sos_parse_versionsos_get_command_outputcCs|sgSdd|dDS)zParse comma separated string.cSsg|]}|qS)strip).0stringrr=/usr/lib/python3/dist-packages/sos/collector/clusters/juju.py sz(_parse_option_string..,)split)stringsrrr _parse_option_stringsrcCsGddd}||S)aRHelper function to get Index. The reason why we need Index defined in function is because currently the collector.__init__ will load all the classes in this module and also Index. This will cause bug because it think Index is Cluster type. Also We don't want to provide a customized filter to remove Index class. c@s0eZdZdZddZddZddZdd Zd S) z_get_index..IndexzIndex structure to help parse juju status output. Attributes apps, units and machines are dict which key is the app/unit/machine name and the value is list of targets which format are {model_name}:{machine_id}. cSs(||_i|_i|_i|_td|_dS)Nsos) model_nameappsunitsmachineslogging getLoggerui_log)selfrrrr __init__.s z"_get_index..Index.__init__c Ss|dD]7\}}g}|di}|D]!\}}|d}|jd|} | g|j|<| g|j|<|| q||j|<qdS)zAdds principal units to index. applicationsrmachine:N)itemsgetrrrappendr) r juju_statusappapp_infonodesrunit unit_infornoderrr add_principals5s     z(_get_index..Index.add_principalsc Ss|dD]s\}}|dg}|D]f}|j|s%|jd|dq|j||j|d|d|vrC|jd|dq|d|d}|D](\}}|jd|d} |d iD]\} }| |d rv| g|j| <qeqOqqd S) zAdd subordinates to index. Since subordinates does not have units they need to be manually added. rzsubordinate-tozPrincipal charm z is missingrz is missing unitsrr subordinates/N) rrrrwarningextendr startswithr) rr r!r"subordinate_toparentr_r%r&sub_keyrrr add_subordinatesCs:      z*_get_index..Index.add_subordinatescSs2|dD]}|jd|}|g|j|<qdS)zAdd machines to index. If model does not have any applications it needs to be manually added. rrN)keysrr)rr rr&rrr add_machinesdsz&_get_index..Index.add_machinesN)__name__ __module__ __qualname____doc__rr'r1r3rrrr Index%s  !r8r)rr8rrr _get_indexs Ir9c@s`eZdZdZdZdZgdZddZddZdd Z d d Z d d Z ddZ ddZ ddZdS)jujua! The juju cluster profile is intended to be used on juju managed clouds. It"s assumed that `juju` is installed on the machine where `sos` is called, and that the juju user has superuser privilege to the current controller. By default, the sos reports will be collected from all the applications in the current model. If necessary, you can filter the nodes by models / applications / units / machines with cluster options. Example: sos collect --cluster-type juju -c "juju.models=sos" -c "juju.apps=a,b,c" zJuju Managed Clouds))rz1Filter node list by apps (comma separated regex).)rr;z3Filter node list by units (comma separated string).)modelsr;z4Filter node list by models (comma separated string).)rr;z6Filter node list by machines (comma separated string).cCstjdd|dtjdS)z#Remove leading characters before {.z (^[^{]*)(.*)z\2r)countflags)resub MULTILINE)routputrrr _cleanup_juju_outputs zjuju._cleanup_juju_outputcCs6||}t|d}|||||||S)zParse juju status output and return target dict. Here are couple helper functions to parse the juju principals units, subordinate units and machines. )r)_execute_juju_statusr9r'r1r3)rrr indexrrr _get_model_infos     zjuju._get_model_infocCstd}|dS)zGrab the version of jujuz juju versionrBr)rresrrr _get_juju_versionszjuju._get_juju_versionc Cs|rd|nd}d}|}t|tdkr|d7}|jd|d|}||}|dd ks=td |d |d||d }d}t|}|S) Nz-m r;z --format json3z --no-colorz status  statusr'z' returned error: rB)rHrcmdexec_primary_cmd ExceptionrCjsonloads) rr model_option format_option juju_version status_cmdrGjuju_json_outputr rrr rDs   zjuju._execute_juju_statuscCsFt}|D]}t||D]\}}t||r||pgqq|S)zFilter with regex match.)setgetattrrr?matchupdaterkeypatterns model_infor#patternparamvaluerrr _filter_by_patterns zjuju._filter_by_patterncCsBt}|D]}t||D]\}}||kr||pgqq|S)zFilter with fixed match.)rWrXrrZr[rrr _filter_by_fixedszjuju._filter_by_fixedcCsdS)z'Dynamically change transport to 'juju'.r:r)rrrr set_transport_typeszjuju.set_transport_typec Cst|d}t|d}t|d}t|d}|||d}t|s,|s,gS|s1dg}t}|D](}||}|D]\} } | dkrQ|| | |} n|| | |} | | qAq6t |S)z+Get the machine numbers from `juju status`.r<rrr)rrrr;) r get_optionanyvaluesrWrFrrbrcrZlist) rr<rrrfiltersr#modelr^r\resource_nodesrrr get_nodess&   zjuju.get_nodesN)r4r5r6r7rM cluster_name option_listrCrFrHrDrbrcrdrmrrrr r:qs   r:)N) rrPr?sos.collector.clustersr sos.utilitiesrrrr9r:rrrr s     V