Saggi Mizrahi has uploaded a new change for review.
Change subject: Rescan FC when rescanning for new multipath devices
......................................................................
Rescan FC when rescanning for new multipath devices
Change-Id: Idec939222676a24452e8825b36db68839bfd2bbc
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M lib/vdsm/utils.py
M tests/utilsTests.py
M vdsm/storage/Makefile.am
A vdsm/storage/fc.py
M vdsm/storage/multipath.py
5 files changed, 61 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/19539/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index f06cad2..e273514 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -793,6 +793,24 @@
return functools.partial(self.__call__, obj)
+def tee_async(data, outputFiles=[], append=False):
+ cmd = ["tee"]
+ if append:
+ cmd.append("--append")
+
+ cmd.extend(outputFiles)
+ proc = execCmd(cmd, sync=False)
+ proc.stdin.write(data)
+
+ def parser(rc, out, err):
+ if rc != 0:
+ raise OSError(-1, err)
+
+ return out
+
+ return AsyncProcessOperation(proc, parser)
+
+
def validateMinimalKeySet(dictionary, reqParams):
if not all(key in dictionary for key in reqParams):
raise ValueError
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index 656c121..5b83ec0 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -18,11 +18,14 @@
# Refer to the README and COPYING files for full details of the license
#
import errno
+import time
+import tempfile
+import shutil
+import os
from testrunner import VdsmTestCase as TestCaseBase
from vdsm import utils
from storage import misc
-import time
class RetryTests(TestCaseBase):
@@ -63,6 +66,33 @@
sproc.wait()
+class TeeTests(TestCaseBase):
+ def setUp(self):
+ self.dir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.dir)
+
+ def test(self):
+ d = self.dir
+ n = 10
+ files = []
+ for i in range(n):
+ files.append(os.path.join(d, "%d.tmp" % i))
+
+ data = "hello"
+ res = utils.tee_async(data, files).result()
+ self.assertEquals((data, None), res)
+ for fname in files:
+ with open(fname, "r") as f:
+ self.assertEquals(data, f.read())
+
+ def testError(self):
+ res, err = utils.tee_async("hello", ["/"]).result()
+ self.assertEquals(res, None)
+ self.assertNotEquals(err, None)
+
+
class CommandPathTests(TestCaseBase):
def testExisting(self):
cp = utils.CommandPath('sh', 'utter nonsense',
'/bin/sh')
diff --git a/vdsm/storage/Makefile.am b/vdsm/storage/Makefile.am
index 2d3e9a6..a367c9b 100644
--- a/vdsm/storage/Makefile.am
+++ b/vdsm/storage/Makefile.am
@@ -33,6 +33,7 @@
fileSD.py \
fileUtils.py \
fileVolume.py \
+ fc.py \
fuser.py \
glusterSD.py \
glusterVolume.py \
diff --git a/vdsm/storage/fc.py b/vdsm/storage/fc.py
new file mode 100644
index 0000000..96aa710
--- /dev/null
+++ b/vdsm/storage/fc.py
@@ -0,0 +1,8 @@
+from glob import glob
+from vdsm import utils
+
+
+def rescan():
+ """Issue command to discover new ports if the fc driver supports
it"""
+ # Use tee to make sure we don't do that IO directly
+ utils.tee_async("1", glob("/sys/class/fc_host/host*/issue_lip"))
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 6d6fcbd..076bfca 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -36,6 +36,7 @@
import iscsi
import supervdsm
import devicemapper
+import fc
import storage_exception as se
@@ -106,7 +107,8 @@
Should only be called from hsm._rescanDevices()
"""
- # First ask iSCSI to rescan all its sessions
+ # First ask fc and iSCSI to rescan all of their sessions
+ fc.rescan()
iscsi.rescan()
# Now let multipath daemon pick up new devices
--
To view, visit
http://gerrit.ovirt.org/19539
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idec939222676a24452e8825b36db68839bfd2bbc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>