Merge "Dell SC: ISCSI initialize_connection fixes" into stable/newton
This commit is contained in:
commit
141a1c6dcd
@ -3544,8 +3544,7 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
'_find_active_controller',
|
||||
return_value='64702.64702')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_controller_port',
|
||||
return_value=ISCSI_CTRLR_PORT)
|
||||
'_find_controller_port')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_domains',
|
||||
return_value=ISCSI_FLT_DOMAINS_MULTI_PORTALS)
|
||||
@ -3565,6 +3564,59 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
# Test case where there are multiple portals
|
||||
mock_find_ctrl_port.side_effect = [
|
||||
{'iscsiName': 'iqn.2002-03.com.compellent:5000d31000fcbe43'},
|
||||
{'iscsiName': 'iqn.2002-03.com.compellent:5000d31000fcbe44'}]
|
||||
res = self.scapi.find_iscsi_properties(self.VOLUME)
|
||||
self.assertTrue(mock_find_mappings.called)
|
||||
self.assertTrue(mock_find_domains.called)
|
||||
self.assertTrue(mock_find_ctrl_port.called)
|
||||
self.assertTrue(mock_find_active_controller.called)
|
||||
self.assertTrue(mock_is_virtualport_mode.called)
|
||||
expected = {'target_discovered': False,
|
||||
'target_iqn':
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe44',
|
||||
'target_iqns':
|
||||
[u'iqn.2002-03.com.compellent:5000d31000fcbe44',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe44'],
|
||||
'target_lun': 1,
|
||||
'target_luns': [1, 1, 1, 1],
|
||||
'target_portal': u'192.168.0.25:3260',
|
||||
'target_portals': [u'192.168.0.25:3260',
|
||||
u'192.168.0.21:3260',
|
||||
u'192.168.0.25:3260',
|
||||
u'192.168.0.21:3260']}
|
||||
self.assertEqual(expected, res, 'Wrong Target Info')
|
||||
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_active_controller',
|
||||
return_value='64702.64702')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_controller_port')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_domains',
|
||||
return_value=ISCSI_FLT_DOMAINS_MULTI_PORTALS)
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_mappings',
|
||||
return_value=MAPPINGS_MULTI_PORTAL)
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_is_virtualport_mode',
|
||||
return_value=True)
|
||||
def test_find_iscsi_properties_multi_portals_duplicates(
|
||||
self,
|
||||
mock_is_virtualport_mode,
|
||||
mock_find_mappings,
|
||||
mock_find_domains,
|
||||
mock_find_ctrl_port,
|
||||
mock_find_active_controller,
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
# Test case where there are multiple portals and
|
||||
mock_find_ctrl_port.return_value = {
|
||||
'iscsiName': 'iqn.2002-03.com.compellent:5000d31000fcbe43'}
|
||||
res = self.scapi.find_iscsi_properties(self.VOLUME)
|
||||
self.assertTrue(mock_find_mappings.called)
|
||||
self.assertTrue(mock_find_domains.called)
|
||||
@ -3576,16 +3628,12 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
'target_iqns':
|
||||
[u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43'],
|
||||
'target_lun': 1,
|
||||
'target_luns': [1, 1, 1, 1],
|
||||
'target_luns': [1, 1],
|
||||
'target_portal': u'192.168.0.25:3260',
|
||||
'target_portals': [u'192.168.0.21:3260',
|
||||
u'192.168.0.25:3260',
|
||||
u'192.168.0.21:3260',
|
||||
u'192.168.0.25:3260']}
|
||||
'target_portals': [u'192.168.0.25:3260',
|
||||
u'192.168.0.21:3260']}
|
||||
self.assertEqual(expected, res, 'Wrong Target Info')
|
||||
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
@ -3710,8 +3758,7 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
'_find_active_controller',
|
||||
return_value='64702.64702')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_controller_port',
|
||||
return_value=ISCSI_CTRLR_PORT)
|
||||
'_find_controller_port')
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
'_find_mappings',
|
||||
return_value=MAPPINGS_MULTI_PORTAL)
|
||||
@ -3731,6 +3778,9 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
mock_find_ctrl_port.side_effect = [
|
||||
{'iscsiName': 'iqn.2002-03.com.compellent:5000d31000fcbe43'},
|
||||
{'iscsiName': 'iqn.2002-03.com.compellent:5000d31000fcbe44'}]
|
||||
# Test case where there are multiple portals
|
||||
res = self.scapi.find_iscsi_properties(self.VOLUME)
|
||||
self.assertTrue(mock_find_mappings.called)
|
||||
@ -3738,13 +3788,13 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
self.assertTrue(mock_find_active_controller.called)
|
||||
self.assertTrue(mock_is_virtualport_mode.called)
|
||||
self.assertTrue(mock_find_controller_port_iscsi_config.called)
|
||||
# Since we're feeding the same info back multiple times the information
|
||||
# will be duped.
|
||||
# We're feeding the same info back multiple times the information
|
||||
# will be scrubbed to a single item.
|
||||
expected = {'target_discovered': False,
|
||||
'target_iqn':
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe44',
|
||||
'target_iqns':
|
||||
[u'iqn.2002-03.com.compellent:5000d31000fcbe43',
|
||||
[u'iqn.2002-03.com.compellent:5000d31000fcbe44',
|
||||
u'iqn.2002-03.com.compellent:5000d31000fcbe43'],
|
||||
'target_lun': 1,
|
||||
'target_luns': [1, 1],
|
||||
|
@ -1692,7 +1692,15 @@ class StorageCenterApi(object):
|
||||
:return: Nothing
|
||||
"""
|
||||
if self.excluded_domain_ips.count(address) == 0:
|
||||
portals.append(address + ':' + six.text_type(port))
|
||||
# Make sure this isn't a duplicate.
|
||||
newportal = address + ':' + six.text_type(port)
|
||||
for idx, portal in enumerate(portals):
|
||||
if portal == newportal and iqns[idx] == iqn:
|
||||
LOG.debug('Skipping duplicate portal %(ptrl)s and'
|
||||
'iqn %(iqn)s.', {'ptrl': portal, 'iqn': iqn})
|
||||
return
|
||||
# It isn't in the list so process it.
|
||||
portals.append(newportal)
|
||||
iqns.append(iqn)
|
||||
luns.append(lun)
|
||||
|
||||
@ -1784,13 +1792,17 @@ class StorageCenterApi(object):
|
||||
'Volume is not yet active on any controller.')
|
||||
pdata['active'] = 0
|
||||
|
||||
# Make sure we have a good item at the top of the list.
|
||||
iqns.insert(0, iqns.pop(pdata['active']))
|
||||
portals.insert(0, portals.pop(pdata['active']))
|
||||
luns.insert(0, luns.pop(pdata['active']))
|
||||
data = {'target_discovered': False,
|
||||
'target_iqn': iqns[pdata['active']],
|
||||
'target_iqn': iqns[0],
|
||||
'target_iqns': iqns,
|
||||
'target_portal': portals[pdata['active']],
|
||||
'target_portal': portals[0],
|
||||
'target_portals': portals,
|
||||
'target_lun': luns[pdata['active']],
|
||||
'target_luns': luns,
|
||||
'target_lun': luns[0],
|
||||
'target_luns': luns
|
||||
}
|
||||
LOG.debug('find_iscsi_properties: %s', data)
|
||||
return data
|
||||
|
Loading…
Reference in New Issue
Block a user