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 <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2017-06-19 23:37:20 -05:00
parent d66fb8f310
commit c69ac0c92e
No known key found for this signature in database
GPG Key ID: 69FEFFC5E2D9273F
1 changed files with 3 additions and 6 deletions

View File

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