From c69ac0c92e41f866e4637426207cf3a303491503 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Mon, 19 Jun 2017 23:37:20 -0500 Subject: [PATCH] Correct ansible imports The import `to_bytes` was broken with recent ansible changes. This change ensures that we're using the method from the embeded Ansible ssh plugin instead of trying to import it. I've also moved the `shlex_quote` method back to the embeded module so that we ensure we're not facing similar import issues in the future. Change-Id: I24b0e1c71650598f8ff5e7b4e1823411787266d2 Signed-off-by: Kevin Carter --- connection/ssh.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/connection/ssh.py b/connection/ssh.py index 5ad0ac7f..ddc2dac7 100644 --- a/connection/ssh.py +++ b/connection/ssh.py @@ -17,9 +17,6 @@ import imp import os -from ansible.module_utils._text import to_bytes -from ansible.compat.six.moves import shlex_quote - # NOTICE(cloudnull): The connection plugin imported using the full path to the # file because the ssh connection plugin is not importable. import ansible.plugins.connection as conn @@ -75,8 +72,8 @@ class Connection(SSH.Connection): # Remote user is normally set, but if it isn't, then default to 'root' container_user = 'root' if self._play_context.remote_user: - container_user = to_bytes(self._play_context.remote_user, - errors='surrogate_or_strict') + container_user = SSH.to_bytes(self._play_context.remote_user, + errors='surrogate_or_strict') # NOTE(hwoarang) It is important to connect to the container # without inheriting the host environment as that would interfere # with running commands and services inside the container. However, @@ -97,7 +94,7 @@ class Connection(SSH.Connection): # to a command etc... It's somewhat ugly but maybe it can be # improved somehow... cmd = '%s -- su - %s -c %s' % (lxc_command, container_user, - shlex_quote(cmd)) + SSH.shlex_quote(cmd)) if self._chroot_check(): chroot_command = 'chroot %s' % self.chroot_path