From: Mark Wu <wudxw(a)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(a)linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget(a)linux.vnet.ibm.com>
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
Makefile.am | 1 +
contrib/kimchi.spec.fedora.in | 3 +++
src/kimchi/Makefile.am | 4 +++-
src/kimchi/sos.py | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 src/kimchi/sos.py
diff --git a/Makefile.am b/Makefile.am
index 3293d9e..8776760 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,6 +69,7 @@ PEP8_WHITELIST = \
src/kimchi/root.py \
src/kimchi/scan.py \
src/kimchi/server.py \
+ src/kimchi/sos.py \
src/kimchi/swupdate.py \
src/kimchi/template.py \
src/kimchi/utils.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..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