Merge lp:~psivaa/uci-engine/django-in-mthood into lp:uci-engine/mthood
- django-in-mthood
- Merge into mthood
Status: | Merged |
---|---|
Merged at revision: | 417 |
Proposed branch: | lp:~psivaa/uci-engine/django-in-mthood |
Merge into: | lp:uci-engine/mthood |
Prerequisite: | lp:~psivaa/uci-engine/lander-jenkins-plugin |
Diff against target: |
204 lines (+60/-5) 5 files modified
charms/precise/python-django/config.yaml (+8/-0) charms/precise/python-django/hooks/hooks.py (+37/-3) juju-deployer/deploy.py (+11/-2) juju-deployer/ppa-assigner.yaml.tmpl (+2/-0) juju-deployer/ticket-system.yaml.tmpl (+2/-0) |
To merge this branch: | bzr merge lp:~psivaa/uci-engine/django-in-mthood |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Canonical CI Engineering | Pending | ||
Review via email: mp+219118@code.launchpad.net |
Commit message
Fixes the python-django installation related issues in mthood private cloud. This completes the changes needed for the deployment in the private cloud.
Description of the change
Fixes the python-django installation related issues in mthood private cloud. This completes the changes needed for the deployment in the private cloud.
Andy Doan (doanac) wrote : | # |
Para Siva (psivaa) wrote : | # |
Thanks doanac for the comments. They all should be fixed now. Could you please verify?
One note on pep8 warnings is that hooks.py in this charm throws quite a lot of warnings about lines that haven't been changed as part of this MP. I haven't attempted to fix all of them but only the lines that changed due to time limitation.
Andy Doan (doanac) wrote : | # |
tried out inline comments for this.
Para Siva (psivaa) wrote : | # |
r417 should fix the inline comments for r416
Para Siva (psivaa) wrote : | # |
Curious if I could get a nod for this to go in so that we don't lose this work. This part alone is functionally in working order, although there are other tweaks needed in some other components for mthood to be fully functional.
This is in a state where it can be picked up later if mthood needs development.
Vincent Ladeuil (vila) wrote : | # |
Let's park that now indeed.
Preview Diff
1 | === modified file 'charms/precise/python-django/config.yaml' | |||
2 | --- charms/precise/python-django/config.yaml 2014-03-10 22:25:00 +0000 | |||
3 | +++ charms/precise/python-django/config.yaml 2014-06-06 10:05:35 +0000 | |||
4 | @@ -22,6 +22,14 @@ | |||
5 | 22 | type: string | 22 | type: string |
6 | 23 | default: "" | 23 | default: "" |
7 | 24 | description: The vcs url to checkout. | 24 | description: The vcs url to checkout. |
8 | 25 | proxy-url: | ||
9 | 26 | type: string | ||
10 | 27 | default: "" | ||
11 | 28 | description: The http proxy url for private clouds. | ||
12 | 29 | ppa-gpg-key: | ||
13 | 30 | type: string | ||
14 | 31 | default: "" | ||
15 | 32 | description: GPG key fingerprint for the PPA | ||
16 | 25 | repos_username: | 33 | repos_username: |
17 | 26 | type: string | 34 | type: string |
18 | 27 | default: "" | 35 | default: "" |
19 | 28 | 36 | ||
20 | === modified file 'charms/precise/python-django/hooks/hooks.py' | |||
21 | --- charms/precise/python-django/hooks/hooks.py 2014-03-10 22:25:00 +0000 | |||
22 | +++ charms/precise/python-django/hooks/hooks.py 2014-06-06 10:05:35 +0000 | |||
23 | @@ -1,5 +1,4 @@ | |||
24 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
25 | 2 | # vim: et ai ts=4 sw=4: | ||
26 | 3 | 2 | ||
27 | 4 | import base64 | 3 | import base64 |
28 | 5 | import json | 4 | import json |
29 | @@ -10,12 +9,13 @@ | |||
30 | 10 | import subprocess | 9 | import subprocess |
31 | 11 | import sys | 10 | import sys |
32 | 12 | import time | 11 | import time |
33 | 12 | import textwrap | ||
34 | 13 | from pwd import getpwnam | 13 | from pwd import getpwnam |
35 | 14 | from grp import getgrnam | 14 | from grp import getgrnam |
36 | 15 | from random import choice | 15 | from random import choice |
37 | 16 | 16 | ||
38 | 17 | CHARM_PACKAGES = ["python-pip", "python-jinja2", "mercurial", "git-core", | 17 | CHARM_PACKAGES = ["python-pip", "python-jinja2", "mercurial", "git-core", |
40 | 18 | "subversion", "bzr", "gettext"] | 18 | "subversion", "bzr", "gettext", "tsocks"] |
41 | 19 | 19 | ||
42 | 20 | INJECTED_WARNING = """ | 20 | INJECTED_WARNING = """ |
43 | 21 | #------------------------------------------------------------------------------ | 21 | #------------------------------------------------------------------------------ |
44 | @@ -352,6 +352,7 @@ | |||
45 | 352 | this_host = run("unit-get private-address") | 352 | this_host = run("unit-get private-address") |
46 | 353 | return this_host.strip() | 353 | return this_host.strip() |
47 | 354 | 354 | ||
48 | 355 | |||
49 | 355 | def process_template(template_name, template_vars, destination): | 356 | def process_template(template_name, template_vars, destination): |
50 | 356 | # --- exported service configuration file | 357 | # --- exported service configuration file |
51 | 357 | from jinja2 import Environment, FileSystemLoader | 358 | from jinja2 import Environment, FileSystemLoader |
52 | @@ -365,6 +366,16 @@ | |||
53 | 365 | with open(destination, 'w') as inject_file: | 366 | with open(destination, 'w') as inject_file: |
54 | 366 | inject_file.write(str(template)) | 367 | inject_file.write(str(template)) |
55 | 367 | 368 | ||
56 | 369 | |||
57 | 370 | def import_ppa_keys(): | ||
58 | 371 | cmd = ['apt-key', 'adv', '--keyserver', 'keyserver.ubuntu.com', | ||
59 | 372 | '--recv-keys', ppa_gpg_key] | ||
60 | 373 | try: | ||
61 | 374 | subprocess.check_call(cmd) | ||
62 | 375 | except: | ||
63 | 376 | juju_log(MSG_ERROR, "Error importing repo key") | ||
64 | 377 | |||
65 | 378 | |||
66 | 368 | def configure_and_install(rel): | 379 | def configure_and_install(rel): |
67 | 369 | 380 | ||
68 | 370 | def _import_key(id): | 381 | def _import_key(id): |
69 | @@ -377,12 +388,16 @@ | |||
70 | 377 | 388 | ||
71 | 378 | if rel == 'distro': | 389 | if rel == 'distro': |
72 | 379 | return apt_get_install("python-django") | 390 | return apt_get_install("python-django") |
73 | 391 | |||
74 | 380 | elif rel[:4] == "ppa:": | 392 | elif rel[:4] == "ppa:": |
75 | 393 | if ppa_gpg_key: | ||
76 | 394 | import_ppa_keys() | ||
77 | 381 | src = rel | 395 | src = rel |
78 | 382 | subprocess.check_call(["add-apt-repository", "-y", src]) | 396 | subprocess.check_call(["add-apt-repository", "-y", src]) |
79 | 383 | apt_get_update() | 397 | apt_get_update() |
80 | 384 | 398 | ||
81 | 385 | return apt_get_install("python-django") | 399 | return apt_get_install("python-django") |
82 | 400 | |||
83 | 386 | elif rel[:3] == "deb": | 401 | elif rel[:3] == "deb": |
84 | 387 | l = len(rel.split('|')) | 402 | l = len(rel.split('|')) |
85 | 388 | if l == 2: | 403 | if l == 2: |
86 | @@ -465,6 +480,17 @@ | |||
87 | 465 | subprocess.check_call(cmd, shell=True) | 480 | subprocess.check_call(cmd, shell=True) |
88 | 466 | 481 | ||
89 | 467 | 482 | ||
90 | 483 | def setup_apt_proxy(): | ||
91 | 484 | apt_conf= textwrap.dedent("""\ | ||
92 | 485 | Acquire::http::proxy "%s"; | ||
93 | 486 | Acquire::https::proxy "%s"; | ||
94 | 487 | Acquire::HTTP::PROXY "%s"; | ||
95 | 488 | Acquire::HTTPS::PROXY "%s"; | ||
96 | 489 | """ % (proxy_url, proxy_url, proxy_url, proxy_url)) | ||
97 | 490 | with open('/etc/apt/apt.conf.d/95proxies', 'w') as f: | ||
98 | 491 | f.write(apt_conf) | ||
99 | 492 | |||
100 | 493 | |||
101 | 468 | ############################################################################### | 494 | ############################################################################### |
102 | 469 | # Hook functions | 495 | # Hook functions |
103 | 470 | ############################################################################### | 496 | ############################################################################### |
104 | @@ -475,6 +501,8 @@ | |||
105 | 475 | time.sleep(10) | 501 | time.sleep(10) |
106 | 476 | else: | 502 | else: |
107 | 477 | break | 503 | break |
108 | 504 | if proxy_url: | ||
109 | 505 | setup_apt_proxy() | ||
110 | 478 | 506 | ||
111 | 479 | configure_and_install(django_version) | 507 | configure_and_install(django_version) |
112 | 480 | 508 | ||
113 | @@ -510,7 +538,11 @@ | |||
114 | 510 | else: | 538 | else: |
115 | 511 | run('git clone %s %s' % (repos_url, vcs_clone_dir)) | 539 | run('git clone %s %s' % (repos_url, vcs_clone_dir)) |
116 | 512 | elif vcs == 'bzr' or vcs == 'bazaar' or vcs == 'branch': | 540 | elif vcs == 'bzr' or vcs == 'bazaar' or vcs == 'branch': |
118 | 513 | run('bzr branch %s %s' % (repos_url, vcs_clone_dir)) | 541 | if proxy_url: |
119 | 542 | run('http_proxy=%s https_proxy=%s bzr branch %s %s' | ||
120 | 543 | % (proxy_url, proxy_url, repos_url, vcs_clone_dir)) | ||
121 | 544 | else: | ||
122 | 545 | run('bzr branch %s %s' % (repos_url, vcs_clone_dir)) | ||
123 | 514 | elif vcs == 'svn' or vcs == 'subversion': | 546 | elif vcs == 'svn' or vcs == 'subversion': |
124 | 515 | run('svn co %s %s' % (repos_url, vcs_clone_dir)) | 547 | run('svn co %s %s' % (repos_url, vcs_clone_dir)) |
125 | 516 | elif vcs == 'tarball': | 548 | elif vcs == 'tarball': |
126 | @@ -810,6 +842,8 @@ | |||
127 | 810 | repos_username = config_data['repos_username'] | 842 | repos_username = config_data['repos_username'] |
128 | 811 | repos_password = config_data['repos_password'] | 843 | repos_password = config_data['repos_password'] |
129 | 812 | repos_branch = config_data['repos_branch'] | 844 | repos_branch = config_data['repos_branch'] |
130 | 845 | proxy_url = config_data['proxy-url'] | ||
131 | 846 | ppa_gpg_key = config_data['ppa-gpg-key'] | ||
132 | 813 | 847 | ||
133 | 814 | project_template_extension = config_data['project_template_extension'] | 848 | project_template_extension = config_data['project_template_extension'] |
134 | 815 | project_template_url = config_data['project_template_url'] | 849 | project_template_url = config_data['project_template_url'] |
135 | 816 | 850 | ||
136 | === modified file 'juju-deployer/deploy.py' | |||
137 | --- juju-deployer/deploy.py 2014-05-07 01:25:30 +0000 | |||
138 | +++ juju-deployer/deploy.py 2014-06-06 10:05:35 +0000 | |||
139 | @@ -56,7 +56,7 @@ | |||
140 | 56 | value)) | 56 | value)) |
141 | 57 | 57 | ||
142 | 58 | 58 | ||
144 | 59 | def check_environment(): | 59 | def check_environment(args): |
145 | 60 | '''Cheetah requires environment variables for populating our templates''' | 60 | '''Cheetah requires environment variables for populating our templates''' |
146 | 61 | cheetah_vars = { | 61 | cheetah_vars = { |
147 | 62 | 'OS_USERNAME': None, | 62 | 'OS_USERNAME': None, |
148 | @@ -77,6 +77,12 @@ | |||
149 | 77 | 'CI_MASTER_PPA': 'ppa:ci-engineering-airline/ci-archive', | 77 | 'CI_MASTER_PPA': 'ppa:ci-engineering-airline/ci-archive', |
150 | 78 | } | 78 | } |
151 | 79 | missing_required = [] | 79 | missing_required = [] |
152 | 80 | if args.mthood_deployment: | ||
153 | 81 | os.environ['CI_PPA'] = 'ppa:canonical-ci-engineering/mthood-phase-0' | ||
154 | 82 | if not os.environ.get('CI_PRIVATE_HTTP_PROXY'): | ||
155 | 83 | missing_required.append('CI_PRIVATE_HTTP_PROXY') | ||
156 | 84 | if not os.environ.get('CI_PPA_GPG_KEY'): | ||
157 | 85 | missing_required.append('CI_PPA_GPG_KEY') | ||
158 | 80 | for key in cheetah_vars: | 86 | for key in cheetah_vars: |
159 | 81 | if key not in os.environ or len(os.environ[key]) == 0: | 87 | if key not in os.environ or len(os.environ[key]) == 0: |
160 | 82 | default = cheetah_vars[key] | 88 | default = cheetah_vars[key] |
161 | @@ -352,13 +358,16 @@ | |||
162 | 352 | parser.add_argument('--private-launchpad', action='store_true', | 358 | parser.add_argument('--private-launchpad', action='store_true', |
163 | 353 | help='''Sets the environment to use proper Launchpad | 359 | help='''Sets the environment to use proper Launchpad |
164 | 354 | instance.''', default=False) | 360 | instance.''', default=False) |
165 | 361 | parser.add_argument('--mthood-deployment', action='store_true', | ||
166 | 362 | help='''Sets the environment to use mthood specific | ||
167 | 363 | variables.''', default=False) | ||
168 | 355 | return parser.parse_args(args) | 364 | return parser.parse_args(args) |
169 | 356 | 365 | ||
170 | 357 | 366 | ||
171 | 358 | def main(): | 367 | def main(): |
172 | 359 | args = _get_args() | 368 | args = _get_args() |
173 | 360 | 369 | ||
175 | 361 | check_environment() | 370 | check_environment(args) |
176 | 362 | 371 | ||
177 | 363 | # You can configure the system to use private PPAs only or by providing | 372 | # You can configure the system to use private PPAs only or by providing |
178 | 364 | # the option --private-ppas-only or by setting the environment variable | 373 | # the option --private-ppas-only or by setting the environment variable |
179 | 365 | 374 | ||
180 | === modified file 'juju-deployer/ppa-assigner.yaml.tmpl' | |||
181 | --- juju-deployer/ppa-assigner.yaml.tmpl 2014-03-10 22:25:00 +0000 | |||
182 | +++ juju-deployer/ppa-assigner.yaml.tmpl 2014-06-06 10:05:35 +0000 | |||
183 | @@ -9,6 +9,8 @@ | |||
184 | 9 | repos_url: ${CI_BRANCH} | 9 | repos_url: ${CI_BRANCH} |
185 | 10 | additional_distro_packages: python-oauth, python-launchpadlib, python-yaml, python-tastypie, python-django-south | 10 | additional_distro_packages: python-oauth, python-launchpadlib, python-yaml, python-tastypie, python-django-south |
186 | 11 | django_version: ${CI_PPA} | 11 | django_version: ${CI_PPA} |
187 | 12 | proxy-url: ${CI_PRIVATE_HTTP_PROXY} | ||
188 | 13 | ppa-gpg-key: ${CI_PPA_GPG_KEY} | ||
189 | 12 | application_path: ppa-assigner/ | 14 | application_path: ppa-assigner/ |
190 | 13 | django_settings: ppa_assigner.settings | 15 | django_settings: ppa_assigner.settings |
191 | 14 | django_south: True | 16 | django_south: True |
192 | 15 | 17 | ||
193 | === modified file 'juju-deployer/ticket-system.yaml.tmpl' | |||
194 | --- juju-deployer/ticket-system.yaml.tmpl 2014-02-25 14:14:43 +0000 | |||
195 | +++ juju-deployer/ticket-system.yaml.tmpl 2014-06-06 10:05:35 +0000 | |||
196 | @@ -18,6 +18,8 @@ | |||
197 | 18 | repos_url: ${CI_BRANCH} | 18 | repos_url: ${CI_BRANCH} |
198 | 19 | additional_distro_packages: python-lazr.enum, python-yaml, python-tastypie, python-django-south | 19 | additional_distro_packages: python-lazr.enum, python-yaml, python-tastypie, python-django-south |
199 | 20 | django_version: ${CI_PPA} | 20 | django_version: ${CI_PPA} |
200 | 21 | proxy-url: ${CI_PRIVATE_HTTP_PROXY} | ||
201 | 22 | ppa-gpg-key: ${CI_PPA_GPG_KEY} | ||
202 | 21 | unit-config: include-base64://configs/unit_config.yaml | 23 | unit-config: include-base64://configs/unit_config.yaml |
203 | 22 | application_path: ticket_system/ | 24 | application_path: ticket_system/ |
204 | 23 | django_settings: ticket_system.settings | 25 | django_settings: ticket_system.settings |
On 05/11/2014 07:07 AM, Parameswaran Sivatharman wrote:
> === modified file 'charms/ precise/ python- django/ hooks/hooks. py'
> @@ -347,7 +348,6 @@
> remote_host = run("relation-get private-address")
> return remote_host
>
> -
> def get_unit_host():
check out the deletion of that line. I suspect that might cause a pep8
warning. functions need 2 blank lines between them.
> @@ -365,6 +365,15 @@ file.write( str(template) ) ci_ppa_ keys():
> with open(destination, 'w') as inject_file:
> inject_
>
> +def import_
ditto on the 2 blank lines
> + cmd = "apt-key adv --keyserver keyserver. ubuntu. com " \ check_call( cmd.split( ' '))
> + "--recv-keys F7F9102D6A8DFC40"
> + try:
> + subprocess.
> + except:
> + juju_log(MSG_ERROR, "Error importing repo key ")
That's a bit awkward to write a string and split. how about do this:
def import_ ci_ppa_ keys(): ubuntu. com',
'- -recv-keys' , 'F7F9102D6A8DFC40']
subprocess. check_call( cmd)
juju_ log(MSG_ ERROR, "Error importing repo key ")
cmd = ['apt-key', 'adv', '--keyserver', 'keyserver.
try:
except:
Also - what is "F7F9102D6A8DFC40"? Seems like this should probably come
from config.yaml?
You also might name the function "import_ppa_keys" so this isn't totally
tied to ci-airlines (I know it is totally tied to ci-airlines, but lets
not make the problem worse).
> @@ -510,7 +534,8 @@
> else:
> run('git clone %s %s' % (repos_url, vcs_clone_dir))
> elif vcs == 'bzr' or vcs == 'bazaar' or vcs == 'branch':
> - run('bzr branch %s %s' % (repos_url, vcs_clone_dir))
> + run('http_proxy=%s https_proxy=%s bzr branch %s %s'
> + % (proxy_url, proxy_url, repos_url, vcs_clone_dir))
not sure - is this safe when no http_proxy was defined?