Merge ~powersj/cloud-init:cii-shlex-fix into cloud-init:master

Proposed by Joshua Powers on 2017-09-21
Status: Merged
Merged at revision: fd57d50911b9d2a2012dbc2b84c64566b857ab4b
Proposed branch: ~powersj/cloud-init:cii-shlex-fix
Merge into: cloud-init:master
Diff against target: 64 lines (+16/-15)
1 file modified
tests/cloud_tests/instances/nocloudkvm.py (+16/-15)
Reviewer Review Type Date Requested Status
Scott Moser Approve on 2017-09-25
Ryan Harper 2017-09-21 Approve on 2017-09-22
Server Team CI bot continuous-integration Approve on 2017-09-21
Review via email: mp+331167@code.launchpad.net

Commit Message

tests: remove dependency on shlex

This removes shlex and converts the subprocess commands to use a
list over a string.

To post a comment you must log in.

PASSED: Continuous integration, rev:c0ad5b4f90dca79814e0cdb1dd591900d38ac6af
https://jenkins.ubuntu.com/server/job/cloud-init-ci/342/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/342/rebuild

review: Approve (continuous-integration)
Ryan Harper (raharper) wrote :

Looks good.

review: Approve
Scott Moser (smoser) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/cloud_tests/instances/nocloudkvm.py b/tests/cloud_tests/instances/nocloudkvm.py
2index 7abfe73..8a0e531 100644
3--- a/tests/cloud_tests/instances/nocloudkvm.py
4+++ b/tests/cloud_tests/instances/nocloudkvm.py
5@@ -4,7 +4,6 @@
6
7 import os
8 import paramiko
9-import shlex
10 import socket
11 import subprocess
12 import time
13@@ -83,10 +82,10 @@ class NoCloudKVMInstance(base.Instance):
14
15 def mount_image_callback(self, cmd):
16 """Run mount-image-callback."""
17- mic = ('sudo mount-image-callback --system-mounts --system-resolvconf '
18- '%s -- chroot _MOUNTPOINT_ ' % self.name)
19-
20- out, err = c_util.subp(shlex.split(mic) + cmd)
21+ out, err = c_util.subp(['sudo', 'mount-image-callback',
22+ '--system-mounts', '--system-resolvconf',
23+ self.name, '--', 'chroot',
24+ '_MOUNTPOINT_'] + cmd)
25
26 return out, err
27
28@@ -122,11 +121,11 @@ class NoCloudKVMInstance(base.Instance):
29 if self.pid:
30 super(NoCloudKVMInstance, self).push_file()
31 else:
32- cmd = ("sudo mount-image-callback --system-mounts "
33- "--system-resolvconf %s -- chroot _MOUNTPOINT_ "
34- "/bin/sh -c 'cat - > %s'" % (self.name, remote_path))
35 local_file = open(local_path)
36- p = subprocess.Popen(shlex.split(cmd),
37+ p = subprocess.Popen(['sudo', 'mount-image-callback',
38+ '--system-mounts', '--system-resolvconf',
39+ self.name, '--', 'chroot', '_MOUNTPOINT_',
40+ '/bin/sh', '-c', 'cat - > %s' % remote_path],
41 stdin=local_file,
42 stdout=subprocess.PIPE,
43 stderr=subprocess.PIPE)
44@@ -186,12 +185,14 @@ class NoCloudKVMInstance(base.Instance):
45 self.pid_file = os.path.join(tmpdir, '%s.pid' % self.name)
46 self.ssh_port = self.get_free_port()
47
48- cmd = ('./tools/xkvm --disk %s,cache=unsafe --disk %s,cache=unsafe '
49- '--netdev user,hostfwd=tcp::%s-:22 '
50- '-- -pidfile %s -vnc none -m 2G -smp 2'
51- % (self.name, seed, self.ssh_port, self.pid_file))
52-
53- subprocess.Popen(shlex.split(cmd), close_fds=True,
54+ subprocess.Popen(['./tools/xkvm',
55+ '--disk', '%s,cache=unsafe' % self.name,
56+ '--disk', '%s,cache=unsafe' % seed,
57+ '--netdev',
58+ 'user,hostfwd=tcp::%s-:22' % self.ssh_port,
59+ '--', '-pidfile', self.pid_file, '-vnc', 'none',
60+ '-m', '2G', '-smp', '2'],
61+ close_fds=True,
62 stdin=subprocess.PIPE,
63 stdout=subprocess.PIPE,
64 stderr=subprocess.PIPE)

Subscribers

People subscribed via source and target branches