Merge "Multipath Device Action Being Parsed as Name"
This commit is contained in:
commit
8e845f2cee
|
@ -32,6 +32,9 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
MULTIPATH_ERROR_REGEX = re.compile("\w{3} \d+ \d\d:\d\d:\d\d \|.*$")
|
||||
MULTIPATH_WWID_REGEX = re.compile("\((?P<wwid>.+)\)")
|
||||
MULTIPATH_DEVICE_ACTIONS = ['unchanged:', 'reject:', 'reload:',
|
||||
'switchpg:', 'rename:', 'create:',
|
||||
'resize:']
|
||||
|
||||
|
||||
class LinuxSCSI(executor.Executor):
|
||||
|
@ -272,6 +275,10 @@ class LinuxSCSI(executor.Executor):
|
|||
if lines:
|
||||
|
||||
mdev_name = lines[0].split(" ")[0]
|
||||
|
||||
if mdev_name in MULTIPATH_DEVICE_ACTIONS:
|
||||
mdev_name = lines[0].split(" ")[1]
|
||||
|
||||
mdev = '/dev/mapper/%s' % mdev_name
|
||||
|
||||
# Confirm that the device is present.
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import os
|
||||
import os.path
|
||||
import textwrap
|
||||
import time
|
||||
|
||||
import mock
|
||||
|
@ -457,3 +458,36 @@ loop0 0"""
|
|||
path)
|
||||
|
||||
self.assertEqual(4, mock_sleep.call_count)
|
||||
|
||||
def test_find_multipath_device_with_action(self):
|
||||
def fake_execute(*cmd, **kwargs):
|
||||
out = textwrap.dedent("""
|
||||
create: 36005076303ffc48e0000000000000101 dm-2 IBM,2107900
|
||||
size=1.0G features='1 queue_if_no_path' hwhandler='0'
|
||||
wp=rw
|
||||
`-+- policy='round-robin 0' prio=-1 status=active
|
||||
|- 6:0:2:0 sdd 8:64 active undef running
|
||||
`- 6:1:0:3 sdc 8:32 active undef running
|
||||
""")
|
||||
return out, None
|
||||
|
||||
self.linuxscsi._execute = fake_execute
|
||||
info = self.linuxscsi.find_multipath_device('/dev/sdd')
|
||||
LOG.error("Device info: %s" % info)
|
||||
|
||||
self.assertEqual('36005076303ffc48e0000000000000101', info['id'])
|
||||
self.assertEqual('36005076303ffc48e0000000000000101', info['name'])
|
||||
self.assertEqual('/dev/mapper/36005076303ffc48e0000000000000101',
|
||||
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'])
|
||||
|
|
Loading…
Reference in New Issue