[Kimchi-devel] [PATCH 3/5] Add sos plugin for kimchi

Paulo Vital pvital at linux.vnet.ibm.com
Fri Aug 15 15:29:32 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>

Conflicts:
	contrib/kimchi.spec.fedora.in
---
 contrib/kimchi.spec.fedora.in |  3 +++
 src/kimchi/Makefile.am        |  4 +++-
 src/kimchi/sos.py             | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 43 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 5766784..78dd423 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -78,6 +78,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
@@ -158,6 +160,7 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/kimchi/model/*.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/kimchi-guest.png
diff --git a/src/kimchi/Makefile.am b/src/kimchi/Makefile.am
index e2b5bea..a405782 100644
--- a/src/kimchi/Makefile.am
+++ b/src/kimchi/Makefile.am
@@ -19,10 +19,12 @@
 
 SUBDIRS = control model
 
-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..f43c4bd
--- /dev/null
+++ b/src/kimchi/sos.py
@@ -0,0 +1,37 @@
+### This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program 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 General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin
+
+
+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, _ = self.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