Merge lp:~doanac/ubuntu-ci-services-itself/restish-deb into lp:ubuntu-ci-services-itself

Proposed by Andy Doan
Status: Merged
Approved by: Chris Johnston
Approved revision: 319
Merged at revision: 318
Proposed branch: lp:~doanac/ubuntu-ci-services-itself/restish-deb
Merge into: lp:ubuntu-ci-services-itself
Diff against target: 349 lines (+251/-6)
10 files modified
charms/precise/restish/Makefile (+24/-0)
charms/precise/restish/charm-helpers.yaml (+4/-0)
charms/precise/restish/cm.py (+172/-0)
charms/precise/restish/config-manager.txt (+5/-0)
charms/precise/restish/config.yaml (+25/-0)
charms/precise/restish/hooks/hooks.py (+5/-6)
juju-deployer/branch-source-builder.yaml.tmpl (+4/-0)
juju-deployer/image-builder.yaml.tmpl (+4/-0)
juju-deployer/lander.yaml.tmpl (+4/-0)
juju-deployer/test-runner.yaml.tmpl (+4/-0)
To merge this branch: bzr merge lp:~doanac/ubuntu-ci-services-itself/restish-deb
Reviewer Review Type Date Requested Status
Chris Johnston (community) Approve
Evan (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+209558@code.launchpad.net

Commit message

restish charm: use restish .deb

ev's got this packaged now so we don't need pip for this

Description of the change

remove the pip dependency from the restish charm. I think this gets all our services using .deb's only

To post a comment you must log in.
319. By Andy Doan

oops - must have fat-fingered "dd"

should switch to emacs, it would have taken like 15 keystrokes to
have made this mistake

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:319
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/301/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/301/rebuild

review: Approve (continuous-integration)
Revision history for this message
Evan (ev) wrote :

Yay! +1

We really need to centralise our use of cm.py and charmhelpers down the road. We have what, three copies of it in the tree now? :)

review: Approve
Revision history for this message
Evan (ev) wrote :

PS. this made my afternoon: "should switch to emacs, it would have taken like 15 keystrokes to have made this mistake"

Revision history for this message
Chris Johnston (cjohnston) wrote :

 merge approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'charms/precise/restish/Makefile'
