summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/setup_image.py
diff options
context:
space:
mode:
authorJoshua Powers <josh.powers@canonical.com>2017-09-11 10:29:19 -0700
committerScott Moser <smoser@brickies.net>2017-09-13 21:16:43 -0400
commit1ac4bc2a4758d330bb94cd1b2391121cf461ff6a (patch)
tree40f2e93a89a7d3b830fecf5b1d6c2208ffaf25d5 /tests/cloud_tests/setup_image.py
parented8f1b159174715403cb1ffa200ff6d080770152 (diff)
downloadvyos-cloud-init-1ac4bc2a4758d330bb94cd1b2391121cf461ff6a.tar.gz
vyos-cloud-init-1ac4bc2a4758d330bb94cd1b2391121cf461ff6a.zip
tests: execute: support command as string
If a string is passed to execute, then invoke 'bash', '-c', 'string'. That allows the less verbose execution of simple commands: image.execute("ls /run") compared to the more explicit but longer winded: image.execute(["ls", "/run"]) If 'env' was ever modified in execute or a method that it called, then the next invocation's default value would be changed. Instead use None and then set to a new empty dict in the method.
Diffstat (limited to 'tests/cloud_tests/setup_image.py')
-rw-r--r--tests/cloud_tests/setup_image.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/cloud_tests/setup_image.py b/tests/cloud_tests/setup_image.py
index 8053a093..3c0fff62 100644
--- a/tests/cloud_tests/setup_image.py
+++ b/tests/cloud_tests/setup_image.py
@@ -49,8 +49,8 @@ def install_deb(args, image):
LOG.debug(msg)
remote_path = os.path.join('/tmp', os.path.basename(args.deb))
image.push_file(args.deb, remote_path)
- cmd = 'dpkg -i {} || apt-get install --yes -f'.format(remote_path)
- image.execute(['/bin/sh', '-c', cmd], description=msg)
+ cmd = 'dpkg -i {}; apt-get install --yes -f'.format(remote_path)
+ image.execute(cmd, description=msg)
# check installed deb version matches package
fmt = ['-W', "--showformat='${Version}'"]
@@ -113,7 +113,7 @@ def upgrade(args, image):
msg = 'upgrading cloud-init'
LOG.debug(msg)
- image.execute(['/bin/sh', '-c', cmd], description=msg)
+ image.execute(cmd, description=msg)
def upgrade_full(args, image):
@@ -134,7 +134,7 @@ def upgrade_full(args, image):
msg = 'full system upgrade'
LOG.debug(msg)
- image.execute(['/bin/sh', '-c', cmd], description=msg)
+ image.execute(cmd, description=msg)
def run_script(args, image):
@@ -165,7 +165,7 @@ def enable_ppa(args, image):
msg = 'enable ppa: "{}" in target'.format(ppa)
LOG.debug(msg)
cmd = 'add-apt-repository --yes {} && apt-get update'.format(ppa)
- image.execute(['/bin/sh', '-c', cmd], description=msg)
+ image.execute(cmd, description=msg)
def enable_repo(args, image):
@@ -188,7 +188,7 @@ def enable_repo(args, image):
msg = 'enable repo: "{}" in target'.format(args.repo)
LOG.debug(msg)
- image.execute(['/bin/sh', '-c', cmd], description=msg)
+ image.execute(cmd, description=msg)
def setup_image(args, image):