Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/setting-proxy-to-containers into lp:snappy-ecosystem-tests

Proposed by Heber Parrucci
Status: Merged
Approved by: Santiago Baldassin
Approved revision: 43
Merged at revision: 43
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/setting-proxy-to-containers
Merge into: lp:snappy-ecosystem-tests
Diff against target: 34 lines (+17/-0)
1 file modified
snappy_ecosystem_tests/environment/containers/lxd.py (+17/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/setting-proxy-to-containers
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Approve
Santiago Baldassin (community) Approve
Review via email: mp+319927@code.launchpad.net

Commit message

Setting proxy environment variables to containers if they are set in the host

Description of the change

Setting proxy environment variables to containers if they are set in the host

To post a comment you must log in.
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Looks good

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy_ecosystem_tests/environment/containers/lxd.py'
2--- snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-15 12:37:04 +0000
3+++ snappy_ecosystem_tests/environment/containers/lxd.py 2017-03-15 14:15:26 +0000
4@@ -33,6 +33,7 @@
5
6 LOGGER = logging.getLogger(__name__)
7 DOMAIN_PING = 'ubuntu.com'
8+VARIABLES = ['https_proxy', 'http_proxy']
9
10
11 class LXDDriver:
12@@ -146,6 +147,22 @@
13 self._execute_command(
14 container,
15 'echo \'{}={}\' >> /etc/environment'.format(key, value))
16+ self.set_variables(VARIABLES, container)
17+
18+ def set_variables(self, variables, container):
19+ """Read given environment variables in the host and set to
20+ the container"""
21+ for var in variables:
22+ self._set_variable(var, container)
23+
24+ def _set_variable(self, variable, container):
25+ """Read the given variable in the host and set to the container"""
26+ value = os.environ.get(variable)
27+ if value:
28+ self._execute_command(
29+ container,
30+ 'echo \'{}={}\' >> /etc/environment'.format(variable,
31+ value))
32
33 def wait_for_internet(self, container, attempts_count=10,
34 attempt_interval=1, ping_domain=DOMAIN_PING):

Subscribers

People subscribed via source and target branches