Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/microshift.cpython-36.pyc

3

�f��@s2ddlZddlmZmZmZGdd�dee�ZdS)�N)�Plugin�RedHatPlugin�	PluginOptc@s�eZdZdZdZdZdZdZefZefZ	dZ
ede
edd	�ed
dedd	�ed
dedd	�gZ
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�
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��microshift-selinux�microshift-networkingz2/var/lib/microshift/resources/kubeadmin/kubeconfig�
kubeconfigz+Path to a locally available kubeconfig file)�defaultZval_typeZdesczonly-namespaces�z2colon-delimited list of namespaces to collect fromzadd-namespaceszHcolon-delimited list of namespaces to add to the default collection listcCs\|jd�rt|jd�jd��Sddg}|jd�rXx&|jd�jd�D]}|jd|�qBW|S)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.
        zonly-namespaces�:z^openshift\-.+$z
^kube\-.+$zadd-namespacesz^%s$)�
get_option�list�split�append)�selfZcollect_regexesZnsp�r� /usr/lib/python3.6/microshift.py�_setup_namespace_regexes,s

z#Microshift._setup_namespace_regexescs,dd��|j��tt��fdd�|D���S)aReduce 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
        cSs"x|D]}tj||�rdSqWdS)z�Match a particular namespace for inclusion (or not) in the
            collection phases

                :param namespace str:   The name of a namespace
            TF)�re�match)�	namespace�regexesZregexrrr�_match_namespaceGs
z;Microshift._reduce_namespace_list.<locals>._match_namespacec3s|]}�|��r|VqdS)Nr)�.0�n)rrrr�	<genexpr>Usz4Microshift._reduce_namespace_list.<locals>.<genexpr>)rr�set)rZnspsr)rrr�_reduce_namespace_list?sz!Microshift._reduce_namespace_listcCs8|jd|jd��}|ddkr4|j|djd��SgS)NzToc get namespaces -o custom-columns=NAME:.metadata.name --no-headers --kubeconfig=%sr	�statusr�output�
)�exec_cmdr
rr)r�resrrr�_get_namespacesWszMicroshift._get_namespacescCs�ddddddddd	d
ddd
dddddddddddddg}g}x@|D]8}|jd|jd�|ftjd�}|ddkrB|j|�qBW|S) z@Get cluster-level (non-namespaced) resources to collect
        ZapiservicesZcertificatesigningrequestsZclusterrolebindingsZclusterrolesZcomponentstatusesZ
csidriversZcsinodesZcustomresourcedefinitionsZflowschemasZingressclassesZlogicalvolumesZmutatingwebhookconfigurationsZnodesZpersistentvolumesZpriorityclassesZprioritylevelconfigurationsZrangeallocationsZruntimeclassesZsecuritycontextconstraintsZselfsubjectaccessreviewsZselfsubjectrulesreviewsZstorageclassesZsubjectaccessreviewsZtokenreviewsZvalidatingwebhookconfigurationsZvolumeattachmentszoc get --kubeconfig %s %sr	)�timeoutrr)r"r
r�plugin_timeoutr)rZglobal_resourcesZ_filtered_resourcesZresourcer#rrr�_get_cluster_resourcesasF

z!Microshift._get_cluster_resourcescCs�|jd�|jd�|jd�r,|jddg�|jdg�|jddg�d	j|j��}d
jdd�|j�D��}|jtj	�r�|j
d
d�}|jd�}|jd|||fdtjd�|jd|||fdtjd�dS)a�The setup() phase of this plugin will first gather system
        information and then iterate through all default namespaces, and/or
        those specified via the `add-namespaces` and `only-namespaces` plugin
        options. Both of these options accept shell-style regexes.

        Output format for this function is based on `oc adm inspect` command,
        which is used to retrieve all API resources from the cluster.
        zmicroshift-etcd.scopez/etc/microshiftz/var/lib/microshift-backupsz%/var/lib/microshift-backups/*/versionz"/var/lib/microshift-backups/*.jsonz/var/log/kube-apiserver/*.logzmicroshift versionz#microshift show-config -m effective�,� cSsg|]}d|�qS)zns/%sr)rrrrr�
<listcomp>�sz$Microshift.setup.<locals>.<listcomp>F)Zmaker	z/oc adm inspect --kubeconfig %s --dest-dir %s %szinspect_cluster_resources.log)Zsuggest_filenamer%zinspect_namespaces.logN)
Zadd_journalZ
add_copy_specZpath_existsZadd_cmd_output�joinr'r$Zis_service_runningr�plugin_nameZget_cmd_output_pathr
r&)rZ_cluster_resources_to_collectZ_namespaces_to_collectZ_subdirZ_kubeconfigrrr�setup�s4	







zMicroshift.setupN)rrr)�__name__�
__module__�__qualname__�__doc__Z
short_descr,r&ZpackagesZservicesZprofilesZlocalhost_kubeconfigr�strZoption_listrrr$r'r-rrrrrs&


+r)rZsos.report.pluginsrrrrrrrr�<module>
s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists