晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /lib/python3.6/site-packages/sos/report/plugins/ |
Upload File : |
# Copyright 2023 Red Hat, Inc. Pablo Acevedo <pacevedo@redhat.com>
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.
import re
from sos.report.plugins import Plugin, RedHatPlugin, PluginOpt
class Microshift(Plugin, RedHatPlugin):
"""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.
"""
short_desc = 'Microshift'
plugin_name = 'microshift'
plugin_timeout = 900
packages = ('microshift', 'microshift-selinux', 'microshift-networking',)
services = (plugin_name,)
profiles = (plugin_name,)
localhost_kubeconfig = '/var/lib/microshift/resources/kubeadmin/kubeconfig'
option_list = [
PluginOpt('kubeconfig', default=localhost_kubeconfig, val_type=str,
desc='Path to a locally available kubeconfig file'),
PluginOpt('only-namespaces', default='', val_type=str,
desc='colon-delimited list of namespaces to collect from'),
PluginOpt('add-namespaces', default='', val_type=str,
desc=('colon-delimited list of namespaces to add to the '
'default collection list'))
]
def _setup_namespace_regexes(self):
"""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.
"""
if self.get_option('only-namespaces'):
return list(self.get_option('only-namespaces').split(':'))
collect_regexes = [
r'^openshift\-.+$',
r'^kube\-.+$'
]
if self.get_option('add-namespaces'):
for nsp in self.get_option('add-namespaces').split(':'):
collect_regexes.append(fr'^{nsp}$')
return collect_regexes
def _reduce_namespace_list(self, nsps):
"""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
"""
def _match_namespace(namespace, regexes):
"""Match a particular namespace for inclusion (or not) in the
collection phases
:param namespace str: The name of a namespace
"""
for regex in regexes:
if re.match(regex, namespace):
return True
return False
regexes = self._setup_namespace_regexes()
return list(set(n for n in nsps if _match_namespace(n, regexes)))
def _get_namespaces(self):
res = self.exec_cmd(
'oc get namespaces'
' -o custom-columns=NAME:.metadata.name'
' --no-headers'
f' --kubeconfig={self.get_option("kubeconfig")}')
if res['status'] == 0:
return self._reduce_namespace_list(res['output'].split('\n'))
return []
def _get_cluster_resources(self):
"""Get cluster-level (non-namespaced) resources to collect
"""
global_resources = [
'apiservices',
'certificatesigningrequests',
'clusterrolebindings',
'clusterroles',
'componentstatuses',
'csidrivers',
'csinodes',
'customresourcedefinitions',
'flowschemas',
'ingressclasses',
'logicalvolumes',
'mutatingwebhookconfigurations',
'nodes',
'persistentvolumes',
'priorityclasses',
'prioritylevelconfigurations',
'rangeallocations',
'runtimeclasses',
'securitycontextconstraints',
'selfsubjectaccessreviews',
'selfsubjectrulesreviews',
'storageclasses',
'subjectaccessreviews',
'tokenreviews',
'validatingwebhookconfigurations',
'volumeattachments'
]
_filtered_resources = []
for resource in global_resources:
res = self.exec_cmd(
f"oc get --kubeconfig {self.get_option('kubeconfig')} "
f"{resource}",
timeout=Microshift.plugin_timeout)
if res['status'] == 0:
_filtered_resources.append(resource)
return _filtered_resources
def setup(self):
"""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.
"""
self.add_journal('microshift-etcd.scope')
self.add_copy_spec('/etc/microshift')
if self.path_exists('/var/lib/microshift-backups'):
self.add_copy_spec(['/var/lib/microshift-backups/*/version',
'/var/lib/microshift-backups/*.json'])
self.add_copy_spec(['/var/log/kube-apiserver/*.log'])
self.add_cmd_output([
'microshift version',
'microshift show-config -m effective'
])
_cluster_resources_to_collect = ",".join(
self._get_cluster_resources())
_namespaces_to_collect = " ".join(
[f'ns/{n}' for n in self._get_namespaces()])
if self.is_service_running(Microshift.plugin_name):
_subdir = self.get_cmd_output_path(make=False)
_kubeconfig = self.get_option('kubeconfig')
self.add_cmd_output(
f'oc adm inspect --kubeconfig {_kubeconfig} --dest-dir '
f'{_subdir} {_cluster_resources_to_collect}',
suggest_filename='inspect_cluster_resources.log',
timeout=Microshift.plugin_timeout)
self.add_cmd_output(
f'oc adm inspect --kubeconfig {_kubeconfig} --dest-dir '
f'{_subdir} {_namespaces_to_collect}',
suggest_filename='inspect_namespaces.log',
timeout=Microshift.plugin_timeout)