Merge lp:~psivaa/uci-engine/rabbitmq-restish-with-proxy into lp:uci-engine/mthood

Proposed by Para Siva
Status: Merged
Merged at revision: 418
Proposed branch: lp:~psivaa/uci-engine/rabbitmq-restish-with-proxy
Merge into: lp:uci-engine/mthood
Diff against target: 262 lines (+105/-4)
9 files modified
charms/precise/rabbitmq-worker/config.yaml (+12/-0)
charms/precise/rabbitmq-worker/hooks/hooks.py (+37/-3)
charms/precise/restish/config.yaml (+8/-1)
charms/precise/restish/hooks/hooks.py (+29/-0)
juju-deployer/branch-source-builder.yaml.tmpl (+5/-0)
juju-deployer/deploy.py (+2/-0)
juju-deployer/image-builder.yaml.tmpl (+5/-0)
juju-deployer/lander.yaml.tmpl (+2/-0)
juju-deployer/test-runner.yaml.tmpl (+5/-0)
To merge this branch: bzr merge lp:~psivaa/uci-engine/rabbitmq-restish-with-proxy
Reviewer Review Type Date Requested Status
Vincent Ladeuil (community) Approve
Review via email: mp+220503@code.launchpad.net

Commit message

Making rabbitmq and restish charm deployments with proxy. Should be similar changes to the lander-jenkins and python-django. Also contains change to the rabbitmq upstart job to include the proxy env variables.

Description of the change

Making rabbitmq and restish charm deployments with proxy. Spotting is not easy when the charm silently ignores packages listed in yaml for installation :/. Should be similar changes to the lander-jenkins and python-django. Also contains change to the rabbitmq upstart job to include the proxy env variables.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

one comment about the jinja stuff again

418. By Para Siva

Better conditional logic for private-public cloud in rabbitmq charm upstart job

419. By Para Siva

Adding no_proxy for the keystone, swift hosts

420. By Para Siva

no_proxy in deploy and yaml files

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

