Yeela Kaplan has uploaded a new change for review.
Change subject: multipath: use a backup file instead of rotateFiles
......................................................................
multipath: use a backup file instead of rotateFiles
as part of the move to using vdsm tool configurator for multipath,
we want to consolidate the configuration of multipath with
other configurators, such as libvirt.
Rotating the configuration file will end up deleting the
most important multipath conf file for the user,
which is the original conf file - pre vdsm installation.
That is why we will only back up the original multipath conf,
and any other new changes to multipath that are important to the
user and have been made after vdsm installation should be saved
by the user.
Change-Id: I96a9251ebc852fcdf39239ba50f43dd2343b83a6
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M vdsm/storage/multipath.py
1 file changed, 28 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/34077/1
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 43b06f1..e5964de 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -28,6 +28,7 @@
import tempfile
import logging
import re
+import shutil
from collections import namedtuple
from vdsm import constants
@@ -48,6 +49,8 @@
TOXIC_CHARS = '()*+?|^$.\\'
MPATH_CONF = "/etc/multipath.conf"
+
+CONF_BACKUP = "/etc/multipath.conf.bak"
OLD_TAGS = ["# RHAT REVISION 0.2", "# RHEV REVISION 0.3",
"# RHEV REVISION 0.4", "# RHEV REVISION 0.5",
@@ -110,6 +113,19 @@
misc.execCmd([constants.EXT_MULTIPATH], sudo=True)
+def _parseConf():
+ first = second = ''
+ svdsm = supervdsm.getProxy()
+ mpathconf = svdsm.readMultipathConf()
+ try:
+ first = mpathconf[0]
+ second = mpathconf[1]
+ except IndexError:
+ pass
+
+ return (first, second)
+
+
def isEnabled():
"""
Check the multipath daemon configuration. The configuration file
@@ -120,14 +136,7 @@
"""
if os.path.exists(MPATH_CONF):
- first = second = ''
- svdsm = supervdsm.getProxy()
- mpathconf = svdsm.readMultipathConf()
- try:
- first = mpathconf[0]
- second = mpathconf[1]
- except IndexError:
- pass
+ first, second = _parseConf()
if MPATH_CONF_PRIVATE_TAG in second:
log.info("Manual override for multipath.conf detected - "
"preserving current configuration")
@@ -158,10 +167,17 @@
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)
+ first, second = _parseConf()
+
+ if not os.path.exists(CONF_BACKUP) and MPATH_CONF_TAG not in first:
+ try:
+ shutil.copyfile(MPATH_CONF, CONF_BACKUP)
+ except IOError:
+ raise se.MultipathSetupError()
+ else:
+ utils.persist(CONF_BACKUP)
+
+
with tempfile.NamedTemporaryFile() as f:
f.write(MPATH_CONF_TEMPLATE % {'scsi_id_path': _scsi_id.cmd})
f.flush()
--
To view, visit
http://gerrit.ovirt.org/34077
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96a9251ebc852fcdf39239ba50f43dd2343b83a6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>