Note, this is not iSCSI.
"""
import os
+import re
from cinder.brick import executor
from cinder.i18n import _
LOG = logging.getLogger(__name__)
+MULTIPATH_ERROR_REGEX = re.compile("\w{3} \d+ \d\d:\d\d:\d\d \|.*$")
+
class LinuxSCSI(executor.Executor):
def __init__(self, root_helper, execute=putils.execute,
if out:
lines = out.strip()
lines = lines.split("\n")
+ lines = [line for line in lines
+ if not re.match(MULTIPATH_ERROR_REGEX, line)]
if lines:
line = lines[0]
info = line.split(" ")
self.assertEqual("1", info['devices'][1]['channel'])
self.assertEqual("0", info['devices'][1]['id'])
self.assertEqual("3", info['devices'][1]['lun'])
+
+ def test_find_multipath_device_with_error(self):
+ def fake_execute(*cmd, **kwargs):
+ out = ("Oct 13 10:24:01 | /lib/udev/scsi_id exitted with 1\n"
+ "36005076303ffc48e0000000000000101 dm-2 IBM,2107900\n"
+ "size=1.0G features='1 queue_if_no_path' hwhandler='0'"
+ " wp=rw\n"
+ "`-+- policy='round-robin 0' prio=-1 status=active\n"
+ " |- 6:0:2:0 sdd 8:64 active undef running\n"
+ " `- 6:1:0:3 sdc 8:32 active undef running\n"
+ )
+ return out, None
+
+ self.stubs.Set(self.linuxscsi, '_execute', fake_execute)
+
+ info = self.linuxscsi.find_multipath_device('/dev/sdd')
+ LOG.error("info = %s" % info)
+ self.assertEqual("/dev/dm-2", info["device"])
+ self.assertEqual("/dev/sdd", info['devices'][0]['device'])
+ self.assertEqual("6", info['devices'][0]['host'])
+ self.assertEqual("0", info['devices'][0]['channel'])
+ self.assertEqual("2", info['devices'][0]['id'])
+ self.assertEqual("0", info['devices'][0]['lun'])
+
+ self.assertEqual("/dev/sdc", info['devices'][1]['device'])
+ self.assertEqual("6", info['devices'][1]['host'])
+ self.assertEqual("1", info['devices'][1]['channel'])
+ self.assertEqual("0", info['devices'][1]['id'])
+ self.assertEqual("3", info['devices'][1]['lun'])