Remove brackets from portal
In case IPv6 address is present in location os_brick would fail to get correct path as brackets are forbidden chars in udev and are removed. Closes-Bug: #1449492 Change-Id: I965ce7bb9bc2b2c3fdd240d998441f8b06b36934
This commit is contained in:
parent
e5ccc19a4b
commit
10924909cd
os_brick
@ -886,16 +886,27 @@ class ISCSIConnector(InitiatorConnector):
|
||||
if not devices:
|
||||
self._disconnect_from_iscsi_portal(connection_properties)
|
||||
|
||||
def _munge_portal(self, target):
|
||||
"""Remove brackets from portal.
|
||||
|
||||
In case IPv6 address was used the udev path should not contain any
|
||||
brackets. Udev code specifically forbids that.
|
||||
"""
|
||||
portal, iqn, lun = target
|
||||
return (portal.replace('[', '').replace(']', ''), iqn, lun)
|
||||
|
||||
def _get_device_path(self, connection_properties):
|
||||
if self._get_transport() == "default":
|
||||
return ["/dev/disk/by-path/ip-%s-iscsi-%s-lun-%s" % x for x in
|
||||
return ["/dev/disk/by-path/ip-%s-iscsi-%s-lun-%s" %
|
||||
self._munge_portal(x) for x in
|
||||
self._get_all_targets(connection_properties)]
|
||||
else:
|
||||
# we are looking for paths in the format :
|
||||
# /dev/disk/by-path/pci-XXXX:XX:XX.X-ip-PORTAL:PORT-iscsi-IQN-lun-LUN_ID
|
||||
device_list = []
|
||||
for x in self._get_all_targets(connection_properties):
|
||||
look_for_device = glob.glob('/dev/disk/by-path/*ip-%s-iscsi-%s-lun-%s' % x) # noqa
|
||||
look_for_device = glob.glob('/dev/disk/by-path/*ip-%s-iscsi-%s-lun-%s' # noqa
|
||||
% self._munge_portal(x))
|
||||
if look_for_device:
|
||||
device_list.extend(look_for_device)
|
||||
return device_list
|
||||
|
@ -416,7 +416,7 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
'Test requires /dev/disk/by-path')
|
||||
def test_connect_volume_with_alternative_targets(self):
|
||||
location = '10.0.2.15:3260'
|
||||
location2 = '10.0.3.15:3260'
|
||||
location2 = '[2001:db8::1]:3260'
|
||||
iqn = 'iqn.2010-10.org.openstack:volume-00000001'
|
||||
iqn2 = 'iqn.2010-10.org.openstack:volume-00000001-2'
|
||||
extra_props = {'target_portals': [location, location2],
|
||||
@ -453,7 +453,8 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
def test_connect_volume_with_alternative_targets_primary_error(
|
||||
self, mock_iscsiadm, mock_exists):
|
||||
location = '10.0.2.15:3260'
|
||||
location2 = '10.0.3.15:3260'
|
||||
location2 = '[2001:db8::1]:3260'
|
||||
dev_loc2 = '2001:db8::1:3260' # udev location2
|
||||
name = 'volume-00000001'
|
||||
iqn = 'iqn.2010-10.org.openstack:%s' % name
|
||||
iqn2 = 'iqn.2010-10.org.openstack:%s-2' % name
|
||||
@ -462,7 +463,7 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
connection_info['data']['target_portals'] = [location, location2]
|
||||
connection_info['data']['target_iqns'] = [iqn, iqn2]
|
||||
connection_info['data']['target_luns'] = [1, 2]
|
||||
dev_str2 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (location2, iqn2)
|
||||
dev_str2 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (dev_loc2, iqn2)
|
||||
|
||||
def fake_run_iscsiadm(iscsi_properties, iscsi_command, **kwargs):
|
||||
if iscsi_properties['target_portal'] == location:
|
||||
@ -594,7 +595,8 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
mock_get_device_map, mock_devices, mock_exists, mock_scsi_wwn):
|
||||
mock_scsi_wwn.return_value = FAKE_SCSI_WWN
|
||||
location1 = '10.0.2.15:3260'
|
||||
location2 = '10.0.3.15:3260'
|
||||
location2 = '[2001:db8::1]:3260'
|
||||
dev_loc2 = '2001:db8::1:3260' # udev location2
|
||||
name1 = 'volume-00000001-1'
|
||||
name2 = 'volume-00000001-2'
|
||||
iqn1 = 'iqn.2010-10.org.openstack:%s' % name1
|
||||
@ -604,7 +606,7 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
connection_properties = self.iscsi_connection_multipath(
|
||||
vol, [location1, location2], [iqn1, iqn2], [1, 2])
|
||||
devs = ['/dev/disk/by-path/ip-%s-iscsi-%s-lun-1' % (location1, iqn1),
|
||||
'/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (location2, iqn2)]
|
||||
'/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (dev_loc2, iqn2)]
|
||||
mock_devices.return_value = devs
|
||||
mock_iscsi_devices.return_value = devs
|
||||
mock_device_name.return_value = fake_multipath_dev
|
||||
@ -648,7 +650,8 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
mock_scsi_wwn):
|
||||
mock_scsi_wwn.return_value = FAKE_SCSI_WWN
|
||||
location1 = '10.0.2.15:3260'
|
||||
location2 = '10.0.3.15:3260'
|
||||
location2 = '[2001:db8::1]:3260'
|
||||
dev_loc2 = '2001:db8::1:3260' # udev location2
|
||||
name1 = 'volume-00000001-1'
|
||||
name2 = 'volume-00000001-2'
|
||||
iqn1 = 'iqn.2010-10.org.openstack:%s' % name1
|
||||
@ -658,7 +661,7 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
connection_properties = self.iscsi_connection_multipath(
|
||||
vol, [location1, location2], [iqn1, iqn2], [1, 2])
|
||||
dev1 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-1' % (location1, iqn1)
|
||||
dev2 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (location2, iqn2)
|
||||
dev2 = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (dev_loc2, iqn2)
|
||||
|
||||
def fake_run_iscsiadm(iscsi_properties, iscsi_command, **kwargs):
|
||||
if iscsi_properties['target_portal'] == location1:
|
||||
@ -720,7 +723,8 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
mock_connect, mock_portals, mock_exists, mock_scsi_wwn):
|
||||
mock_scsi_wwn.return_value = FAKE_SCSI_WWN
|
||||
location1 = '10.0.2.15:3260'
|
||||
location2 = '10.0.3.15:3260'
|
||||
location2 = '[2001:db8::1]:3260'
|
||||
dev_loc2 = '2001:db8::1:3260' # udev location2
|
||||
name1 = 'volume-00000001-1'
|
||||
name2 = 'volume-00000001-2'
|
||||
iqn1 = 'iqn.2010-10.org.openstack:%s' % name1
|
||||
@ -729,7 +733,7 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
|
||||
vol = {'id': 1, 'name': name1}
|
||||
connection_properties = self.iscsi_connection(vol, location1, iqn1)
|
||||
devs = ['/dev/disk/by-path/ip-%s-iscsi-%s-lun-1' % (location1, iqn1),
|
||||
'/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (location2, iqn2)]
|
||||
'/dev/disk/by-path/ip-%s-iscsi-%s-lun-2' % (dev_loc2, iqn2)]
|
||||
mock_devices.return_value = devs
|
||||
mock_iscsi_devices.return_value = devs
|
||||
mock_device_name.return_value = fake_multipath_dev
|
||||
|
Loading…
x
Reference in New Issue
Block a user