Файловый менеджер - Редактировать - /usr/lib/python3.9/site-packages/sos/report/plugins/__pycache__/juju.cpython-39.pyc
�азад
a ([Qh" � @ sB d dl Z d dlZd dlZd dlmZmZmZ G dd� dee�ZdS )� N)�Plugin�UbuntuPlugin� PluginOptc @ sx e Zd ZdZdZdZdZdZedde dd �ed de dd �ed de dd �edde dd �gZdZdd� Z dd� Zdd� ZdS )�Jujua3 The Juju plugin is aimed at collecting Juju-related logs, configurations, and controller/model state(s). Logs and agent configuration information (/var/log/juju and /var/lib/juju) is collected by default since these are useful for troubleshooting. The Juju state collection is disabled by default and can be enabled with the 'juju-state' option. Collecting Juju state is safe in theory, but it does act on the live controller(s)/model(s) and is therefore optional. The default Juju state collection collects all controllers and models that the 'juju-user' (default=ubuntu) has access to. Specific controllers or models can be collected using the 'controllers' and 'models' options. Important: the string list is whitespace delimited, not colon delimited (sos plugin standard). This is due to the underlying Juju CLI accepting specific models in the format 'controller:model' and whitespaces are not allowed in either controller and model names. Example: models="controller_a:model_x controller_b:model_y" zJuju orchestration toolZjuju)ZvirtZsysmgmt)� /var/log/juju� juju-stateFz Include Juju state in the report)�defaultZval_typeZdesc� juju-userZubuntuzJuju client user.�controllers� z[Collect Juju state for specified controllers. Uses a whitespace delimited list.�modelszVCollect Juju state for specified models. Uses a whitespace delimited list.c C sX | � d�D ]}| �|� | �|� q dddddddd d d� }| �d�rl|�� D ]\}}| j| �|�|d � qN| �d� | jddgdd� | � d�r�| �g d�� | � d� | � d� n | �d� | � d�s�d S | � d�}zt�|� W n( t �y | �d|� d�� Y d S 0 | � d��r6| � d��r6| �d� d S | jd|d �}|d! d"k�r�t| � d��d#��}|�r~|d$hk�r~|}ntt�|d% �d �� �}ni }| � d��r�| � d��d#�D ] } d&| � d'�} | j| |d � �q�nv|D ]p}| jd(|� d'�|d �}|d! d"k�r�t�|d% �d } | D ].} | d) }d&|� d*|� d'�} | j| |d � �q �q�d S )+Nzjuju*Z depenginezdebug/pprof/goroutine?debug=1zdebug/pprof/heap?debug=1ZmetricsZpubsubZpresenceZ statepoolz&debug/pprof/juju/state/tracker?debug=1zunits?action=status) Zjuju_engine_reportZjuju_goroutinesZjuju_heap_profileZjuju_metricsZjuju_pubsub_reportZjuju_presence_reportZjuju_statepool_reportZjuju_statetracker_reportZjuju_unit_status�/var/lib/juju/agents)Zsuggest_filenamez!/var/lib/juju/agents/*/agent.confz/var/log/juju*z/var/lib/juju*T)� recursiveZall_logs)r z /var/lib/jujuz/var/lib/juju/**/.*z/var/lib/juju/kvmz/var/lib/juju/toolsz/var/log/juju/*.logr r zUser "z4" does not exist, will not collect Juju information.r r zWOptions: controllers, models are mutually exclusive. Will not collect Juju information.zjuju controllers --format=json)Zrunas�statusr � r �outputzjuju status -m z --format=jsonzjuju models --all -c z short-name�:)Zget_service_namesZadd_journalZadd_service_statusZpath_exists�itemsZadd_cmd_output�_juju_agentZ add_copy_specZadd_dir_listingZ get_optionZadd_forbidden_path�pwd�getpwnam�KeyErrorZ _log_warnZcollect_cmd_output�set�split�json�loads�keysZexec_cmd)�selfZserviceZjuju_agent_cmds�cmdZ agent_cmdZ juju_userZcontrollers_jsonZdesired_controllersr Zmodel�commandZ controllerZmodels_jsonr Z short_name� r �;/usr/lib/python3.9/site-packages/sos/report/plugins/juju.py�setupR s� � � �� ������ ��z Juju.setupc C sB | j dkr0| �d�D ]}t�d|�r|| _ q0qd| j � d|� �S )Nr r z$machine-*|controller-*|application-*zjuju-introspect --agent=r )� agent_name�listdir�re�search)r r Zdir_namer r r! r � s zJuju._juju_agentc C sH d}g d�}dd� |�� d�}d}| �|||� | �|� | �d� d S )Nz/var/lib/juju/agents/*)ZsharedsecretZapipasswordZoldpasswordZ statepasswordz(^\s*(�|z )\s*:\s*)(.*)z\1*********zjuju controllers)�joinZdo_path_regex_subZdo_file_private_subZdo_cmd_private_sub)r Zagents_pathZprotect_keysZ keys_regexZ sub_regexr r r! �postproc� s z Juju.postprocN)�__name__� __module__�__qualname__�__doc__Z short_descZplugin_nameZprofiles�filesr �bool�strZoption_listr# r"