[Kimchi-devel] [PATCH 1/2] Add sos plugin for kimchi

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Thu Oct 30 16:44:41 UTC 2014


From: Mark Wu <wudxw at linux.vnet.ibm.com>

This patches adds a sos plugin to collect kimchi's configuration,
log files and other information for diagnosis.

Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget at linux.vnet.ibm.com>
Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
 contrib/kimchi.spec.fedora.in |  3 +++
 src/kimchi/Makefile.am        |  4 +++-
 src/kimchi/sos.py             | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 src/kimchi/sos.py

diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 236c862..d58f3eb 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -80,6 +80,8 @@ make
 %install
 rm -rf %{buildroot}
 make DESTDIR=%{buildroot} install
+install -Dm 0644 src/kimchi/sos.py \
+                 %{buildroot}/%{python_sitelib}/sos/plugins/kimchi.py
 
 %if 0%{?with_systemd}
 # Install the systemd scripts
@@ -161,6 +163,7 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/kimchi/xmlutils/*.py*
 %{python_sitelib}/kimchi/API.json
 %{python_sitelib}/kimchi/plugins/*.py*
+%{python_sitelib}/sos/plugins/kimchi.py*
 %{_datadir}/kimchi/doc/API.md
 %{_datadir}/kimchi/doc/README.md
 %{_datadir}/kimchi/doc/README-federation.md
diff --git a/src/kimchi/Makefile.am b/src/kimchi/Makefile.am
index 5c204e0..c28e92d 100644
--- a/src/kimchi/Makefile.am
+++ b/src/kimchi/Makefile.am
@@ -19,10 +19,12 @@
 
 SUBDIRS = control model xmlutils
 
-kimchi_PYTHON = $(filter-out config.py, $(wildcard *.py))
+kimchi_PYTHON = $(filter-out config.py sos.py, $(wildcard *.py))
 
 nodist_kimchi_PYTHON = config.py
 
+dist_noinst_PYTHON = sos.py
+
 EXTRA_DIST = \
 	API.json \
 	config.py.in
diff --git a/src/kimchi/sos.py b/src/kimchi/sos.py
new file mode 100644
index 0000000..5d1fa3f
--- /dev/null
+++ b/src/kimchi/sos.py
@@ -0,0 +1,43 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin
+from sos.utilities import sos_get_command_output
+
+
+class Kimchi(Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin):
+    """
+    kimchi-related information
+    """
+
+    plugin_name = 'kimchi'
+
+    def setup(self):
+        self.add_copy_specs([
+            "/etc/kimchi/",
+            "/var/log/kimchi*"
+        ])
+        self.add_cmd_output("virsh pool-list --details")
+        rc, out, _ = sos_get_command_output('virsh pool-list')
+        if rc == 0:
+            for pool in out.splitlines()[2:]:
+                if pool:
+                    pool_name = pool.split()[0]
+                    self.add_cmd_output("virsh vol-list --pool %s --details"
+                                        % pool_name)
-- 
1.9.3




More information about the Kimchi-devel mailing list