Merge lp:~psivaa/charms/precise/ubuntu-ci-services-itself/upstart-with-proxy-2 into lp:~canonical-ci-engineering/charms/precise/ubuntu-ci-services-itself/upstart

Proposed by Para Siva
Status: Needs review
Proposed branch: lp:~psivaa/charms/precise/ubuntu-ci-services-itself/upstart-with-proxy-2
Merge into: lp:~canonical-ci-engineering/charms/precise/ubuntu-ci-services-itself/upstart
Diff against target: 47 lines (+15/-1)
2 files modified
config.yaml (+8/-0)
hooks/hooks.py (+7/-1)
To merge this branch: bzr merge lp:~psivaa/charms/precise/ubuntu-ci-services-itself/upstart-with-proxy-2
Reviewer Review Type Date Requested Status
Andy Doan (community) Needs Fixing
Review via email: mp+220333@code.launchpad.net

Commit message

This is for ppa-cleaner upstart job to take in http proxies.

Description of the change

This is for ppa-cleaner upstart job to take in http proxies.

To post a comment you must log in.
Revision history for this message
Para Siva (psivaa) wrote :

Just realised the need for this to work with uci-engine trunk. Still WIP

Revision history for this message
Para Siva (psivaa) wrote :

This should work for both private clouds and otherwise. The change look cumbersome. Please feel free to correct.

Revision history for this message
Andy Doan (doanac) wrote :

You should be able to keep this diff smaller with jinja2 conditional logic like:

{% if proxy_url %}
env http_proxy={proxy_url}
env https_proxy={proxy_url}
{% endif %}

Then you won't need those two big blocks that are essentially the same logic

review: Needs Fixing
11. By Para Siva

Better conditional format

12. By Para Siva

Upstart command to work with both type of clouds-fixed

13. By Para Siva

Typo fix

Revision history for this message
Para Siva (psivaa) wrote :

Thanks for that doanac. Direct copying of that snippet is throwing KeyError during the charm installation and therefore I've used the fix in r13. This atleast does not throw errors during deployments. I've tried to verify if that'd give me the needed upstart job but it's taking too long to get one deployment going. Will update once i've been able to deploy.

Revision history for this message
Andy Doan (doanac) wrote :

small comment to make it better

14. By Para Siva

Using doanac's hack for conditional proxy

15. By Para Siva

Adding no-proxy for the needed urls

16. By Para Siva

Fix the syntax in no proxy inclusion

Unmerged revisions

16. By Para Siva

Fix the syntax in no proxy inclusion

15. By Para Siva

Adding no-proxy for the needed urls

14. By Para Siva

Using doanac's hack for conditional proxy

13. By Para Siva

Typo fix

12. By Para Siva

Upstart command to work with both type of clouds-fixed

11. By Para Siva

Better conditional format

10. By Para Siva

Making the hooks conditional if the proxy is defined

9. By Para Siva

Pep8 fix

8. By Para Siva

Add http proxy env variable for ppa-cleaner upstart job

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-01-15 18:39:50 +0000
3+++ config.yaml 2014-05-27 12:39:07 +0000
4@@ -2,6 +2,14 @@
5 script:
6 type: string
7 description: "The script to execute as a daemon. Can be a relative path"
8+ proxy-url:
9+ type: string
10+ default: ""
11+ description: The http proxy url for private clouds.
12+ no-proxy:
13+ type: string
14+ default: ""
15+ description: The hopt ips to bypass proxy.
16 service-name:
17 type: string
18 description: "The name of the upstart job"
19
20=== modified file 'hooks/hooks.py'
21--- hooks/hooks.py 2014-03-21 23:22:42 +0000
22+++ hooks/hooks.py 2014-05-27 12:39:07 +0000
23@@ -46,10 +46,15 @@
24
25 setuid {uid}
26 setgid {gid}
27-
28 chdir {sdir}
29+ {proxy}
30 exec {main}
31 ''')
32+ proxy = ''
33+ if config['proxy-url']:
34+ url = config['proxy-url']
35+ no_proxy = config['no-proxy']
36+ proxy = 'env http_proxy=%s\nenv https_proxy=%s\nenv no_proxy=%s\n' % (url, url, no_proxy)
37 defstart = '(local-filesystems and net-device-up IFACE=eth0)'
38 defstop = 'runlevel [!12345]'
39 params = {
40@@ -60,6 +65,7 @@
41 'stop_on': config.get('stop-on', defstop),
42 'uid': config.get('uid', 'nobody'),
43 'gid': config.get('gid', 'nogroup'),
44+ 'proxy': proxy,
45 }
46
47 with open(_upstart_file(config), 'w') as f:

Subscribers

People subscribed via source and target branches