2--- charms/precise/restish/Makefile 1970-01-01 00:00:00 +0000
3+++ charms/precise/restish/Makefile 2014-03-05 23:39:46 +0000
4@@ -0,0 +1,24 @@
5+PWD := $(shell pwd)
6+SOURCEDEPS_DIR ?= $(shell dirname $(PWD))/.sourcecode
7+PYTHON := /usr/bin/env python
8+CONFIGMANAGER := $(PWD)/bin/cm.py
9+
10+
11+sourcedeps: $(PWD)/config-manager.txt clean
12+ @echo Updating source dependencies...
13+ @$(PYTHON) cm.py -c $(PWD)/config-manager.txt \
14+ -p $(SOURCEDEPS_DIR) \
15+ -t $(PWD)
16+ @$(PYTHON) build/charm-helpers/tools/charm_helpers_sync/charm_helpers_sync.py \
17+ -c charm-helpers.yaml \
18+ -b build/charm-helpers \
19+ -d hooks/charmhelpers
20+ @echo Do not forget to commit the updated files if any.
21+ #@cd $(PWD)/build/charm-helpers; \
22+ #@$(PYTHON) setup.py install --install-purelib=$(PWD)/lib \
23+ #--install-scripts=$(PWD)/lib/bin
24+
25+clean:
26+ rm -fr hooks/charmhelpers build/charm-helpers ../.sourcecode
27+
28+.PHONY: sourcedeps
29
30=== added directory 'charms/precise/restish/build'
31=== added file 'charms/precise/restish/charm-helpers.yaml'
32--- charms/precise/restish/charm-helpers.yaml 1970-01-01 00:00:00 +0000
33+++ charms/precise/restish/charm-helpers.yaml 2014-03-05 23:39:46 +0000
34@@ -0,0 +1,4 @@
35+include:
36+ - core
37+ - fetch
38+ - contrib.charmsupport
39
40=== added file 'charms/precise/restish/cm.py'
41--- charms/precise/restish/cm.py 1970-01-01 00:00:00 +0000
42+++ charms/precise/restish/cm.py 2014-03-05 23:39:46 +0000
43@@ -0,0 +1,172 @@
44+# Copyright 2014 Canonical Ltd. All rights reserved.
45+
46+import os
47+import re
48+import sys
49+import errno
50+import hashlib
51+import subprocess
52+import optparse
53+import urllib
54+
55+from os import curdir
56+from bzrlib.branch import Branch
57+from bzrlib.plugin import load_plugins
58+load_plugins()
59+from bzrlib.plugins.launchpad import account as lp_account
60+
61+if 'GlobalConfig' in dir(lp_account):
62+ from bzrlib.config import LocationConfig as LocationConfiguration
63+ _ = LocationConfiguration
64+else:
65+ from bzrlib.config import LocationStack as LocationConfiguration
66+ _ = LocationConfiguration
67+
68+
69+def get_ubunet_branch_config(config_file):
70+ """
71+ Retrieves the sourcedeps configuration for an ubunet source dir.
72+ Returns a dict of (branch, revspec) tuples, keyed by branch name.
73+ """
74+ branches = {}
75+ with open(config_file, 'r') as stream:
76+ for line in stream:
77+ line = line.split('#')[0].strip()
78+ match = re.match(r'(\S+)\s+'
79+ 'bzr\+ssh://([^/]+)/([^;]+)'
80+ '(?:;revno=(\d+))?', line)
81+ if match:
82+ name, host, branch, revno = match.group(1, 2, 3, 4)
83+ if revno is None:
84+ revspec = "-1"
85+ else:
86+ revspec = revno
87+ branches[name] = (host, branch, revspec)
88+ return branches
89+
90+
91+def main(config_file, parent_dir, target_dir, verbose):
92+ """Do the deed."""
93+
94+ try:
95+ os.makedirs(parent_dir)
96+ except OSError, e:
97+ if e.errno != errno.EEXIST:
98+ raise
99+
100+ bzr_config = LocationConfiguration(parent_dir)
101+ get_lp_login = lp_account.get_lp_login
102+ username = get_lp_login(bzr_config) or get_lp_login()
103+ if username is None:
104+ raise RuntimeError("Unable to determine launchpad login")
105+ quoted_username = urllib.quote(username)
106+
107+ branches = sorted(get_ubunet_branch_config(config_file).iteritems())
108+ for branch_name, (host, quoted_branch_spec, revspec) in branches:
109+ revno = int(revspec)
110+
111+ # qualify mirror branch name with hash of remote repo path to deal
112+ # with changes to the remote branch URL over time
113+ branch_spec_digest = hashlib.sha1(quoted_branch_spec).hexdigest()
114+ branch_directory = branch_spec_digest
115+
116+ source_path = os.path.join(parent_dir, branch_directory)
117+ destination_path = os.path.join(target_dir, branch_name)
118+
119+ # Remove leftover symlinks/stray files.
120+ try:
121+ os.remove(destination_path)
122+ except OSError, e:
123+ if e.errno != errno.EISDIR and e.errno != errno.ENOENT:
124+ raise
125+
126+ branch_url = ("bzr+ssh://%s@%s/%s" %
127+ (quoted_username, host, quoted_branch_spec))
128+ lp_url = "lp:" + quoted_branch_spec.replace("+branch/", "")
129+
130+ # Create the local mirror branch if it doesn't already exist
131+ if verbose:
132+ sys.stderr.write('%30s: ' % (branch_name,))
133+ sys.stderr.flush()
134+
135+ fresh = False
136+ if not os.path.exists(source_path):
137+ subprocess.check_call(['bzr', 'branch', '-q',
138+ '--', branch_url, source_path])
139+ fresh = True
140+
141+ source_branch = Branch.open(source_path)
142+
143+ # Freshen the source branch if required (-1 means we want tip).
144+ if not fresh and (revno == -1 or revno > source_branch.revno()):
145+ subprocess.check_call(['bzr', 'pull', '-q', '--overwrite', '-r',
146+ str(revno), '-d', source_path,
147+ '--', branch_url])
148+
149+ if os.path.exists(destination_path):
150+ # Overwrite the destination with the appropriate revision.
151+ subprocess.check_call(['bzr', 'clean-tree', '--force', '-q',
152+ '--ignored', '-d', destination_path])
153+ subprocess.check_call(['bzr', 'pull', '-q', '--overwrite',
154+ '-r', str(revno),
155+ '-d', destination_path, '--', source_path])
156+ else:
157+ # Create a new branch.
158+ subprocess.check_call(['bzr', 'branch', '-q', '--hardlink',
159+ '-r', str(revno),
160+ '--', source_path, destination_path])
161+
162+ # Check the state of the destination branch.
163+ destination_branch = Branch.open(destination_path)
164+ destination_revno = destination_branch.revno()
165+
166+ if verbose:
167+ sys.stderr.write('checked out %4s of %s\n' %
168+ ("r" + str(destination_revno), lp_url))
169+ sys.stderr.flush()
170+
171+ if revno != -1 and destination_revno != revno:
172+ raise RuntimeError("Expected revno %d but got revno %d" %
173+ (revno, destination_revno))
174+
175+if __name__ == '__main__':
176+ parser = optparse.OptionParser(
177+ usage="%prog [options]",
178+ description=(
179+ "Add a lightweight checkout in <target> for each "
180+ "corresponding file in <parent>."),
181+ add_help_option=False)
182+ parser.add_option(
183+ '-p', '--parent', dest='parent', default=None,
184+ help=("The directory of the parent tree."),
185+ metavar="DIR")
186+ parser.add_option(
187+ '-t', '--target', dest='target', default=curdir,
188+ help=("The directory of the target tree."),
189+ metavar="DIR")
190+ parser.add_option(
191+ '-c', '--config', dest='config', default=None,
192+ help=("The config file to be used for config-manager."),
193+ metavar="DIR")
194+ parser.add_option(
195+ '-q', '--quiet', dest='verbose', action='store_false',
196+ help="Be less verbose.")
197+ parser.add_option(
198+ '-h', '--help', action='help',
199+ help="Show this help message and exit.")
200+ parser.set_defaults(verbose=True)
201+
202+ options, args = parser.parse_args()
203+
204+ if options.parent is None:
205+ parser.error(
206+ "Parent directory not specified.")
207+
208+ if options.target is None:
209+ parser.error(
210+ "Target directory not specified.")
211+
212+ sys.exit(main(config_file=options.config,
213+ parent_dir=options.parent,
214+ target_dir=options.target,
215+ verbose=options.verbose))
216
217=== added file 'charms/precise/restish/config-manager.txt'
218--- charms/precise/restish/config-manager.txt 1970-01-01 00:00:00 +0000
219+++ charms/precise/restish/config-manager.txt 2014-03-05 23:39:46 +0000
220@@ -0,0 +1,5 @@
221+# After making changes to this file, to ensure that the charm payload
222+# is up-to-date do:
223+#
224+# make
225+build/charm-helpers bzr+ssh://bazaar.launchpad.net/~charm-helpers/charm-helpers/devel;revno=99
226
227=== modified file 'charms/precise/restish/config.yaml'
228--- charms/precise/restish/config.yaml 2014-02-28 21:55:28 +0000
229+++ charms/precise/restish/config.yaml 2014-03-05 23:39:46 +0000
230@@ -47,3 +47,28 @@
231 type: int
232 default: 8080
233 description: "Port the application will be listening."
234+
235+ # Apt info used by charmhelpers
236+ install_sources:
237+ type: string
238+ default: ""
239+ description: |
240+ YAML list of additional installation sources, as a string. The number
241+ of install_sources must match the number of install_keys. For
242+ example:
243+ install_sources: |
244+ - ppa:project1/ppa
245+ - ppa:project2/ppa
246+ install_keys:
247+ type: string
248+ default: ""
249+ description: |
250+ YAML list of GPG keys for installation sources, as a string. For apt
251+ repository URLs, use the public key ID used to verify package
252+ signatures. For other sources such as PPA, use empty string. This
253+ list must have the same number of elements as install_sources, even
254+ if the key items are all empty string. An example to go with the
255+ above for install_sources:
256+ install_keys: |
257+ - ""
258+ - ""
259
260=== modified file 'charms/precise/restish/hooks/hooks.py'
261--- charms/precise/restish/hooks/hooks.py 2014-02-28 21:55:28 +0000
262+++ charms/precise/restish/hooks/hooks.py 2014-03-05 23:39:46 +0000
263@@ -7,6 +7,8 @@
264 import sys
265 import time
266
267+import charmhelpers.fetch
268+
269
270 def juju_info(msg):
271 subprocess.check_call(['juju-log', '-l', 'INFO', msg])
272@@ -83,14 +85,11 @@
273 def install(config):
274 pkgs = [x for x in config['packages'].split(' ') if x]
275 pkgs.append('bzr')
276- pkgs.append('python-pip') # required for restish?
277+ pkgs.append('python-restish')
278
279 juju_info('installing apt packages...')
280- subprocess.check_call(['apt-get', 'install', '-y', '-q'] + pkgs)
281-
282- juju_info('installing restish...')
283- restish = 'restish==%s' % config['restish_version']
284- subprocess.check_call(['pip', 'install', restish])
285+ charmhelpers.fetch.configure_sources(update=True)
286+ charmhelpers.fetch.apt_install(pkgs)
287
288 if config.get('vcs') == 'tarball':
289 _install_from_tarball(config)
290
291=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
292--- juju-deployer/branch-source-builder.yaml.tmpl 2014-03-05 11:41:47 +0000
293+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-03-05 23:39:46 +0000
294@@ -11,6 +11,10 @@
295 # need non-default package python-amqplib for this service
296 packages: "python-webtest python-mock python-jinja2 python-amqplib"
297 json_status_path: api/v1/status
298+ install_sources: |
299+ - ${CI_PPA}
300+ install_keys: |
301+ - ""
302 bsb-gunicorn:
303 charm: gunicorn
304 branch: lp:charms/precise/gunicorn@28
305
306=== modified file 'juju-deployer/image-builder.yaml.tmpl'
307--- juju-deployer/image-builder.yaml.tmpl 2014-03-05 11:20:09 +0000
308+++ juju-deployer/image-builder.yaml.tmpl 2014-03-05 23:39:46 +0000
309@@ -10,6 +10,10 @@
310 python_path: ./image-builder:./ci-utils
311 packages: "python-webtest python-mock python-jinja2 python-amqplib"
312 json_status_path: api/v1/status
313+ install_sources: |
314+ - ${CI_PPA}
315+ install_keys: |
316+ - ""
317 imagebuild-gunicorn:
318 charm: gunicorn
319 branch: lp:charms/precise/gunicorn@28
320
321=== modified file 'juju-deployer/lander.yaml.tmpl'
322--- juju-deployer/lander.yaml.tmpl 2014-03-05 11:20:09 +0000
323+++ juju-deployer/lander.yaml.tmpl 2014-03-05 23:39:46 +0000
324@@ -10,6 +10,10 @@
325 python_path: "./lander:./ci-utils"
326 # need non-default package python-amqplib for this service
327 packages: "python-webtest python-mock python-jinja2 python-jenkins"
328+ install_sources: |
329+ - ${CI_PPA}
330+ install_keys: |
331+ - ""
332 lander-gunicorn:
333 charm: gunicorn
334 branch: lp:charms/precise/gunicorn@28
335
336=== modified file 'juju-deployer/test-runner.yaml.tmpl'
337--- juju-deployer/test-runner.yaml.tmpl 2014-03-05 11:20:09 +0000
338+++ juju-deployer/test-runner.yaml.tmpl 2014-03-05 23:39:46 +0000
339@@ -23,6 +23,10 @@
340 # instance. Arguably a bug in the gunicorn charm.
341
342 packages: "python-webtest python-jinja2 python-amqplib"
343+ install_sources: |
344+ - ${CI_PPA}
345+ install_keys: |
346+ - ""
347 tr-rabbit-worker:
348 charm: rabbitmq-worker
349 options:

Subscribers

People subscribed via source and target branches