NineSec Team Shell
Server IP : 184.107.3.203  /  Your IP : 216.73.216.51
Web Server : Apache
System : Linux dedicated2.avenfashion.com.ph 4.18.0-553.40.1.el8_10.x86_64 #1 SMP Mon Feb 10 12:11:18 EST 2025 x86_64
User : adminteladeoro ( 1015)
PHP Version : 8.2.28
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/

[  Home  ][  C0mmand  ][  Upload File  ]

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

~�g��@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�r\x*|jd�jd�D]}|jd|�d��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-namespaces�^�$)�
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_listcCs:|jd|jd����}|ddkr6|j|djd��SgS)NzRoc get namespaces -o custom-columns=NAME:.metadata.name --no-headers --kubeconfig=r	�statusr�output�
)�exec_cmdrr r)r�resrrr�_get_namespacesWs
zMicroshift._get_namespacescCs�ddddddddd	d
ddd
dddddddddddddg}g}xD|D]<}|jd|jd��d|��tjd�}|dd krB|j|�qBW|S)!z@Get cluster-level (non-namespaced) resources to collect
        ZapiservicesZcertificatesigningrequestsZclusterrolebindingsZclusterrolesZcomponentstatusesZ
csidriversZcsinodesZcustomresourcedefinitionsZflowschemasZingressclassesZlogicalvolumesZmutatingwebhookconfigurationsZnodesZpersistentvolumesZpriorityclassesZprioritylevelconfigurationsZrangeallocationsZruntimeclassesZsecuritycontextconstraintsZselfsubjectaccessreviewsZselfsubjectrulesreviewsZstorageclassesZsubjectaccessreviewsZtokenreviewsZvalidatingwebhookconfigurationsZvolumeattachmentszoc get --kubeconfig r	� )�timeoutr!r)r$rr�plugin_timeoutr)rZglobal_resourcesZ_filtered_resourcesZresourcer%rrr�_get_cluster_resourcesasD

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|�d|�d
|��dtjd�|jd|�d|�d
|��dtj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�,r'cSsg|]}d|���qS)zns/r)rrrrr�
<listcomp>�sz$Microshift.setup.<locals>.<listcomp>F)Zmaker	zoc adm inspect --kubeconfig z --dest-dir zinspect_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_pathrr))rZ_cluster_resources_to_collectZ_namespaces_to_collectZ_subdirZ_kubeconfigrrr�setup�s0	





zMicroshift.setupN)rrr)�__name__�
__module__�__qualname__�__doc__Z
short_descr.r)ZpackagesZservicesZprofilesZlocalhost_kubeconfigr�strZoption_listrr r&r*r/rrrrrs&


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

NineSec Team - 2022