mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
'-gname', 'fakehost', '-o',
poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False),
mock.call(*self.testData.PINGNODE_CMD('A', 4, 0,
'10.0.0.2'))]
fake_cli.assert_has_calls(expected)
poll=True),
mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
'-gname', 'fakehost', '-o', poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False),
mock.call(*self.testData.PINGNODE_CMD('A', 4, 0,
'10.0.0.2'))]
fake_cli.assert_has_calls(expected)
mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'),
poll=True),
mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
- '-gname', 'fakehost', '-o', poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False)]
+ '-gname', 'fakehost', '-o', poll=False)]
fake_cli.assert_has_calls(expected)
@mock.patch('random.randint',
expected = [mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'),
poll=False),
mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
- '-gname', 'fakehost', '-o', poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False)]
+ '-gname', 'fakehost', '-o', poll=False)]
fake_cli.assert_has_calls(expected)
@mock.patch(
poll=False),
mock.call(*self.testData.STORAGEGROUP_LIST_CMD('fakehost'),
poll=True),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False),
mock.call(*self.testData.PINGNODE_CMD('A', 4, 0,
'10.0.0.2'))]
fake_cli.assert_has_calls(expected)
poll=True),
mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 1,
'-gname', 'fakehost', '-o',
- poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
poll=False)]
fake_cli.assert_has_calls(expected)
mock.call('storagegroup', '-addhlu', '-hlu', 2, '-alu', 4,
'-gname', 'fakehost', '-o',
poll=False),
- mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
- poll=False),
mock.call(*self.testData.PINGNODE_CMD('A', 4, 0,
u'10.0.0.2'))]
fake_cli.assert_has_calls(expected)
'B': [port_b1]}
targets = self.driver.cli._client.find_available_iscsi_targets(
'fakehost',
- 'B',
{('A', 2, 0), ('B', 1, 0)},
all_targets)
- self.assertEqual([port_b1, port_a2], targets)
+ self.assertTrue(port_a2 in targets)
+ self.assertTrue(port_b1 in targets)
- @mock.patch("random.shuffle", mock.Mock())
@mock.patch.object(emc_vnx_cli.CommandLineHelper,
'ping_node')
def test_find_available_iscsi_targets_with_pingnode(self, ping_node):
'IP Address': 'fake_ip_b1'}
all_targets = {'A': [port_a1, port_a2],
'B': [port_b1]}
- ping_node.side_effect = [False, True]
- targets = self.driver.cli._client.find_available_iscsi_targets(
- 'fakehost',
- 'B',
- {('A', 2, 0), ('A', 1, 0), ('B', 1, 0)},
- all_targets)
- self.assertEqual([port_a1, port_b1, port_a2], targets)
ping_node.side_effect = [False, False, True]
targets = self.driver.cli._client.find_available_iscsi_targets(
'fakehost',
- 'B',
{('A', 2, 0), ('A', 1, 0), ('B', 1, 0)},
all_targets)
- self.assertEqual([port_a2, port_b1, port_a1], targets)
+ self.assertTrue(port_a1 in targets)
+ self.assertTrue(port_a2 in targets)
+ self.assertTrue(port_b1 in targets)
@mock.patch('cinder.volume.drivers.emc.emc_vnx_cli.'
'EMCVnxCliBase.get_lun_owner',
return False
def find_available_iscsi_targets(self, hostname,
- preferred_sp,
registered_spport_set,
all_iscsi_targets):
"""Finds available iscsi targets for a host.
else:
iscsi_initiator_ips = None
- # Check the targets on the owner first
- if preferred_sp == 'A':
- target_sps = ('A', 'B')
- else:
- target_sps = ('B', 'A')
-
target_portals = []
- for target_sp in target_sps:
- sp_portals = all_iscsi_targets[target_sp]
- random.shuffle(sp_portals)
- for portal in sp_portals:
- spport = (portal['SP'],
- portal['Port ID'],
- portal['Virtual Port ID'])
- if spport not in registered_spport_set:
- LOG.debug(
- "Skip SP Port %(port)s since "
- "no path from %(host)s is through it.",
- {'port': spport,
- 'host': hostname})
- continue
- target_portals.append(portal)
+
+ all_portals = all_iscsi_targets['A'] + all_iscsi_targets['B']
+ random.shuffle(all_portals)
+ for portal in all_portals:
+ spport = (portal['SP'],
+ portal['Port ID'],
+ portal['Virtual Port ID'])
+ if spport not in registered_spport_set:
+ LOG.debug(
+ "Skip SP Port %(port)s since "
+ "no path from %(host)s is through it.",
+ {'port': spport,
+ 'host': hostname})
+ continue
+ target_portals.append(portal)
main_portal_index = None
if iscsi_initiator_ips:
def vnx_get_iscsi_properties(self, volume, connector, hlu, sg_raw_output):
storage_group = connector['host']
- owner_sp = self.get_lun_owner(volume)
registered_spports = self._client.get_registered_spport_set(
connector['initiator'],
storage_group,
sg_raw_output)
targets = self._client.find_available_iscsi_targets(
- storage_group, owner_sp,
+ storage_group,
registered_spports,
self.iscsi_targets)
properties = {'target_discovered': False,