[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
This commit is contained in:
silvacarloss 2021-02-04 14:08:59 -03:00
parent 355681cd53
commit a5c80032f6
3 changed files with 13 additions and 5 deletions

View File

@ -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))

View File

@ -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,

View File

@ -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 <https://bugs.launchpad.net/cinder/+bug/1914639>`_
for more details.