Merge lp:~cjwatson/charms/trusty/turnip/api-server into lp:~canonical-launchpad-branches/charms/trusty/turnip/devel

Proposed by Colin Watson on 2015-02-27
Status: Merged
Approved by: Colin Watson on 2015-03-02
Approved revision: 30
Merged at revision: 30
Proposed branch: lp:~cjwatson/charms/trusty/turnip/api-server
Merge into: lp:~canonical-launchpad-branches/charms/trusty/turnip/devel
Diff against target: 102 lines (+41/-4)
5 files modified
Makefile (+1/-1)
config.yaml (+15/-1)
hooks/actions.py (+4/-2)
hooks/services.py (+5/-0)
templates/turnip-api.conf.j2 (+16/-0)
To merge this branch: bzr merge lp:~cjwatson/charms/trusty/turnip/api-server
Reviewer Review Type Date Requested Status
Kit Randel code 2015-02-27 Approve on 2015-03-01
Review via email: mp+251305@code.launchpad.net

Commit Message

Start the turnip API server. This requires installing python-pygit2 from the Launchpad PPA.

Description of the Change

Start the turnip API server, now that it's been split out from turnipserver.

This requires installing python-pygit2 from the Launchpad PPA, and will also only work once https://code.launchpad.net/~cjwatson/turnip/pastescript/+merge/251303 has been merged. We need to install turnip itself as an egg (develop mode will do) so that pyramid can find it. Furthermore, I could only make this work by switching to "virtualenv --system-site-packages", along with disabling wheel support when building the pip cache because pkg_resources called from within pyramid is apparently unable to understand wheels and requires eggs. I don't think that the loss of isolation is important within a charm, since we're running within a contained environment anyway.

Once we go to production, I expect we'll want to use an IS-managed PPA rather than the Launchpad PPA, but this works for now.

To post a comment you must log in.
Kit Randel (blr) wrote :

Thank you Colin - beat me to it!

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-02-27 15:28:32 +0000
3+++ Makefile 2015-02-27 18:18:37 +0000
4@@ -45,7 +45,7 @@
5 @echo "Updating python dependency cache..."
6 @sudo apt-get install -qq -y python-pip
7 @mkdir -p $(PIP_CACHE)
8- @pip install --download $(PIP_CACHE) -r $(SOURCE_DIR)/requirements.txt
9+ @pip install --no-use-wheel --download $(PIP_CACHE) -r $(SOURCE_DIR)/requirements.txt
10
11
12 check-rev:
13
14=== modified file 'config.yaml'
15--- config.yaml 2015-02-18 20:51:24 +0000
16+++ config.yaml 2015-02-27 18:18:37 +0000
17@@ -72,4 +72,18 @@
18 authentication_endpoint:
19 type: string
20 default: http://xmlrpc-private.launchpad.dev:8087/authserver
21- description: XMLRPC auth
22\ No newline at end of file
23+ description: XMLRPC auth
24+
25+ # apt configuration used by charmhelpers.
26+ install_sources:
27+ type: string
28+ default: |
29+ - ppa:launchpad/ppa
30+ description: |
31+ YAML list of additional installation sources.
32+ install_keys:
33+ type: string
34+ default: |
35+ - null # PPA keys securely added via Launchpad.
36+ description: |
37+ YAML list of GPG keys for installation sources.
38
39=== modified file 'hooks/actions.py'
40--- hooks/actions.py 2015-02-16 00:30:29 +0000
41+++ hooks/actions.py 2015-02-27 18:18:37 +0000
42@@ -12,7 +12,7 @@
43
44 # Globals
45 CHARM_FILES_DIR = os.path.join(hookenv.charm_dir(), 'files')
46-REQUIRED_PACKAGES = ['python-virtualenv', 'python-dev']
47+REQUIRED_PACKAGES = ['python-virtualenv', 'python-dev', 'python-pygit2']
48 APP = config['app_name']
49 SRV_DIR = config['srv_dir']
50 USER = config['user']
51@@ -71,7 +71,7 @@
52 pip_cache = os.path.join(CHARM_FILES_DIR, 'pip-cache')
53 requirements = os.path.join(SRV_DIR, 'requirements.txt')
54
55- subprocess.call(['virtualenv', env_dir])
56+ subprocess.call(['virtualenv', '--system-site-packages', env_dir])
57 for dirpath, dirname, files in os.walk(pip_cache):
58 if files:
59 hookenv.log('Installing from download cache.')
60@@ -83,3 +83,5 @@
61 else:
62 subprocess.call(['%s/bin/pip' % env_dir,
63 'install', '-r', requirements])
64+ subprocess.call(['%s/bin/pip' % env_dir,
65+ 'install', '--no-deps', '-e', SRV_DIR])
66
67=== modified file 'hooks/services.py'
68--- hooks/services.py 2015-02-18 20:51:24 +0000
69+++ hooks/services.py 2015-02-27 18:18:37 +0000
70@@ -25,6 +25,11 @@
71 owner=config['user'],
72 perms=0o644),
73 helpers.render_template(
74+ source='turnip-api.conf.j2',
75+ target='/etc/init/turnip-api.conf',
76+ owner=config['user'],
77+ perms=0o644),
78+ helpers.render_template(
79 source='turnip-app.j2',
80 target='/srv/deploymgr/turnip-app',
81 owner=config['user'],
82
83=== added file 'templates/turnip-api.conf.j2'
84--- templates/turnip-api.conf.j2 1970-01-01 00:00:00 +0000
85+++ templates/turnip-api.conf.j2 2015-02-27 18:18:37 +0000
86@@ -0,0 +1,16 @@
87+description "Turnip git API server"
88+author "Canonical Launchpad Team"
89+
90+setuid {{ user }}
91+setgid {{ group }}
92+
93+env PYTHON_HOME=/srv/{{ app_name }}/env
94+env PATH=$PYTHON_HOME/bin:$PATH
95+
96+start on started turnip
97+stop on stopping turnip
98+
99+chdir /srv/{{ app_name }}
100+exec $PYTHON_HOME/bin/envdir {{ env_dir }} $PYTHON_HOME/bin/pserve api.ini
101+
102+respawn

Subscribers

People subscribed via source and target branches

to all changes: