�
i��d� � �8 � d dl mZmZmZ d dlZ G d� dee� Zy)� )�Plugin�RedHatPlugin� PluginOptNc � � e Zd ZdZd ZdZdZdZedddfZefZ dZ
ed e
ed
�� edd
ed�� edd
ed�� gZ
d� Zd� Zd� Zd� Zd� Zy)�
Microshifta: This is the plugin for MicroShift 4.X. Even though it shares some of
the OpenShift components, its IoT/Edge target makes the product nimble and
light, thus requiring different a approach when operating it.
When enabled, this plugin will collect cluster information (such as
systemd service logs, configuration, versions, etc.)and also inspect API
resources in certain namespaces. The namespaces to scan are kube.* and
openshift.*. Other namespaces may be collected by making use of the
``only-namespaces`` or ``add-namespaces`` options.
�
microshifti� )r zmicroshift-selinuxzmicroshift-networkingzmicroshift-greenbootzgreenboot-healthcheckzgreenboot-task-runnerzredboot-task-runnerz2/var/lib/microshift/resources/kubeadmin/kubeconfig�
kubeconfigz+Path to a locally available kubeconfig file)�default�val_type�desc�only-namespaces� z2colon-delimited list of namespaces to collect from�add-namespaceszHcolon-delimited list of namespaces to add to the default collection listc �* � | j d� r.| j d� j d� D �cg c] }|�� c}S ddg}| j d� r9| j d� j d� D ] }|j d|z � � |S c c}w )z�Combine a set of regexes for collection with any namespaces passed
to sos via the -k openshift.add-namespaces option. Note that this does
allow for end users to specify namespace regexes of their own.
r
�:z^openshift\-.+$z
^kube\-.+$r z^%s$)�
get_option�split�append)�self�n�collect_regexes�nsps �?/usr/lib/python3/dist-packages/sos/report/plugins/microshift.py�_setup_namespace_regexesz#Microshift._setup_namespace_regexes. s� � �
�?�?�,�-�#���/@�A�G�G��L�M�!�A�M�M�
��
��
�?�?�+�,����'7�8�>�>�s�C�
6���&�&�w��}�5�
6� ��� Ns � Bc
� � � � fd�}� j � � _ t t |D �cg c]
} ||� s�|�� c}� � S c c}w )a Reduce the namespace listing returned to just the ones we want to
collect from. By default, as requested by OCP support personnel, this
must include all 'openshift' prefixed namespaces
:param nsps list: Namespace names from oc output
c �X �� �j D ] }t j || � s� y y)z�Match a particular namespace for inclusion (or not) in the
collection phases
:param namespace str: The name of a namespace
TF)r �re�match)� namespace�regexr s �r �_match_namespacez;Microshift._reduce_namespace_list.<locals>._match_namespaceI s0 �� � �-�-�
���8�8�E�9�-��
� � )r r �list�set)r �nspsr! r s ` r �_reduce_namespace_listz!Microshift._reduce_namespace_listA sA �� �
� $�<�<�>����C�D�@�q�,<�Q�,?��@�A�B�B��@s
�
A�Ac � � | j d| j d� z � }|d dk( r#| j |d j d� � S g S )NzToc get namespaces -o custom-columns=NAME:.metadata.name --no-headers --kubeconfig=%sr �statusr �output�
)�exec_cmdr r& |