Change in vdsm[master]: Move multipath configuration to vdsm-tool configurator

ykaplan at redhat.com ykaplan at redhat.com
Wed Mar 26 15:21:20 UTC 2014


Yeela Kaplan has uploaded a new change for review.

Change subject: Move multipath configuration to vdsm-tool configurator
......................................................................

Move multipath configuration to vdsm-tool configurator

Previously multipathe is recofigured on each vdsm
service restart.
Now it will be reconfigured only on user demand.

Change-Id: I40f802477e39000c5cae01a496ac2d9f879ebfa8
Signed-off-by: Yeela Kaplan <ykaplan at redhat.com>
---
M lib/vdsm/tool/configurator.py
M lib/vdsm/utils.py
M tests/miscTests.py
M tests/utilsTests.py
M vdsm/caps.py
M vdsm/storage/hsm.py
M vdsm/storage/misc.py
M vdsm/storage/multipath.py
M vdsm/storage/sd.py
M vdsm/supervdsmServer
10 files changed, 301 insertions(+), 281 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/26123/1

diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index 869d774..d97af61 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -21,11 +21,10 @@
 import sys
 import grp
 import argparse
+import tempfile
 
-from .. import utils
+from .. import utils, constants
 from . import service, expose
-from ..constants import P_VDSM_EXEC, DISKIMAGE_GROUP
-from ..constants import QEMU_PROCESS_GROUP, VDSM_GROUP
 
 
 class _ModuleConfigure(object):
