-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CA-386479: ensure we login to all iSCSI Target Portal Groups
Some arrays may have multiple, entirely independent, Target Portal Groups within a single controller IQN space. When performing discovery to portals within these portal groups they respond only with the portal addresses within that TQG and do not include the portal addresses in other TPGs in the controller or information about TPGs in any other controller IQN spaces. In order to ensure that all the expected iSCSI paths and sessions are activated it is necessary to make the checks for IQN connectivity also check for the specific target portal address and not just check that the target IQN is served by an active session Signed-off-by: Mark Syms <mark.syms@citrix.com>
- Loading branch information
1 parent
be5b691
commit 1b6e452
Showing
5 changed files
with
189 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
import iscsilib | ||
from SRCommand import SRCommand | ||
|
||
|
||
class ISCSITestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
iscsilib_patcher = mock.patch(f'{self.TEST_CLASS}.iscsilib', | ||
autospec=True) | ||
self.mock_iscsilib = iscsilib_patcher.start() | ||
self.mock_iscsilib.discovery.side_effect = self.discovery | ||
self.mock_iscsilib._checkTGT.side_effect = self._checkTGT | ||
self.mock_iscsilib.login.side_effect = self.iscsi_login | ||
self.mock_iscsilib.parse_IP_port = iscsilib.parse_IP_port | ||
self.discovery_data = {} | ||
self.sessions = [] | ||
|
||
sleep_patcher = mock.patch(f'{self.TEST_CLASS}.time.sleep', | ||
autospec=True) | ||
self.mock_sleep = sleep_patcher.start() | ||
|
||
def _checkTGT(self, tgtIQN, tgt=''): | ||
all_sessions = '\n'.join(self.sessions) | ||
matched = iscsilib._compare_sessions_to_tgt(all_sessions, tgtIQN, tgt) | ||
return matched | ||
|
||
def discovery(self, target, port, chapuser, chappassword, | ||
targetIQN="any", interfaceArray=["default"]): | ||
return self.discovery_data.get(target, []) | ||
|
||
def iscsi_login(self, target, target_iqn, chauser, chappassword, | ||
incoming_user, incoming_password, mpath): | ||
session_count = len(self.sessions) | ||
self.sessions.append(f'tcp: [{session_count}] {target},1 {target_iqn}') | ||
|
||
def create_sr_command( | ||
self, additional_dconf=None, cmd=None, | ||
target_iqn='iqn.2009-01.example.test:iscsi085e938a', | ||
multihomelist='tgt1:3260,tgt2:3260', target="10.70.89.34"): | ||
|
||
sr_cmd = mock.create_autospec(SRCommand) | ||
sr_cmd.dconf = { | ||
'SCSIid': '3600a098038313577792450384a4a6275', | ||
'multihomelist': multihomelist, | ||
'target': target, | ||
'targetIQN': target_iqn, | ||
'localIQN': 'iqn.2018-05.com.example:0d312804' | ||
} | ||
if additional_dconf: | ||
sr_cmd.dconf.update(additional_dconf) | ||
|
||
sr_cmd.params = { | ||
'command': 'nop', | ||
'session_ref': 'test_session', | ||
'host_ref': 'test_host', | ||
'sr_ref': 'sr_ref' | ||
} | ||
sr_cmd.cmd = cmd | ||
return sr_cmd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.