Change in vdsm[master]: sos: Support to SOS 3

dougsland at redhat.com dougsland at redhat.com
Thu Feb 27 20:04:56 UTC 2014


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: sos: Support to SOS 3
......................................................................

sos: Support to SOS 3

This patch will add support to sos 3 API and keep compatible
with old API.

Change-Id: I52fbd9431506c5862cc762b4d3f0701ab5cf6a0b
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1060383
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M configure.ac
M vdsm.spec.in
M vdsm/sos/vdsm.py.in
3 files changed, 73 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/25188/1

diff --git a/configure.ac b/configure.ac
index 55879e7..fd61e03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,26 @@
 )
 AM_CONDITIONAL([HOOKS], [test "${enable_hooks}" = "yes"])
 
+AC_MSG_CHECKING(sos version)
+    AC_ARG_VAR([SOS_VERSION], [SOS utility version])
+    SOS_VERSION=`$PYTHON -c "import sos; print(sos.__version__)" |cut -c1 2>/dev/null`
+    AC_MSG_RESULT($SOS_VERSION)
+
+# SOS - support API 2 and 3 calls
+if test x"${SOS_VERSION}" = x2; then
+  AC_SUBST([SOS_ADD_COPY_SPEC], ["addCopySpec"])
+  AC_SUBST([SOS_ADD_COPY_SPEC_LIMIT], ["addCopySpecLimit"])
+  AC_SUBST([SOS_CLASS], ["vdsm(sos.plugintools.PluginBase)"])
+  AC_SUBST([SOS_CMD_OUTPUT], ["collectExtOutput"])
+  AC_SUBST([SOS_GET_OPTION], ["getOption"])
+else
+  AC_SUBST([SOS_ADD_COPY_SPEC], ["add_copy_spec"])
+  AC_SUBST([SOS_ADD_COPY_SPEC_LIMIT], ["add_copy_spec_limit"])
+  AC_SUBST([SOS_CLASS], ["Vdsm(Plugin, RedHatPlugin)"])
+  AC_SUBST([SOS_CMD_OUTPUT], ["add_cmd_output"])
+  AC_SUBST([SOS_GET_OPTION], ["get_option"])
+fi
+
 AC_ARG_ENABLE(
     [libvirt-sanlock],
     [AS_HELP_STRING(
@@ -185,6 +205,7 @@
 AX_PYTHON_MODULE([pthreading], [fatal])
 AX_PYTHON_MODULE([pyinotify], [fatal])
 AX_PYTHON_MODULE([selinux], [fatal])
+AX_PYTHON_MODULE([sos], [fatal])
 
 # External programs (sorted, please keep in order)
 AC_PATH_PROG([BLKID_PATH], [blkid], [/sbin/blkid])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 0383532..3be91c7 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -97,6 +97,8 @@
 BuildRequires: python-pep8
 %endif
 
+BuildRequires: sos
+
 %if 0%{?with_systemd}
 BuildRequires: systemd-units
 %endif
@@ -241,7 +243,13 @@
 
 Requires: psmisc >= 22.6-15
 Requires: bridge-utils
-Requires: sos
+
+%if 0%{fedora} >= 20 || 0%{?rhel} >= 7
+Requires: sos >= 3.1
+%else
+Requires: sos < 3
+%endif
+
 Requires: tree
 Requires: dosfstools
 Requires: genisoimage
diff --git a/vdsm/sos/vdsm.py.in b/vdsm/sos/vdsm.py.in
index 6bc111a..50f0ac2 100644
--- a/vdsm/sos/vdsm.py.in
+++ b/vdsm/sos/vdsm.py.in
@@ -18,7 +18,11 @@
 # Refer to the README and COPYING files for full details of the license
 #
 
-import sos.plugintools
+try:
+    from sos.plugins import Plugin, RedHatPlugin
+except:
+    import sos.plugintools
+
 import subprocess
 import os
 
@@ -39,7 +43,7 @@
 config = _importVdsmPylibModule('config').config
 
 
-class vdsm(sos.plugintools.PluginBase):
+class @SOS_CLASS@:
     """VDSM server related information
     """
 
@@ -54,64 +58,64 @@
         irrespective of their size.
         """
         if logsize is not None:
-            self.addCopySpecLimit(path, logsize)
+            self. at SOS_ADD_COPY_SPEC_LIMIT@(path, logsize)
         else:
-            self.addCopySpec(path)
+            self. at SOS_ADD_COPY_SPEC@(path)
 
     def setup(self):
         os.environ["LVM_SYSTEM_DIR"] = "@VDSMRUNDIR@/lvm"
-        self.collectExtOutput("/etc/init.d/vdsmd status")
-        self.addCopySpec("/tmp/vds_installer*")
-        self.addCopySpec("/tmp/vds_bootstrap*")
-        self.addCopySpec("/etc/vdsm/*")
-        self.addCopySpec("/etc/vdsm-reg/*")
-        logsize = self.getOption('logsize')
+        self. at SOS_CMD_OUTPUT@("/etc/init.d/vdsmd status")
+        self. at SOS_ADD_COPY_SPEC@("/tmp/vds_installer*")
+        self. at SOS_ADD_COPY_SPEC@("/tmp/vds_bootstrap*")
+        self. at SOS_ADD_COPY_SPEC@("/etc/vdsm/*")
+        self. at SOS_ADD_COPY_SPEC@("/etc/vdsm-reg/*")
+        logsize = self. at SOS_GET_OPTION@('logsize')
         self.__addCopySpecLogLimit("/var/log/vdsm/*", logsize)
         self.__addCopySpecLogLimit("/var/log/vdsm-reg/*", logsize)
         self._addVdsmRunDir()
-        self.addCopySpec("@TRUSTSTORE@")
-        self.addCopySpec("@HOOKSDIR@")
-        self.addCopySpec("/var/log/ovirt.log")
-        self.addCopySpec("/var/log/sanlock.log")
+        self. at SOS_ADD_COPY_SPEC@("@TRUSTSTORE@")
+        self. at SOS_ADD_COPY_SPEC@("@HOOKSDIR@")
+        self. at SOS_ADD_COPY_SPEC@("/var/log/ovirt.log")
+        self. at SOS_ADD_COPY_SPEC@("/var/log/sanlock.log")
         p = subprocess.Popen(['/usr/bin/pgrep', 'qemu-kvm'],
                              stdout=subprocess.PIPE)
         out, err = p.communicate()
         for line in out.splitlines():
             pid = line.strip()
-            self.addCopySpec("/proc/%s/cmdline" % pid)
-            self.addCopySpec("/proc/%s/status" % pid)
-            self.addCopySpec("/proc/%s/mountstats" % pid)
-        self.collectExtOutput("/bin/ls -l /var/log/core")
-        self.collectExtOutput("/bin/ls -ldZ /etc/vdsm")
-        self.collectExtOutput(
+            self. at SOS_ADD_COPY_SPEC@("/proc/%s/cmdline" % pid)
+            self. at SOS_ADD_COPY_SPEC@("/proc/%s/status" % pid)
+            self. at SOS_ADD_COPY_SPEC@("/proc/%s/mountstats" % pid)
+        self. at SOS_CMD_OUTPUT@("/bin/ls -l /var/log/core")
+        self. at SOS_CMD_OUTPUT@("/bin/ls -ldZ /etc/vdsm")
+        self. at SOS_CMD_OUTPUT@(
             "/bin/su vdsm -s /bin/sh -c '/usr/bin/tree -l @VDSMREPO@'")
-        self.collectExtOutput(
+        self. at SOS_CMD_OUTPUT@(
             "/bin/su vdsm -s /bin/sh -c '/bin/ls -lR @VDSMREPO@'")
-        self.collectExtOutput("/sbin/lvm vgs -v -o +tags")
-        self.collectExtOutput("/sbin/lvm lvs -v -o +tags")
-        self.collectExtOutput("/sbin/lvm pvs -v -o +all")
-        self.collectExtOutput("/sbin/fdisk -l")
-        self.collectExtOutput("/usr/bin/iostat")
-        self.collectExtOutput("/sbin/iscsiadm -m node")
-        self.collectExtOutput("/sbin/iscsiadm -m session")
+        self. at SOS_CMD_OUTPUT@("/sbin/lvm vgs -v -o +tags")
+        self. at SOS_CMD_OUTPUT@("/sbin/lvm lvs -v -o +tags")
+        self. at SOS_CMD_OUTPUT@("/sbin/lvm pvs -v -o +all")
+        self. at SOS_CMD_OUTPUT@("/sbin/fdisk -l")
+        self. at SOS_CMD_OUTPUT@("/usr/bin/iostat")
+        self. at SOS_CMD_OUTPUT@("/sbin/iscsiadm -m node")
+        self. at SOS_CMD_OUTPUT@("/sbin/iscsiadm -m session")
         sslopt = ['', '-s '][config.getboolean('vars', 'ssl')]
         vdsclient = "/usr/bin/vdsClient " + sslopt + "0 "
-        self.collectExtOutput(vdsclient + "getVdsCapabilities")
-        self.collectExtOutput(vdsclient + "getVdsStats")
-        self.collectExtOutput(vdsclient + "getAllVmStats")
-        self.collectExtOutput(vdsclient + "list")
-        self.collectExtOutput(vdsclient + "getVGList")
-        self.collectExtOutput(vdsclient + "getDeviceList")
-        self.collectExtOutput(vdsclient + "getAllTasksInfo")
-        self.collectExtOutput(vdsclient + "getAllTasksStatuses")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getVdsCapabilities")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getVdsStats")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getAllVmStats")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "list")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getVGList")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getDeviceList")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getAllTasksInfo")
+        self. at SOS_CMD_OUTPUT@(vdsclient + "getAllTasksStatuses")
         p = subprocess.Popen(vdsclient + "getConnectedStoragePoolsList",
                              shell=True, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         out, err = p.communicate()
         for line in out.splitlines()[1:-1]:
             pool = line.strip()
-            self.collectExtOutput(vdsclient + "getSpmStatus " + pool)
-        self.collectExtOutput(
+            self. at SOS_CMD_OUTPUT@(vdsclient + "getSpmStatus " + pool)
+        self. at SOS_CMD_OUTPUT@(
             '/bin/su vdsm -s @PYTHON@ @VDSMDIR@/dumpStorageTable.pyc')
 
     def _addVdsmRunDir(self):
@@ -123,4 +127,4 @@
         for f in glob.glob("@VDSMRUNDIR@/*"):
             if not f.endswith('.vfd') and not f.endswith('/isoUploader') \
                     and not f.endswith('/storage'):
-                self.addCopySpec(f)
+                self. at SOS_ADD_COPY_SPEC@(f)


-- 
To view, visit http://gerrit.ovirt.org/25188
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52fbd9431506c5862cc762b4d3f0701ab5cf6a0b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>


More information about the vdsm-patches mailing list