Merge "The validation of iscsi session should be case insensitive"

This commit is contained in:
Zuul 2018-10-02 23:22:47 +00:00 committed by Gerrit Code Review
commit 995daed9fe
2 changed files with 32 additions and 1 deletions

View File

@ -1050,7 +1050,7 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector):
for s in sessions:
# Found our session, return session_id
if (s[0] in self.VALID_SESSIONS_PREFIX and
portal == s[2] and s[4] == target_iqn):
portal.lower() == s[2].lower() and s[4] == target_iqn):
return s[1], manual_scan
try:

View File

@ -1008,6 +1008,37 @@ Setting up iSCSI targets: unused
self.assertListEqual(expected_cmds, actual_cmds)
self.assertEqual(2, get_sessions_mock.call_count)
@mock.patch.object(iscsi.ISCSIConnector, '_get_iscsi_sessions_full')
def test_connect_to_iscsi_portal_ip_case_insensitive(self,
get_sessions_mock):
"""Connect creating node and session."""
session = 'session2'
get_sessions_mock.side_effect = [
[('tcp:', 'session1', 'iP1:port1', '1', 'tgt')],
[('tcp:', 'session1', 'Ip1:port1', '1', 'tgt'),
('tcp:', session, 'IP1:port1', '-1', 'tgt1')]
]
with mock.patch.object(self.connector, '_execute') as exec_mock:
exec_mock.side_effect = [('', 'error'), ('', None),
('', None), ('', None),
('', None)]
res = self.connector._connect_to_iscsi_portal(self.CON_PROPS)
# True refers to "manual scans", since the call to update
# node.session.scan didn't fail they are set to manual
self.assertEqual((session, True), res)
prefix = 'iscsiadm -m node -T tgt1 -p ip1:port1'
expected_cmds = [
prefix,
prefix + ' --interface default --op new',
prefix + ' --op update -n node.session.scan -v manual',
prefix + ' --login',
prefix + ' --op update -n node.startup -v automatic'
]
actual_cmds = [' '.join(args[0]) for args in exec_mock.call_args_list]
self.assertListEqual(expected_cmds, actual_cmds)
self.assertEqual(2, get_sessions_mock.call_count)
@mock.patch.object(iscsi.ISCSIConnector, '_get_iscsi_sessions_full')
def test_connect_to_iscsi_portal_all_exists_chap(self, get_sessions_mock):
"""Node and session already exists and we use chap authentication."""