This could go in to mthood branch before parking that for a bit.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks for the hard work, let's get that in.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charms/precise/rabbitmq-worker/config.yaml'
2--- charms/precise/rabbitmq-worker/config.yaml 2014-03-10 22:25:00 +0000
3+++ charms/precise/rabbitmq-worker/config.yaml 2014-05-29 10:25:18 +0000
4@@ -18,6 +18,18 @@
5 pip-packages:
6 type: string
7 description: "Pip packages required for this service"
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 host ips to bypass proxy."
16+ ppa-gpg-key:
17+ type: string
18+ default: ""
19+ description: GPG key fingerprint for the PPA
20 install_root:
21 type: string
22 description: "The root directory the service will be installed in"
23
24=== modified file 'charms/precise/rabbitmq-worker/hooks/hooks.py'
25--- charms/precise/rabbitmq-worker/hooks/hooks.py 2014-03-10 22:25:00 +0000
26+++ charms/precise/rabbitmq-worker/hooks/hooks.py 2014-05-29 10:25:18 +0000
27@@ -81,15 +81,42 @@
28 subprocess.check_call(args)
29
30
31+def setup_apt_proxy(config):
32+ proxy_url = config['proxy-url']
33+ apt_conf = textwrap.dedent("""\
34+ Acquire::http::proxy "%s";
35+ Acquire::https::proxy "%s";
36+ Acquire::HTTP::PROXY "%s";
37+ Acquire::HTTPS::PROXY "%s";
38+ """ % (proxy_url, proxy_url, proxy_url, proxy_url))
39+ with open('/etc/apt/apt.conf.d/95proxies', 'w') as f:
40+ f.write(apt_conf)
41+
42+
43+def import_ppa_keys(config):
44+ cmd = ['apt-key', 'adv', '--keyserver', 'keyserver.ubuntu.com',
45+ '--recv-keys', config['ppa-gpg-key']]
46+ try:
47+ subprocess.check_call(cmd)
48+ except:
49+ juju_log(MSG_ERROR, "Error importing repo key")
50+
51+
52 def install(config):
53- charmhelpers.fetch.configure_sources(update=True)
54-
55 pkgs = [x for x in config.get('packages', '').split(' ') if x]
56 pkgs.append('python-amqplib')
57 pkgs.append('python-pip')
58 pkgs.append('bzr')
59
60+ if config['proxy-url']:
61+ juju_info('Setting up apt with {}'.format(config['proxy-url']))
62+ setup_apt_proxy(config)
63+
64+ if config['ppa-gpg-key']:
65+ juju_info('Importing key for {}'.format(config['ppa-gpg-key']))
66+ import_ppa_keys(config)
67 juju_info('installing apt packages...')
68+ charmhelpers.fetch.configure_sources(update=True)
69 charmhelpers.fetch.apt_install(pkgs)
70
71 pip_pkgs = [x for x in config.get('pip-packages', '').split(' ') if x]
72@@ -129,14 +156,21 @@
73 setuid {uid}
74 setgid {gid}
75 chdir {sdir}
76-
77+ {proxy}
78 exec {main}
79 ''')
80+ proxy = ''
81+ if config['proxy-url']:
82+ url = config['proxy-url']
83+ no_proxy = config['no-proxy']
84+ proxy = ('env http_proxy={}\nenv https_proxy={}\n'
85+ 'env no_proxy={}\n'.format(url, url, no_proxy))
86 params = {
87 'main': config['main'],
88 'sdir': _service_dir(config),
89 'uid': config.get('uid', 'nobody'),
90 'gid': config.get('gid', 'nogroup'),
91+ 'proxy': proxy,
92 }
93 path = '/etc/init/{}.conf'.format(_service_name(config))
94 with tempfile.NamedTemporaryFile('w', delete=False) as f:
95
96=== modified file 'charms/precise/restish/config.yaml'
97--- charms/precise/restish/config.yaml 2014-03-10 22:25:00 +0000
98+++ charms/precise/restish/config.yaml 2014-05-29 10:25:18 +0000
99@@ -41,7 +41,14 @@
100 type: string
101 default: '/'
102 description: The vhost in the rabbitMQ server.
103-
104+ proxy-url:
105+ type: string
106+ default: ""
107+ description: The http proxy url for private clouds.
108+ ppa-gpg-key:
109+ type: string
110+ default: ""
111+ description: GPG key fingerprint for the PPA
112 # required for the gunicorn charm:
113 port:
114 type: int
115
116=== modified file 'charms/precise/restish/hooks/hooks.py'
117--- charms/precise/restish/hooks/hooks.py 2014-03-10 22:25:00 +0000
118+++ charms/precise/restish/hooks/hooks.py 2014-05-29 10:25:18 +0000
119@@ -6,6 +6,7 @@
120 import subprocess
121 import sys
122 import time
123+import textwrap
124
125 import charmhelpers.fetch
126
127@@ -82,12 +83,40 @@
128 subprocess.check_call(args)
129
130
131+def setup_apt_proxy(config):
132+ proxy_url = config['proxy-url']
133+ apt_conf = textwrap.dedent("""\
134+ Acquire::http::proxy "%s";
135+ Acquire::https::proxy "%s";
136+ Acquire::HTTP::PROXY "%s";
137+ Acquire::HTTPS::PROXY "%s";
138+ """ % (proxy_url, proxy_url, proxy_url, proxy_url))
139+ with open('/etc/apt/apt.conf.d/95proxies', 'w') as f:
140+ f.write(apt_conf)
141+
142+
143+def import_ppa_keys(config):
144+ cmd = ['apt-key', 'adv', '--keyserver', 'keyserver.ubuntu.com',
145+ '--recv-keys', config['ppa-gpg-key']]
146+ try:
147+ subprocess.check_call(cmd)
148+ except:
149+ juju_log(MSG_ERROR, "Error importing repo key")
150+
151+
152 def install(config):
153 pkgs = [x for x in config['packages'].split(' ') if x]
154 pkgs.append('bzr')
155 pkgs.append('python-restish')
156
157 juju_info('installing apt packages...')
158+ if config['proxy-url']:
159+ juju_info('Setting up apt with {}'.format(config['proxy-url']))
160+ setup_apt_proxy(config)
161+ if config['ppa-gpg-key']:
162+ juju_info('Importing key for {}'.format(config['ppa-gpg-key']))
163+ import_ppa_keys(config)
164+
165 charmhelpers.fetch.configure_sources(update=True)
166 charmhelpers.fetch.apt_install(pkgs)
167
168
169=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
170--- juju-deployer/branch-source-builder.yaml.tmpl 2014-03-14 10:37:28 +0000
171+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-05-29 10:25:18 +0000
172@@ -8,6 +8,8 @@
173 vcs: ${CI_CODE_SOURCE}
174 branch: ${CI_BRANCH}
175 tarball: ${CI_PAYLOAD_URL}
176+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
177+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
178 python_path: ./branch-source-builder:./ci-utils
179 # need non-default package python-amqplib for this service
180 packages: "python-webtest python-mock python-jinja2 python-amqplib"
181@@ -29,6 +31,9 @@
182 vcs: ${CI_CODE_SOURCE}
183 branch: ${CI_BRANCH}
184 tarball: ${CI_PAYLOAD_URL}
185+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
186+ no-proxy: ${CI_PRIVATE_NO_PROXY}
187+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
188 unit-config: include-base64://configs/unit_config.yaml
189 packages: "dput python-dput python-swiftclient lazr.enum"
190 install_sources: |
191
192=== modified file 'juju-deployer/deploy.py'
193--- juju-deployer/deploy.py 2014-05-07 01:25:30 +0000
194+++ juju-deployer/deploy.py 2014-05-29 10:25:18 +0000
195@@ -77,6 +77,8 @@
196 'CI_MASTER_PPA': 'ppa:ci-engineering-airline/ci-archive',
197 }
198 missing_required = []
199+ if not os.environ.get('CI_PRIVATE_NO_PROXY'):
200+ missing_required.append('CI_PRIVATE_NO_PROXY')
201 for key in cheetah_vars:
202 if key not in os.environ or len(os.environ[key]) == 0:
203 default = cheetah_vars[key]
204
205=== modified file 'juju-deployer/image-builder.yaml.tmpl'
206--- juju-deployer/image-builder.yaml.tmpl 2014-03-14 10:37:28 +0000
207+++ juju-deployer/image-builder.yaml.tmpl 2014-05-29 10:25:18 +0000
208@@ -8,6 +8,8 @@
209 vcs: ${CI_CODE_SOURCE}
210 branch: ${CI_BRANCH}
211 tarball: ${CI_PAYLOAD_URL}
212+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
213+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
214 python_path: ./image-builder:./ci-utils
215 packages: "python-webtest python-mock python-jinja2 python-amqplib"
216 json_status_path: api/v1/status
217@@ -28,6 +30,9 @@
218 vcs: ${CI_CODE_SOURCE}
219 branch: ${CI_BRANCH}
220 tarball: ${CI_PAYLOAD_URL}
221+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
222+ no-proxy: ${CI_PRIVATE_NO_PROXY}
223+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
224 packages: "qemu-utils python-glanceclient python-swiftclient"
225 uid: root
226 unit-config: include-base64://configs/unit_config.yaml
227
228=== modified file 'juju-deployer/lander.yaml.tmpl'
229--- juju-deployer/lander.yaml.tmpl 2014-05-20 12:33:46 +0000
230+++ juju-deployer/lander.yaml.tmpl 2014-05-29 10:25:18 +0000
231@@ -7,6 +7,8 @@
232 vcs: ${CI_CODE_SOURCE}
233 branch: ${CI_BRANCH}
234 tarball: ${CI_PAYLOAD_URL}
235+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
236+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
237 python_path: "./lander:./ci-utils"
238 # need non-default package python-amqplib for this service
239 packages: "python-webtest python-mock python-jinja2 python-jenkins"
240
241=== modified file 'juju-deployer/test-runner.yaml.tmpl'
242--- juju-deployer/test-runner.yaml.tmpl 2014-03-10 22:25:00 +0000
243+++ juju-deployer/test-runner.yaml.tmpl 2014-05-29 10:25:18 +0000
244@@ -13,6 +13,8 @@
245 vcs: ${CI_CODE_SOURCE}
246 branch: ${CI_BRANCH}
247 tarball: ${CI_PAYLOAD_URL}
248+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
249+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
250 python_path: test_runner:ci-utils
251 json_status_path: api/v1/status
252
253@@ -35,6 +37,9 @@
254 vcs: ${CI_CODE_SOURCE}
255 branch: ${CI_BRANCH}
256 tarball: ${CI_PAYLOAD_URL}
257+ proxy-url: ${CI_PRIVATE_HTTP_PROXY}
258+ no-proxy: ${CI_PRIVATE_NO_PROXY}
259+ ppa-gpg-key: ${CI_PPA_GPG_KEY}
260 packages: "python-requests python-novaclient python-swiftclient"
261 unit-config: include-base64://configs/unit_config.yaml
262 uid: root

Subscribers

People subscribed via source and target branches