Fix StringIO import and patch paramiko in Python 3
This fixes ModuleNotFoundError: No module named 'StringIO', raised in Python 3 functional tests. We also patch paramiko on Python 3, since we use it in functional tests. Change-Id: I357dd9c3ec7c0a76d31b7f94ec0e844d9bdcb5c5
This commit is contained in:
parent
e34047457c
commit
ff9ed8461e
|
@ -19,9 +19,9 @@ The test uses the default demo project and credentials and assumes there is a
|
||||||
centos-image present in Glance.
|
centos-image present in Glance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import StringIO
|
|
||||||
import testtools
|
import testtools
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -147,7 +147,7 @@ class TestEnrollment(testtools.TestCase):
|
||||||
# we wouldn't be able to connect to keystone from the same namespace.
|
# we wouldn't be able to connect to keystone from the same namespace.
|
||||||
|
|
||||||
pkey = paramiko.RSAKey.from_private_key(
|
pkey = paramiko.RSAKey.from_private_key(
|
||||||
StringIO.StringIO(self._key.private_key))
|
io.StringIO(self._key.private_key))
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.load_system_host_keys()
|
client.load_system_host_keys()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
@ -170,7 +170,7 @@ class TestEnrollment(testtools.TestCase):
|
||||||
stdin, stdout, stderr = ssh.exec_command('id admin')
|
stdin, stdout, stderr = ssh.exec_command('id admin')
|
||||||
self.assertRegex(
|
self.assertRegex(
|
||||||
'uid=\d+\(admin\) gid=\d+\(admins\) groups=\d+\(admins\)',
|
'uid=\d+\(admin\) gid=\d+\(admins\) groups=\d+\(admins\)',
|
||||||
stdout.read())
|
stdout.read().decode())
|
||||||
|
|
||||||
@loopingcall.RetryDecorator(200, 5, 5, (AssertionError,))
|
@loopingcall.RetryDecorator(200, 5, 5, (AssertionError,))
|
||||||
def _check_ipa_client_created(self):
|
def _check_ipa_client_created(self):
|
||||||
|
|
|
@ -16,6 +16,34 @@
|
||||||
replace: 'GSS_AUTH_AVAILABLE = False'
|
replace: 'GSS_AUTH_AVAILABLE = False'
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Install paramiko to patch it (Python3)
|
||||||
|
pip:
|
||||||
|
name: paramiko
|
||||||
|
executable: pip{{ python_version }}
|
||||||
|
become: true
|
||||||
|
when: python_version is defined
|
||||||
|
|
||||||
|
- name: Find Paramiko ssh_gss.py (Python3)
|
||||||
|
command: python{{ python_version }} -c "from paramiko import ssh_gss; print(ssh_gss.__file__.rstrip('c'))"
|
||||||
|
register: ssh_gss_file
|
||||||
|
when: python_version is defined
|
||||||
|
|
||||||
|
- name: Patch Paramiko (https://github.com/paramiko/paramiko/pull/1311)
|
||||||
|
replace:
|
||||||
|
path: '{{ ssh_gss_file.stdout }}'
|
||||||
|
regexp: 'GSS_EXCEPTIONS = \(gssapi.GSSException,\)'
|
||||||
|
replace: 'GSS_EXCEPTIONS = ()'
|
||||||
|
become: true
|
||||||
|
when: python_version is defined
|
||||||
|
|
||||||
|
- name: Patch Paramiko (https://github.com/paramiko/paramiko/pull/1311)
|
||||||
|
replace:
|
||||||
|
path: '{{ ssh_gss_file.stdout }}'
|
||||||
|
regexp: 'GSS_AUTH_AVAILABLE = True'
|
||||||
|
replace: 'GSS_AUTH_AVAILABLE = False'
|
||||||
|
become: true
|
||||||
|
when: python_version is defined
|
||||||
|
|
||||||
- name: Uninstall urllib3 to fix later conflict with python-urllib3 system package
|
- name: Uninstall urllib3 to fix later conflict with python-urllib3 system package
|
||||||
pip:
|
pip:
|
||||||
name: urllib3
|
name: urllib3
|
||||||
|
|
Loading…
Reference in New Issue