Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/allow-environment-variable-export into lp:snappy-ecosystem-tests

Proposed by Omer Akram
Status: Merged
Approved by: Santiago Baldassin
Approved revision: 31
Merged at revision: 30
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/allow-environment-variable-export
Merge into: lp:snappy-ecosystem-tests
Diff against target: 61 lines (+14/-5)
1 file modified
snappy_ecosystem_tests/environment/managers.py (+14/-5)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/allow-environment-variable-export
Reviewer Review Type Date Requested Status
Santiago Baldassin (community) Approve
platform-qa-bot continuous-integration Approve
Review via email: mp+318927@code.launchpad.net

Commit message

Allow export of environment variables inside container.

Description of the change

Allow export of environment variables inside container.

To post a comment you must log in.
31. By Omer Akram

simple

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy_ecosystem_tests/environment/managers.py'
2--- snappy_ecosystem_tests/environment/managers.py 2017-03-03 13:44:31 +0000
3+++ snappy_ecosystem_tests/environment/managers.py 2017-03-03 15:53:20 +0000
4@@ -34,6 +34,10 @@
5 from snappy_ecosystem_tests.environment.data.snapd import (
6 DEFAULT_CONTAINER_CONFIG, SNAPD_CONTAINER_NAME)
7
8+COMMAND_ALLOW_ENV_VARS = 'sed -i \'/^AcceptEnv/ s/$/ {}/\' ' \
9+ '/etc/ssh/sshd_config'
10+
11+
12 def get_manager(mode):
13 """Get the manager for the given mode"""
14 supported_modules = {
15@@ -88,7 +92,6 @@
16 container_name,
17 DEPENDENCIES[container_type] + DEPENDENCIES['shared'])
18
19-
20 def configure(self, container_name, container_type, profile):
21 """Configure a given container"""
22 container = self.client.containers.get(container_name)
23@@ -102,13 +105,20 @@
24 @retry(stop_max_attempt_number=5, wait_fixed=3000,
25 retry_on_exception=lambda exception: isinstance(
26 exception, LXDAPIException))
27- def enable_ssh(self, container_name):
28+ def enable_ssh(self, container_name, container_type, profile):
29 """Enable the ssh connection on the container"""
30 container = self.client.containers.get(container_name)
31 pub_key = open(
32 os.path.expanduser('~') + '/.ssh/id_rsa.pub').read().strip('\n')
33 container.files.put('/home/ubuntu/.ssh/authorized_keys', pub_key)
34-
35+ # Allow export of environment variables over ssh.
36+ container.execute(
37+ COMMAND_ALLOW_ENV_VARS.format(
38+ ' '.join(PROFILES[profile][container_type]
39+ ['environment_variables'].keys())
40+ )
41+ )
42+ container.execute('service ssh restart')
43
44 def setup(self, profile):
45 """setup the container based on the profile"""
46@@ -116,14 +126,13 @@
47 self._setup(
48 SNAPCRAFT_CONTAINER_NAME, constants.SNAPCRAFT, profile)
49
50-
51 def _setup(self, container_name, container_type, profile):
52 """
53 Launch a container, enable ssh, install dependencies
54 and setup the needed environment variables
55 """
56 self.launch(container_name)
57- self.enable_ssh(container_name)
58+ self.enable_ssh(container_name, container_type, profile)
59 self.install(
60 container_name,
61 packages=[PROFILES[profile][container_type]["package_name"]],

Subscribers

People subscribed via source and target branches