|
|
ce36b2 |
From 0618db904dadb05fde70c181a5940989ac127fe2 Mon Sep 17 00:00:00 2001
|
|
|
ce36b2 |
From: Irit Goihman <igoihman@redhat.com>
|
|
|
ce36b2 |
Date: Thu, 1 Feb 2018 16:44:32 +0200
|
|
|
ce36b2 |
Subject: [PATCH] [plugins] add vdsm plugin
|
|
|
ce36b2 |
|
|
|
ce36b2 |
Add a plugin for vdsm
|
|
|
ce36b2 |
|
|
|
ce36b2 |
Resolves: #1205
|
|
|
ce36b2 |
|
|
|
ce36b2 |
Signed-off-by: Irit Goihman <igoihman@redhat.com>
|
|
|
ce36b2 |
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
|
|
|
ce36b2 |
---
|
|
|
ce36b2 |
sos/plugins/vdsm.py | 146 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ce36b2 |
1 file changed, 146 insertions(+)
|
|
|
ce36b2 |
create mode 100644 sos/plugins/vdsm.py
|
|
|
ce36b2 |
|
|
|
ce36b2 |
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
|
|
|
ce36b2 |
new file mode 100644
|
|
|
ce36b2 |
index 00000000..c648abbf
|
|
|
ce36b2 |
--- /dev/null
|
|
|
ce36b2 |
+++ b/sos/plugins/vdsm.py
|
|
|
ce36b2 |
@@ -0,0 +1,146 @@
|
|
|
ce36b2 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+# This file is part of the sos project: https://github.com/sosreport/sos
|
|
|
ce36b2 |
+#
|
|
|
ce36b2 |
+# This copyrighted material is made available to anyone wishing to use,
|
|
|
ce36b2 |
+# modify, copy, or redistribute it subject to the terms and conditions of
|
|
|
ce36b2 |
+# version 2 of the GNU General Public License.
|
|
|
ce36b2 |
+#
|
|
|
ce36b2 |
+# See the LICENSE file in the source distribution for further information.
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+from sos.plugins import Plugin, RedHatPlugin
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+import glob
|
|
|
ce36b2 |
+import json
|
|
|
ce36b2 |
+import re
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+# This configuration is based on vdsm.storage.lvm.LVM_CONF_TEMPLATE.
|
|
|
ce36b2 |
+#
|
|
|
ce36b2 |
+# locking_type is set to 0 in order to match lvm sos commands. With this
|
|
|
ce36b2 |
+# configuration we don't take any locks, so we will never block because
|
|
|
ce36b2 |
+# there is a stuck lvm command.
|
|
|
ce36b2 |
+# locking_type=0
|
|
|
ce36b2 |
+#
|
|
|
ce36b2 |
+# use_lvmetad is set to 0 in order not to show cached, old lvm metadata.
|
|
|
ce36b2 |
+# use_lvmetad=0
|
|
|
ce36b2 |
+#
|
|
|
ce36b2 |
+# preferred_names and filter config values are set to capture Vdsm devices.
|
|
|
ce36b2 |
+# preferred_names=[ '^/dev/mapper/' ]
|
|
|
ce36b2 |
+# filter=[ 'a|^/dev/mapper/.*|', 'r|.*|' ]
|
|
|
ce36b2 |
+LVM_CONFIG = """
|
|
|
ce36b2 |
+global {
|
|
|
ce36b2 |
+ locking_type=0
|
|
|
ce36b2 |
+ use_lvmetad=0
|
|
|
ce36b2 |
+}
|
|
|
ce36b2 |
+devices {
|
|
|
ce36b2 |
+ preferred_names=["^/dev/mapper/"]
|
|
|
ce36b2 |
+ ignore_suspended_devices=1
|
|
|
ce36b2 |
+ write_cache_state=0
|
|
|
ce36b2 |
+ disable_after_error_count=3
|
|
|
ce36b2 |
+ filter=["a|^/dev/mapper/.*|", "r|.*|"]
|
|
|
ce36b2 |
+}
|
|
|
ce36b2 |
+"""
|
|
|
ce36b2 |
+LVM_CONFIG = re.sub(r"\s+", " ", LVM_CONFIG).strip()
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+class Vdsm(Plugin, RedHatPlugin):
|
|
|
ce36b2 |
+ """vdsm Plugin"""
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ packages = (
|
|
|
ce36b2 |
+ 'vdsm',
|
|
|
ce36b2 |
+ 'vdsm-client',
|
|
|
ce36b2 |
+ )
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ plugin_name = 'vdsm'
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ def setup(self):
|
|
|
ce36b2 |
+ self.add_forbidden_path('/etc/pki/vdsm/keys/*')
|
|
|
ce36b2 |
+ self.add_forbidden_path('/etc/pki/vdsm/libvirt-spice/*-key.*')
|
|
|
ce36b2 |
+ self.add_forbidden_path('/etc/pki/libvirt/private/*')
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ self.add_cmd_output('service vdsmd status')
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ self.add_copy_spec([
|
|
|
ce36b2 |
+ '/tmp/vds_installer*',
|
|
|
ce36b2 |
+ '/tmp/vds_bootstrap*',
|
|
|
ce36b2 |
+ '/etc/vdsm/*'
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ limit = self.get_option('log_size')
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ self.add_copy_spec('/var/log/vdsm/*', sizelimit=limit)
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ self._add_vdsm_forbidden_paths()
|
|
|
ce36b2 |
+ self.add_copy_spec([
|
|
|
ce36b2 |
+ '/var/run/vdsm/*',
|
|
|
ce36b2 |
+ '/usr/libexec/vdsm/hooks',
|
|
|
ce36b2 |
+ '/var/lib/vdsm'
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ qemu_pids = self.get_process_pids('qemu-kvm')
|
|
|
ce36b2 |
+ if qemu_pids:
|
|
|
ce36b2 |
+ files = ["cmdline", "status", "mountstats"]
|
|
|
ce36b2 |
+ self.add_copy_spec([
|
|
|
ce36b2 |
+ "/proc/%s/%s" % (pid, name)
|
|
|
ce36b2 |
+ for pid in qemu_pids
|
|
|
ce36b2 |
+ for name in files
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+ self.add_cmd_output([
|
|
|
ce36b2 |
+ "ls -ldZ /etc/vdsm",
|
|
|
ce36b2 |
+ "su vdsm -s sh -c 'tree -l /rhev/data-center'",
|
|
|
ce36b2 |
+ "su vdsm -s sh -c 'ls -lR /rhev/data-center'"
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+ self.add_cmd_output([
|
|
|
ce36b2 |
+ "lvm vgs -v -o +tags --config \'%s\'" % LVM_CONFIG,
|
|
|
ce36b2 |
+ "lvm lvs -v -o +tags --config \'%s\'" % LVM_CONFIG,
|
|
|
ce36b2 |
+ "lvm pvs -v -o +all --config \'%s\'" % LVM_CONFIG
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ self.add_cmd_output([
|
|
|
ce36b2 |
+ 'vdsm-client Host getCapabilities',
|
|
|
ce36b2 |
+ 'vdsm-client Host getStats',
|
|
|
ce36b2 |
+ 'vdsm-client Host getAllVmStats',
|
|
|
ce36b2 |
+ 'vdsm-client Host getVMFullList',
|
|
|
ce36b2 |
+ 'vdsm-client Host getDeviceList',
|
|
|
ce36b2 |
+ 'vdsm-client Host hostdevListByCaps',
|
|
|
ce36b2 |
+ 'vdsm-client Host getAllTasksInfo',
|
|
|
ce36b2 |
+ 'vdsm-client Host getAllTasksStatuses'
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ try:
|
|
|
ce36b2 |
+ res = self.call_ext_prog(
|
|
|
ce36b2 |
+ 'vdsm-client Host getConnectedStoragePools'
|
|
|
ce36b2 |
+ )
|
|
|
ce36b2 |
+ if res['status'] == 0:
|
|
|
ce36b2 |
+ pools = json.loads(res['output'])
|
|
|
ce36b2 |
+ for pool in pools:
|
|
|
ce36b2 |
+ self.add_cmd_output(
|
|
|
ce36b2 |
+ 'vdsm-client StoragePool getSpmStatus'
|
|
|
ce36b2 |
+ ' storagepoolID={}'.format(pool)
|
|
|
ce36b2 |
+ )
|
|
|
ce36b2 |
+ except ValueError as e:
|
|
|
ce36b2 |
+ self._log_error(
|
|
|
ce36b2 |
+ 'vdsm-client Host getConnectedStoragePools: %s' % (e)
|
|
|
ce36b2 |
+ )
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ try:
|
|
|
ce36b2 |
+ res = self.call_ext_prog('vdsm-client Host getStorageDomains')
|
|
|
ce36b2 |
+ if res['status'] == 0:
|
|
|
ce36b2 |
+ sd_uuids = json.loads(res['output'])
|
|
|
ce36b2 |
+ dump_volume_chains_cmd = 'vdsm-tool dump-volume-chains %s'
|
|
|
ce36b2 |
+ self.add_cmd_output([
|
|
|
ce36b2 |
+ dump_volume_chains_cmd % uuid for uuid in sd_uuids
|
|
|
ce36b2 |
+ ])
|
|
|
ce36b2 |
+ except ValueError as e:
|
|
|
ce36b2 |
+ self._log_error(
|
|
|
ce36b2 |
+ 'vdsm-client Host getStorageDomains: %s' % (e)
|
|
|
ce36b2 |
+ )
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ def _add_vdsm_forbidden_paths(self):
|
|
|
ce36b2 |
+ """Add confidential sysprep vfds under /var/run/vdsm to
|
|
|
ce36b2 |
+ forbidden paths """
|
|
|
ce36b2 |
+
|
|
|
ce36b2 |
+ for file_path in glob.glob("/var/run/vdsm/*"):
|
|
|
ce36b2 |
+ if file_path.endswith(('.vfd', '/isoUploader', '/storage')):
|
|
|
ce36b2 |
+ self.add_forbidden_path(file_path)
|
|
|
ce36b2 |
--
|
|
|
ce36b2 |
2.17.2
|
|
|
ce36b2 |
|