summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlucasmoura <lucas.moura@canonical.com>2020-11-26 18:53:57 -0300
committerGitHub <noreply@github.com>2020-11-26 16:53:57 -0500
commit53f2bfbb92c8281fd610250cb1a6107bd4eeb50a (patch)
tree15adb793dea1f7d95463b861d4cbbce0703b8253
parent6ee01078ae74338e0a11c1d4b13a667c01e9b26f (diff)
downloadvyos-cloud-init-53f2bfbb92c8281fd610250cb1a6107bd4eeb50a.tar.gz
vyos-cloud-init-53f2bfbb92c8281fd610250cb1a6107bd4eeb50a.zip
Drop use_sudo attribute on IntegrationInstance (#694)
pycloudlib will stop running commands as root by default on LXD. To align with that change and make the behavior consistent with other clouds we support, our LXD instances will now run the commands with sudo by default.
-rw-r--r--tests/integration_tests/instances.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/tests/integration_tests/instances.py b/tests/integration_tests/instances.py
index a0a5fb6b..033847b8 100644
--- a/tests/integration_tests/instances.py
+++ b/tests/integration_tests/instances.py
@@ -26,8 +26,6 @@ def _get_tmp_path():
class IntegrationInstance:
- use_sudo = True
-
def __init__(self, cloud: 'IntegrationCloud', instance: BaseInstance,
settings=integration_settings):
self.cloud = cloud
@@ -37,11 +35,9 @@ class IntegrationInstance:
def destroy(self):
self.instance.delete()
- def execute(self, command, *, use_sudo=None) -> Result:
+ def execute(self, command, *, use_sudo=True) -> Result:
if self.instance.username == 'root' and use_sudo is False:
raise Exception('Root user cannot run unprivileged')
- if use_sudo is None:
- use_sudo = self.use_sudo
return self.instance.execute(command, use_sudo=use_sudo)
def pull_file(self, remote_path, local_path):
@@ -97,21 +93,21 @@ class IntegrationInstance:
def install_proposed_image(self):
log.info('Installing proposed image')
remote_script = (
- '{sudo} echo deb "http://archive.ubuntu.com/ubuntu '
+ 'echo deb "http://archive.ubuntu.com/ubuntu '
'$(lsb_release -sc)-proposed main" | '
- '{sudo} tee /etc/apt/sources.list.d/proposed.list\n'
- '{sudo} apt-get update -q\n'
- '{sudo} apt-get install -qy cloud-init'
- ).format(sudo='sudo' if self.use_sudo else '')
+ 'tee /etc/apt/sources.list.d/proposed.list\n'
+ 'apt-get update -q\n'
+ 'apt-get install -qy cloud-init'
+ )
self._install_new_cloud_init(remote_script)
def install_ppa(self, repo):
log.info('Installing PPA')
remote_script = (
- '{sudo} add-apt-repository {repo} -y && '
- '{sudo} apt-get update -q && '
- '{sudo} apt-get install -qy cloud-init'
- ).format(sudo='sudo' if self.use_sudo else '', repo=repo)
+ 'add-apt-repository {repo} -y && '
+ 'apt-get update -q && '
+ 'apt-get install -qy cloud-init'
+ ).format(repo=repo)
self._install_new_cloud_init(remote_script)
def install_deb(self):
@@ -122,8 +118,7 @@ class IntegrationInstance:
self.push_file(
local_path=integration_settings.CLOUD_INIT_SOURCE,
remote_path=remote_path)
- remote_script = '{sudo} dpkg -i {path}'.format(
- sudo='sudo' if self.use_sudo else '', path=remote_path)
+ remote_script = 'dpkg -i {path}'.format(path=remote_path)
self._install_new_cloud_init(remote_script)
def __enter__(self):
@@ -151,4 +146,4 @@ class IntegrationOciInstance(IntegrationInstance):
class IntegrationLxdInstance(IntegrationInstance):
- use_sudo = False
+ pass