diff options
author | Joshua Powers <josh.powers@canonical.com> | 2017-09-21 10:16:00 -0700 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2017-09-25 16:48:59 -0400 |
commit | fd57d50911b9d2a2012dbc2b84c64566b857ab4b (patch) | |
tree | e9bc5076d01dc5e644ec8cc67acf9f2c970c69b9 /tests | |
parent | ad099a53d120e88719a5ad50f29d22e9f7a52bc7 (diff) | |
download | vyos-cloud-init-fd57d50911b9d2a2012dbc2b84c64566b857ab4b.tar.gz vyos-cloud-init-fd57d50911b9d2a2012dbc2b84c64566b857ab4b.zip |
tests: remove dependency on shlex
This removes shlex and converts the subprocess commands to use a
list over a string.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cloud_tests/instances/nocloudkvm.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/cloud_tests/instances/nocloudkvm.py b/tests/cloud_tests/instances/nocloudkvm.py index 7abfe737..8a0e5319 100644 --- a/tests/cloud_tests/instances/nocloudkvm.py +++ b/tests/cloud_tests/instances/nocloudkvm.py @@ -4,7 +4,6 @@ import os import paramiko -import shlex import socket import subprocess import time @@ -83,10 +82,10 @@ class NoCloudKVMInstance(base.Instance): def mount_image_callback(self, cmd): """Run mount-image-callback.""" - mic = ('sudo mount-image-callback --system-mounts --system-resolvconf ' - '%s -- chroot _MOUNTPOINT_ ' % self.name) - - out, err = c_util.subp(shlex.split(mic) + cmd) + out, err = c_util.subp(['sudo', 'mount-image-callback', + '--system-mounts', '--system-resolvconf', + self.name, '--', 'chroot', + '_MOUNTPOINT_'] + cmd) return out, err @@ -122,11 +121,11 @@ class NoCloudKVMInstance(base.Instance): if self.pid: super(NoCloudKVMInstance, self).push_file() else: - cmd = ("sudo mount-image-callback --system-mounts " - "--system-resolvconf %s -- chroot _MOUNTPOINT_ " - "/bin/sh -c 'cat - > %s'" % (self.name, remote_path)) local_file = open(local_path) - p = subprocess.Popen(shlex.split(cmd), + p = subprocess.Popen(['sudo', 'mount-image-callback', + '--system-mounts', '--system-resolvconf', + self.name, '--', 'chroot', '_MOUNTPOINT_', + '/bin/sh', '-c', 'cat - > %s' % remote_path], stdin=local_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -186,12 +185,14 @@ class NoCloudKVMInstance(base.Instance): self.pid_file = os.path.join(tmpdir, '%s.pid' % self.name) self.ssh_port = self.get_free_port() - cmd = ('./tools/xkvm --disk %s,cache=unsafe --disk %s,cache=unsafe ' - '--netdev user,hostfwd=tcp::%s-:22 ' - '-- -pidfile %s -vnc none -m 2G -smp 2' - % (self.name, seed, self.ssh_port, self.pid_file)) - - subprocess.Popen(shlex.split(cmd), close_fds=True, + subprocess.Popen(['./tools/xkvm', + '--disk', '%s,cache=unsafe' % self.name, + '--disk', '%s,cache=unsafe' % seed, + '--netdev', + 'user,hostfwd=tcp::%s-:22' % self.ssh_port, + '--', '-pidfile', self.pid_file, '-vnc', 'none', + '-m', '2G', '-smp', '2'], + close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |