From a5c80032f623b4a593612bc159257a2f52fe285e Mon Sep 17 00:00:00 2001 From: silvacarloss Date: Thu, 4 Feb 2021 14:08:59 -0300 Subject: [PATCH] [NetApp] Fix iSCSI CHAP auth issue during volume attach Fixes a failure in the NetApp ONTAP driver while trying to configure CHAP authentication during a volume attach operation, by making the code more flexible while trying to identify if the prompted field is available in the buffered message. Change-Id: I81dd9861b9464244f23967f4f83888d06b50754e Closes-Bug: #1914639 --- .../volume/drivers/netapp/dataontap/client/test_api.py | 9 +++++---- cinder/volume/drivers/netapp/dataontap/client/api.py | 2 +- ...hap-auth-issue-in-netapp-driver-e92eaa431d6fcbac.yaml | 7 +++++++ 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/bug-1914639-fix-chap-auth-issue-in-netapp-driver-e92eaa431d6fcbac.yaml diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py index 674629d1315..a2f4c3d7082 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py @@ -508,9 +508,10 @@ class SSHUtilTests(test.TestCase): self.sshutil.execute_command, ssh, 'ls') wait_on_stdout.assert_not_called() - @ddt.data('Password:', - 'Password: ', - 'Password: \n\n') + @ddt.data(b'Password:', + b'Password: ', + b'Password: \n\n', + b'Fake response \r\n Password: \n\n') def test_execute_command_with_prompt(self, response): ssh = mock.Mock(paramiko.SSHClient) stdin, stdout, stderr = self._mock_ssh_channel_files(paramiko.Channel) @@ -533,7 +534,7 @@ class SSHUtilTests(test.TestCase): ssh = mock.Mock(paramiko.SSHClient) stdin, stdout, stderr = self._mock_ssh_channel_files(paramiko.Channel) stdout_read = self.mock_object(stdout.channel, 'recv', - return_value='bad response') + return_value=b'bad response') self.mock_object(ssh, 'exec_command', return_value=(stdin, stdout, stderr)) diff --git a/cinder/volume/drivers/netapp/dataontap/client/api.py b/cinder/volume/drivers/netapp/dataontap/client/api.py index ada92e7f107..99e32875fdc 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/api.py +++ b/cinder/volume/drivers/netapp/dataontap/client/api.py @@ -601,7 +601,7 @@ class SSHUtil(object): stdin, stdout, stderr = client.exec_command(command) self._wait_on_stdout(stdout, timeout) response = stdout.channel.recv(999) - if response.strip() != expected_prompt_text: + if expected_prompt_text not in response.strip().decode(): msg = _("Unexpected output. Expected [%(expected)s] but " "received [%(output)s]") % { 'expected': expected_prompt_text, diff --git a/releasenotes/notes/bug-1914639-fix-chap-auth-issue-in-netapp-driver-e92eaa431d6fcbac.yaml b/releasenotes/notes/bug-1914639-fix-chap-auth-issue-in-netapp-driver-e92eaa431d6fcbac.yaml new file mode 100644 index 00000000000..6aed5cdc749 --- /dev/null +++ b/releasenotes/notes/bug-1914639-fix-chap-auth-issue-in-netapp-driver-e92eaa431d6fcbac.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed a CHAP authentication issue while trying to attach an iSCSI volume + using the NetApp ONTAP driver. Please refer to the + `Launchpad bug #1914639 `_ + for more details.