@@ -68,7 +67,7 @@
         rc, out, err = utils.execCmd(
             (
                 os.path.join(
-                    P_VDSM_EXEC,
+                    constants.P_VDSM_EXEC,
                     'libvirt_configure.sh'
                 ),
                 action,
@@ -126,7 +125,7 @@
                 '/usr/sbin/usermod',
                 '-a',
                 '-G',
-                '%s,%s' % (QEMU_PROCESS_GROUP, VDSM_GROUP),
+                '%s,%s' % (constants.QEMU_PROCESS_GROUP, constants.VDSM_GROUP),
                 'sanlock'
             ),
             raw=True,
@@ -156,7 +155,7 @@
                         break
                 else:
                     raise RuntimeError("Unable to find sanlock service groups")
-            ret = grp.getgrnam(DISKIMAGE_GROUP)[2] in groups
+            ret = grp.getgrnam(constants.DISKIMAGE_GROUP)[2] in groups
         except IOError as e:
             if e.errno == os.errno.ENOENT:
                 sys.stdout.write("sanlock service is not running\n")
@@ -172,9 +171,149 @@
         return ret
 
 
+MPATH_CONF = "/etc/multipath.conf"
+
+STRG_MPATH_CONF = (
+    "\n\n"
+    "defaults {\n"
+    "    polling_interval        5\n"
+    "    getuid_callout          \"%(scsi_id_path)s --whitelisted "
+    "--replace-whitespace --device=/dev/%%n\"\n"
+    "    no_path_retry           fail\n"
+    "    user_friendly_names     no\n"
+    "    flush_on_last_del       yes\n"
+    "    fast_io_fail_tmo        5\n"
+    "    dev_loss_tmo            30\n"
+    "    max_fds                 4096\n"
+    "}\n"
+    "\n"
+    "devices {\n"
+    "device {\n"
+    "    vendor                  \"HITACHI\"\n"
+    "    product                 \"DF.*\"\n"
+    "    getuid_callout          \"%(scsi_id_path)s --whitelisted "
+    "--replace-whitespace --device=/dev/%%n\"\n"
+    "}\n"
+    "device {\n"
+    "    vendor                  \"COMPELNT\"\n"
+    "    product                 \"Compellent Vol\"\n"
+    "    no_path_retry           fail\n"
+    "}\n"
+    "}"
+)
+
+OLD_TAGS = ["# RHAT REVISION 0.2", "# RHEV REVISION 0.3",
+            "# RHEV REVISION 0.4", "# RHEV REVISION 0.5",
+            "# RHEV REVISION 0.6", "# RHEV REVISION 0.7",
+            "# RHEV REVISION 0.8", "# RHEV REVISION 0.9"]
+MPATH_CONF_TAG = "# RHEV REVISION 1.0"
+MPATH_CONF_PRIVATE_TAG = "# RHEV PRIVATE"
+
+MPATH_CONF_TEMPLATE = MPATH_CONF_TAG + STRG_MPATH_CONF
+
+MAX_CONF_COPIES = 5
+
+_scsi_id = utils.CommandPath("scsi_id",
+                         "/sbin/scsi_id",  # EL6
+                         "/usr/lib/udev/scsi_id",  # Fedora
+                         "/lib/udev/scsi_id",  # Ubuntu
+                         )
+
+
+class MultipathModuleConfigure(_ModuleConfigure):
+
+    def __init__(self):
+        super(MultipathModuleConfigure, self).__init__()
+
+    def getName(self):
+        return 'multipath'
+
+    def getServices(self):
+        return ["multipathd"]
+
+    def configure(self):
+        """
+        Set up the multipath daemon configuration to the known and
+        supported state. The original configuration, if any, is saved
+        """
+        if os.getuid() != 0:
+            raise UserWarning("Must run as root")
+        if self.isconfigured():
+            return
+        if os.path.exists(MPATH_CONF):
+            utils.rotateFiles(
+                os.path.dirname(MPATH_CONF),
+                os.path.basename(MPATH_CONF), MAX_CONF_COPIES,
+                cp=True, persist=True)
+        with tempfile.NamedTemporaryFile() as f:
+            f.write(MPATH_CONF_TEMPLATE % {'scsi_id_path': _scsi_id.cmd})
+            f.flush()
+            cmd = [constants.EXT_CP, f.name, MPATH_CONF]
+            rc, out, err = utils.execCmd(cmd)
+
+            if rc != 0:
+                raise RuntimeError("Failed to perform Multipath config.")
+        utils.persistFile(MPATH_CONF)
+
+        # Flush all unused multipath device maps
+        utils.execCmd([constants.EXT_MULTIPATH, "-F"])
+
+        cmd = [constants.EXT_VDSM_TOOL, "service-reload", "multipathd"]
+        rc, out, err = utils.execCmd(cmd)
+        if rc != 0:
+            raise RuntimeError("Failed to reload Multipath.")
+
+
+    def isconfigured(self, *args):
+        """
+        Check the multipath daemon configuration. The configuration file
+        /etc/multipath.conf should contain private tag in form
+        "RHEV REVISION X.Y" for this check to succeed.
+        If the tag above is followed by tag "RHEV PRIVATE" the configuration
+        should be preserved at all cost.
+
+        """
+        if os.getuid() != 0:
+                raise UserWarning("Must run as root")
+
+        if os.path.exists(MPATH_CONF):
+            first = second = ''
+            with open(MPATH_CONF) as f:
+                mpathconf = [x.strip("\n") for x in f.readlines()]
+            try:
+                first = mpathconf[0]
+                second = mpathconf[1]
+            except IndexError:
+                pass
+            if MPATH_CONF_PRIVATE_TAG in second:
+                sys.stdout.write("Manual override for multipath.conf detected"
+                                 " - preserving current configuration")
+                if MPATH_CONF_TAG not in first:
+                    sys.stdout.write("This manual override for multipath.conf "
+                                     "was based on downrevved template. "
+                                     "You are strongly advised to "
+                                     "contact your support representatives")
+                return True
+
+            if MPATH_CONF_TAG in first:
+                sys.stdout.write("Current revision of multipath.conf detected,"
+                                 " preserving")
+                return True
+
+            for tag in OLD_TAGS:
+                if tag in first:
+                    sys.stdout.write("Downrev multipath.conf detected, "
+                                     "upgrade required")
+                    return False
+
+        sys.stdout.write("multipath Defaulting to False")
+        return False
+
+
 __configurers = (
     LibvirtModuleConfigure(),
     SanlockModuleConfigure(),
+    MultipathModuleConfigure(),
 )
 
 
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index b072bd4..b6a2ecc 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -79,6 +79,15 @@
     HIGH = 19
 
 
+class OSName:
+    UNKNOWN = 'unknown'
+    OVIRT = 'oVirt Node'
+    RHEL = 'RHEL'
+    FEDORA = 'Fedora'
+    RHEVH = 'RHEV Hypervisor'
+    DEBIAN = 'Debian'
+
+
 class GeneralException(Exception):
     code = 100
     message = "General Exception"
@@ -144,6 +153,62 @@
             logging.warning("Directory: %s already removed", directoryToRemove)
         else:
             raise
+
+
+def rotateFiles(directory, prefixName, gen, cp=False, persist=False):
+    logging.debug("dir: %s, prefixName: %s, versions: %s" %
+                 (directory, prefixName, gen))
+    gen = int(gen)
+    files = os.listdir(directory)
+    files = glob.glob("%s*" % prefixName)
+    fd = {}
+    for fname in files:
+        name = fname.rsplit('.', 1)
+        try:
+            ind = int(name[1])
+        except ValueError:
+            name[0] = fname
+            ind = 0
+        except IndexError:
+            ind = 0
+        except:
+            continue
+        if ind < gen:
+            fd[ind] = {'old': fname, 'new': name[0] + '.' + str(ind + 1)}
+
+    keys = fd.keys()
+    keys.sort(reverse=True)
+    logging.debug("versions found: %s" % (keys))
+
+    for key in keys:
+        oldName = os.path.join(directory, fd[key]['old'])
+        newName = os.path.join(directory, fd[key]['new'])
+        if isOvirtNode() and persist and not cp:
+            try:
+                execCmd([constants.EXT_UNPERSIST, oldName], logErr=False,
+                        sudo=True)
+                execCmd([constants.EXT_UNPERSIST, newName], logErr=False,
+                        sudo=True)
+            except:
+                pass
+        try:
+            if cp:
+                execCmd([constants.EXT_CP, oldName, newName], sudo=True)
+                if isOvirtNode() and persist and not os.path.exists(newName):
+                    execCmd([constants.EXT_PERSIST, newName], logErr=False,
+                            sudo=True)
+
+            else:
+                os.rename(oldName, newName)
+        except:
+            pass
+        if isOvirtNode() and persist and not cp:
+            try:
+                execCmd([constants.EXT_PERSIST, newName], logErr=False,
+                        sudo=True)
+            except:
+                pass
+
 
 IPXMLRPCRequestHandler = SimpleXMLRPCRequestHandler
 
@@ -826,6 +891,31 @@
         return functools.partial(self.__call__, obj)
 
 
+ at memoized
+def getos():
+    if os.path.exists('/etc/rhev-hypervisor-release'):
+        return OSName.RHEVH
+    elif glob.glob('/etc/ovirt-node-*-release'):
+        return OSName.OVIRT
+    elif os.path.exists('/etc/fedora-release'):
+        return OSName.FEDORA
+    elif os.path.exists('/etc/redhat-release'):
+        return OSName.RHEL
+    elif os.path.exists('/etc/debian_version'):
+        return OSName.DEBIAN
+    else:
+        return OSName.UNKNOWN
+
+
+def isOvirtNode():
+    return getos() in (OSName.RHEVH, OSName.OVIRT)
+
+
+def persistFile(name):
+    if isOvirtNode():
+        execCmd([constants.EXT_PERSIST, name], sudo=True)
+
+
 def validateMinimalKeySet(dictionary, reqParams):
     if not all(key in dictionary for key in reqParams):
         raise ValueError
diff --git a/tests/miscTests.py b/tests/miscTests.py
index fb1191b..1932a43 100644
--- a/tests/miscTests.py
+++ b/tests/miscTests.py
@@ -242,63 +242,6 @@
         self.assertRaises(ValueError, misc.itmap(int, data, 0).next)
 
 
-class RotateFiles(TestCaseBase):
-    def testNonExistingDir(self, persist=False):
-        """
-        Tests that the method fails correctly when given a non existing dir.
-        """
-        self.assertRaises(OSError, misc.rotateFiles, "/I/DONT/EXIST", "prefix",
-                          2, persist=persist)
-
-    def testEmptyDir(self, persist=False):
-        """
-        Test that when given an empty dir the rotator works correctly.
-        """
-        prefix = "prefix"
-        dir = tempfile.mkdtemp()
-
-        misc.rotateFiles(dir, prefix, 0, persist=persist)
-
-        os.rmdir(dir)
-
-    def testFullDir(self, persist=False):
-        """
-        Test that rotator does it's basic functionality.
-        """
-        #Prepare
-        prefix = "prefix"
-        stubContent = ('"Multiple exclamation marks", '
-                       'he went on, shaking his head, '
-                       '"are a sure sign of a diseased mind."')
-        # (C) Terry Pratchet - Small Gods
-        dir = tempfile.mkdtemp()
-        gen = 10
-
-        expectedDirContent = []
-        for i in range(gen):
-            fname = "%s.txt.%d" % (prefix, i + 1)
-            expectedDirContent.append("%s.txt.%d" % (prefix, i + 1))
-            f = open(os.path.join(dir, fname), "wb")
-            f.write(stubContent)
-            f.flush()
-            f.close()
-
-        #Rotate
-        misc.rotateFiles(dir, prefix, gen, persist=persist)
-
-        #Test result
-        currentDirContent = os.listdir(dir)
-        expectedDirContent.sort()
-        currentDirContent.sort()
-        try:
-            self.assertEquals(currentDirContent, expectedDirContent)
-        finally:
-            #Clean
-            for f in os.listdir(dir):
-                os.unlink(os.path.join(dir, f))
-            os.rmdir(dir)
-
-
 class ParseHumanReadableSize(TestCaseBase):
     def testValidInput(self):
         """
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index c5b250d..1e202d2 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -22,6 +22,7 @@
 import contextlib
 import errno
 import logging
+import tempfile
 
 from testrunner import VdsmTestCase as TestCaseBase
 from vdsm import utils
@@ -302,3 +303,60 @@
     def handle(self, record):
         assert self.record is None
         self.record = record
+
+
+class RotateFiles(TestCaseBase):
+    def testNonExistingDir(self, persist=False):
+        """
+        Tests that the method fails correctly when given a non existing dir.
+        """
+        self.assertRaises(OSError, utils.rotateFiles, "/I/DONT/EXIST",
+                          "prefix", 2, persist=persist)
+
+    def testEmptyDir(self, persist=False):
+        """
+        Test that when given an empty dir the rotator works correctly.
+        """
+        prefix = "prefix"
+        dir = tempfile.mkdtemp()
+
+        utils.rotateFiles(dir, prefix, 0, persist=persist)
+
+        os.rmdir(dir)
+
+    def testFullDir(self, persist=False):
+        """
+        Test that rotator does it's basic functionality.
+        """
+        #Prepare
+        prefix = "prefix"
+        stubContent = ('"Multiple exclamation marks", '
+                       'he went on, shaking his head, '
+                       '"are a sure sign of a diseased mind."')
+        # (C) Terry Pratchet - Small Gods
+        dir = tempfile.mkdtemp()
+        gen = 10
+
+        expectedDirContent = []
+        for i in range(gen):
+            fname = "%s.txt.%d" % (prefix, i + 1)
+            expectedDirContent.append("%s.txt.%d" % (prefix, i + 1))
+            f = open(os.path.join(dir, fname), "wb")
+            f.write(stubContent)
+            f.flush()
+            f.close()
+
+        #Rotate
+        utils.rotateFiles(dir, prefix, gen, persist=persist)
+
+        #Test result
+        currentDirContent = os.listdir(dir)
+        expectedDirContent.sort()
+        currentDirContent.sort()
+        try:
+            self.assertEquals(currentDirContent, expectedDirContent)
+        finally:
+            #Clean
+            for f in os.listdir(dir):
+                os.unlink(os.path.join(dir, f))
+            os.rmdir(dir)
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 4f3d6f9..cdf5e1a 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -27,7 +27,6 @@
 import logging
 import time
 import linecache
-import glob
 
 import libvirt
 import rpm
@@ -55,14 +54,6 @@
 except ImportError:
     _glusterEnabled = False
 
-
-class OSName:
-    UNKNOWN = 'unknown'
-    OVIRT = 'oVirt Node'
-    RHEL = 'RHEL'
-    FEDORA = 'Fedora'
-    RHEVH = 'RHEV Hypervisor'
-    DEBIAN = 'Debian'
 
 RNG_SOURCES = {'random': '/dev/random',
                'hwrng': '/dev/hwrng'}
@@ -275,32 +266,16 @@
 
 
 @utils.memoized
-def getos():
-    if os.path.exists('/etc/rhev-hypervisor-release'):
-        return OSName.RHEVH
-    elif glob.glob('/etc/ovirt-node-*-release'):
-        return OSName.OVIRT
-    elif os.path.exists('/etc/fedora-release'):
-        return OSName.FEDORA
-    elif os.path.exists('/etc/redhat-release'):
-        return OSName.RHEL
-    elif os.path.exists('/etc/debian_version'):
-        return OSName.DEBIAN
-    else:
-        return OSName.UNKNOWN
-
-
- at utils.memoized
 def osversion():
     version = release = ''
 
-    osname = getos()
+    osname = utils.getos()
     try:
-        if osname == OSName.RHEVH or osname == OSName.OVIRT:
+        if osname == utils.OSName.RHEVH or osname == utils.OSName.OVIRT:
             d = _parseKeyVal(file('/etc/default/version'))
             version = d.get('VERSION', '')
             release = d.get('RELEASE', '')
-        elif osname == OSName.DEBIAN:
+        elif osname == utils.OSName.DEBIAN:
             version = linecache.getline('/etc/debian_version', 1).strip("\n")
             release = ""  # Debian just has a version entry
         else:
@@ -403,7 +378,8 @@
 
     pkgs = {'kernel': kernelDict()}
 
-    if getos() in (OSName.RHEVH, OSName.OVIRT, OSName.FEDORA, OSName.RHEL):
+    if utils.getos() in (utils.OSName.RHEVH, utils.OSName.OVIRT,
+                         utils.OSName.FEDORA, utils.OSName.RHEL):
         KEY_PACKAGES = {'qemu-kvm': ('qemu-kvm', 'qemu-kvm-rhev'),
                         'qemu-img': ('qemu-img', 'qemu-img-rhev'),
                         'vdsm': ('vdsm',),
@@ -434,7 +410,7 @@
         except:
             logging.error('', exc_info=True)
 
-    elif getos() == OSName.DEBIAN and python_apt:
+    elif utils.getos() == utils.OSName.DEBIAN and python_apt:
         KEY_PACKAGES = {'qemu-kvm': 'qemu-kvm', 'qemu-img': 'qemu-utils',
                         'vdsm': 'vdsmd', 'spice-server': 'libspice-server1',
                         'libvirt': 'libvirt0', 'mom': 'mom'}
@@ -454,7 +430,3 @@
                 logging.error('', exc_info=True)
 
     return pkgs
-
-
-def isOvirtNode():
-    return getos() in (OSName.RHEVH, OSName.OVIRT)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 6bae0bd..0cd40f6 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -350,9 +350,6 @@
 
         self._preparedVolumes = defaultdict(list)
 
-        if not multipath.isEnabled():
-            multipath.setupMultipath()
-
         self.__validateLvmLockingType()
 
         self.domainStateChangeCallbacks = set()
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index 48020b6..1cc73ee 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -55,7 +55,6 @@
 import storage_exception as se
 import fileUtils
 import logUtils
-from caps import isOvirtNode
 
 IOUSER = "vdsm"
 DIRECTFLAG = "direct"
@@ -477,66 +476,6 @@
     if n < 0:
         raise se.InvalidParameterException(name, number)
     return n
-
-
-def rotateFiles(directory, prefixName, gen, cp=False, persist=False):
-    log.debug("dir: %s, prefixName: %s, versions: %s" %
-              (directory, prefixName, gen))
-    gen = int(gen)
-    files = os.listdir(directory)
-    files = glob.glob("%s*" % prefixName)
-    fd = {}
-    for fname in files:
-        name = fname.rsplit('.', 1)
-        try:
-            ind = int(name[1])
-        except ValueError:
-            name[0] = fname
-            ind = 0
-        except IndexError:
-            ind = 0
-        except:
-            continue
-        if ind < gen:
-            fd[ind] = {'old': fname, 'new': name[0] + '.' + str(ind + 1)}
-
-    keys = fd.keys()
-    keys.sort(reverse=True)
-    log.debug("versions found: %s" % (keys))
-
-    for key in keys:
-        oldName = os.path.join(directory, fd[key]['old'])
-        newName = os.path.join(directory, fd[key]['new'])
-        if isOvirtNode() and persist and not cp:
-            try:
-                execCmd([constants.EXT_UNPERSIST, oldName], logErr=False,
-                        sudo=True)
-                execCmd([constants.EXT_UNPERSIST, newName], logErr=False,
-                        sudo=True)
-            except:
-                pass
-        try:
-            if cp:
-                execCmd([constants.EXT_CP, oldName, newName], sudo=True)
-                if isOvirtNode() and persist and not os.path.exists(newName):
-                    execCmd([constants.EXT_PERSIST, newName], logErr=False,
-                            sudo=True)
-
-            else:
-                os.rename(oldName, newName)
-        except:
-            pass
-        if isOvirtNode() and persist and not cp:
-            try:
-                execCmd([constants.EXT_PERSIST, newName], logErr=False,
-                        sudo=True)
-            except:
-                pass
-
-
-def persistFile(name):
-    if isOvirtNode():
-        execCmd([constants.EXT_PERSIST, name], sudo=True)
 
 
 def parseHumanReadableSize(size):
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 29851f3..4ffcd1d 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -25,7 +25,6 @@
 import os
 import errno
 from glob import glob
-import tempfile
 import logging
 import re
 from collections import namedtuple
@@ -37,53 +36,11 @@
 import supervdsm
 import devicemapper
 
-import storage_exception as se
-
 DEV_ISCSI = "iSCSI"
 DEV_FCP = "FCP"
 DEV_MIXED = "MIXED"
 
-MAX_CONF_COPIES = 5
-
 TOXIC_CHARS = '()*+?|^$.\\'
-
-MPATH_CONF = "/etc/multipath.conf"
-
-OLD_TAGS = ["# RHAT REVISION 0.2", "# RHEV REVISION 0.3",
-            "# RHEV REVISION 0.4", "# RHEV REVISION 0.5",
-            "# RHEV REVISION 0.6", "# RHEV REVISION 0.7",
-            "# RHEV REVISION 0.8", "# RHEV REVISION 0.9"]
-MPATH_CONF_TAG = "# RHEV REVISION 1.0"
-MPATH_CONF_PRIVATE_TAG = "# RHEV PRIVATE"
-STRG_MPATH_CONF = (
-    "\n\n"
-    "defaults {\n"
-    "    polling_interval        5\n"
-    "    getuid_callout          \"%(scsi_id_path)s --whitelisted "
-    "--replace-whitespace --device=/dev/%%n\"\n"
-    "    no_path_retry           fail\n"
-    "    user_friendly_names     no\n"
-    "    flush_on_last_del       yes\n"
-    "    fast_io_fail_tmo        5\n"
-    "    dev_loss_tmo            30\n"
-    "    max_fds                 4096\n"
-    "}\n"
-    "\n"
-    "devices {\n"
-    "device {\n"
-    "    vendor                  \"HITACHI\"\n"
-    "    product                 \"DF.*\"\n"
-    "    getuid_callout          \"%(scsi_id_path)s --whitelisted "
-    "--replace-whitespace --device=/dev/%%n\"\n"
-    "}\n"
-    "device {\n"
-    "    vendor                  \"COMPELNT\"\n"
-    "    product                 \"Compellent Vol\"\n"
-    "    no_path_retry           fail\n"
-    "}\n"
-    "}"
-)
-MPATH_CONF_TEMPLATE = MPATH_CONF_TAG + STRG_MPATH_CONF
 
 log = logging.getLogger("Storage.Multipath")
 
@@ -108,76 +65,6 @@
     # Now let multipath daemon pick up new devices
     cmd = [constants.EXT_MULTIPATH, "-r"]
     misc.execCmd(cmd, sudo=True)
-
-
-def isEnabled():
-    """
-    Check the multipath daemon configuration. The configuration file
-    /etc/multipath.conf should contain private tag in form
-    "RHEV REVISION X.Y" for this check to succeed.
-    If the tag above is followed by tag "RHEV PRIVATE" the configuration
-    should be preserved at all cost.
-
-    """
-    if os.path.exists(MPATH_CONF):
-        first = second = ''
-        svdsm = supervdsm.getProxy()
-        mpathconf = svdsm.readMultipathConf()
-        try:
-            first = mpathconf[0]
-            second = mpathconf[1]
-        except IndexError:
-            pass
-        if MPATH_CONF_PRIVATE_TAG in second:
-            log.info("Manual override for multipath.conf detected - "
-                     "preserving current configuration")
-            if MPATH_CONF_TAG not in first:
-                log.warning("This manual override for multipath.conf "
-                            "was based on downrevved template. "
-                            "You are strongly advised to "
-                            "contact your support representatives")
-            return True
-
-        if MPATH_CONF_TAG in first:
-            log.debug("Current revision of multipath.conf detected, "
-                      "preserving")
-            return True
-
-        for tag in OLD_TAGS:
-            if tag in first:
-                log.info("Downrev multipath.conf detected, upgrade required")
-                return False
-
-    log.debug("multipath Defaulting to False")
-    return False
-
-
-def setupMultipath():
-    """
-    Set up the multipath daemon configuration to the known and
-    supported state. The original configuration, if any, is saved
-    """
-    if os.path.exists(MPATH_CONF):
-        misc.rotateFiles(
-            os.path.dirname(MPATH_CONF),
-            os.path.basename(MPATH_CONF), MAX_CONF_COPIES,
-            cp=True, persist=True)
-    with tempfile.NamedTemporaryFile() as f:
-        f.write(MPATH_CONF_TEMPLATE % {'scsi_id_path': _scsi_id.cmd})
-        f.flush()
-        cmd = [constants.EXT_CP, f.name, MPATH_CONF]
-        rc = misc.execCmd(cmd, sudo=True)[0]
-        if rc != 0:
-            raise se.MultipathSetupError()
-    misc.persistFile(MPATH_CONF)
-
-    # Flush all unused multipath device maps
-    misc.execCmd([constants.EXT_MULTIPATH, "-F"], sudo=True)
-
-    cmd = [constants.EXT_VDSM_TOOL, "service-reload", "multipathd"]
-    rc = misc.execCmd(cmd, sudo=True)[0]
-    if rc != 0:
-        raise se.MultipathReloadError()
 
 
 def deduceType(a, b):
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 3249343..877f527 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -30,7 +30,7 @@
 import resourceFactories
 from resourceFactories import IMAGE_NAMESPACE, VOLUME_NAMESPACE
 import resourceManager as rm
-from vdsm import constants
+from vdsm import constants, utils
 import clusterlock
 import outOfProcess as oop
 from persistentDict import unicodeEncoder, unicodeDecoder
@@ -702,7 +702,7 @@
 
     def setMetadata(self, newMetadata):
         # Backup old md (rotate old backup files)
-        misc.rotateFiles(self.mdBackupDir, self.sdUUID, self.mdBackupVersions)
+        utils.rotateFiles(self.mdBackupDir, self.sdUUID, self.mdBackupVersions)
         oldMd = ["%s=%s\n" % (key, value)
                  for key, value in self.getMetadata().copy().iteritems()]
         open(os.path.join(self.mdBackupDir, self.sdUUID),
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index 59df478..a902b09 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -142,11 +142,6 @@
         return _getLsBlk(*args, **kwargs)
 
     @logDecorator
-    def readMultipathConf(self):
-        with open(MPATH_CONF) as f:
-            return [x.strip("\n") for x in f.readlines()]
-
-    @logDecorator
     def getScsiSerial(self, *args, **kwargs):
         return _getScsiSerial(*args, **kwargs)
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40f802477e39000c5cae01a496ac2d9f879ebfa8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan at redhat.com>


More information about the vdsm-patches mailing list