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
=== added file 'charms/precise/restish/Makefile'
--- charms/precise/restish/Makefile 1970-01-01 00:00:00 +0000
+++ charms/precise/restish/Makefile 2014-03-05 23:39:46 +0000
@@ -0,0 +1,24 @@
1PWD := $(shell pwd)
2SOURCEDEPS_DIR ?= $(shell dirname $(PWD))/.sourcecode
3PYTHON := /usr/bin/env python
4CONFIGMANAGER := $(PWD)/bin/cm.py
5
6
7sourcedeps: $(PWD)/config-manager.txt clean
8 @echo Updating source dependencies...
9 @$(PYTHON) cm.py -c $(PWD)/config-manager.txt \
10 -p $(SOURCEDEPS_DIR) \
11 -t $(PWD)
12 @$(PYTHON) build/charm-helpers/tools/charm_helpers_sync/charm_helpers_sync.py \
13 -c charm-helpers.yaml \
14 -b build/charm-helpers \
15 -d hooks/charmhelpers
16 @echo Do not forget to commit the updated files if any.
17 #@cd $(PWD)/build/charm-helpers; \
18 #@$(PYTHON) setup.py install --install-purelib=$(PWD)/lib \
19 #--install-scripts=$(PWD)/lib/bin
20
21clean:
22 rm -fr hooks/charmhelpers build/charm-helpers ../.sourcecode
23
24.PHONY: sourcedeps
025
=== added directory 'charms/precise/restish/build'
=== added file 'charms/precise/restish/charm-helpers.yaml'
--- charms/precise/restish/charm-helpers.yaml 1970-01-01 00:00:00 +0000
+++ charms/precise/restish/charm-helpers.yaml 2014-03-05 23:39:46 +0000
@@ -0,0 +1,4 @@
1include:
2 - core
3 - fetch
4 - contrib.charmsupport
05
=== added file 'charms/precise/restish/cm.py'
--- charms/precise/restish/cm.py 1970-01-01 00:00:00 +0000
+++ charms/precise/restish/cm.py 2014-03-05 23:39:46 +0000
@@ -0,0 +1,172 @@
1# Copyright 2014 Canonical Ltd. All rights reserved.
2
3import os
4import re
5import sys
6import errno
7import hashlib
8import subprocess
9import optparse
10import urllib
11
12from os import curdir
13from bzrlib.branch import Branch
14from bzrlib.plugin import load_plugins
15load_plugins()
16from bzrlib.plugins.launchpad import account as lp_account
17
18if 'GlobalConfig' in dir(lp_account):
19 from bzrlib.config import LocationConfig as LocationConfiguration
20 _ = LocationConfiguration
21else:
22 from bzrlib.config import LocationStack as LocationConfiguration
23 _ = LocationConfiguration
24
25
26def get_ubunet_branch_config(config_file):
27 """
28 Retrieves the sourcedeps configuration for an ubunet source dir.
29 Returns a dict of (branch, revspec) tuples, keyed by branch name.
30 """
31 branches = {}
32 with open(config_file, 'r') as stream:
33 for line in stream:
34 line = line.split('#')[0].strip()
35 match = re.match(r'(\S+)\s+'
36 'bzr\+ssh://([^/]+)/([^;]+)'
37 '(?:;revno=(\d+))?', line)
38 if match:
39 name, host, branch, revno = match.group(1, 2, 3, 4)
40 if revno is None:
41 revspec = "-1"
42 else:
43 revspec = revno
44 branches[name] = (host, branch, revspec)
45 return branches
46
47
48def main(config_file, parent_dir, target_dir, verbose):
49 """Do the deed."""
50
51 try:
52 os.makedirs(parent_dir)
53 except OSError, e:
54 if e.errno != errno.EEXIST:
55 raise
56
57 bzr_config = LocationConfiguration(parent_dir)
58 get_lp_login = lp_account.get_lp_login
59 username = get_lp_login(bzr_config) or get_lp_login()
60 if username is None:
61 raise RuntimeError("Unable to determine launchpad login")
62 quoted_username = urllib.quote(username)
63
64 branches = sorted(get_ubunet_branch_config(config_file).iteritems())
65 for branch_name, (host, quoted_branch_spec, revspec) in branches:
66 revno = int(revspec)
67
68 # qualify mirror branch name with hash of remote repo path to deal
69 # with changes to the remote branch URL over time
70 branch_spec_digest = hashlib.sha1(quoted_branch_spec).hexdigest()
71 branch_directory = branch_spec_digest
72
73 source_path = os.path.join(parent_dir, branch_directory)
74 destination_path = os.path.join(target_dir, branch_name)
75
76 # Remove leftover symlinks/stray files.
77 try:
78 os.remove(destination_path)
79 except OSError, e:
80 if e.errno != errno.EISDIR and e.errno != errno.ENOENT:
81 raise
82
83 branch_url = ("bzr+ssh://%s@%s/%s" %
84 (quoted_username, host, quoted_branch_spec))
85 lp_url = "lp:" + quoted_branch_spec.replace("+branch/", "")
86
87 # Create the local mirror branch if it doesn't already exist
88 if verbose:
89 sys.stderr.write('%30s: ' % (branch_name,))
90 sys.stderr.flush()
91
92 fresh = False
93 if not os.path.exists(source_path):
94 subprocess.check_call(['bzr', 'branch', '-q',
95 '--', branch_url, source_path])
96 fresh = True
97
98 source_branch = Branch.open(source_path)
99
100 # Freshen the source branch if required (-1 means we want tip).
101 if not fresh and (revno == -1 or revno > source_branch.revno()):
102 subprocess.check_call(['bzr', 'pull', '-q', '--overwrite', '-r',
103 str(revno), '-d', source_path,
104 '--', branch_url])
105
106 if os.path.exists(destination_path):
107 # Overwrite the destination with the appropriate revision.
108 subprocess.check_call(['bzr', 'clean-tree', '--force', '-q',
109 '--ignored', '-d', destination_path])
110 subprocess.check_call(['bzr', 'pull', '-q', '--overwrite',
111 '-r', str(revno),
112 '-d', destination_path, '--', source_path])
113 else:
114 # Create a new branch.
115 subprocess.check_call(['bzr', 'branch', '-q', '--hardlink',
116 '-r', str(revno),
117 '--', source_path, destination_path])
118
119 # Check the state of the destination branch.
120 destination_branch = Branch.open(destination_path)
121 destination_revno = destination_branch.revno()
122
123 if verbose:
124 sys.stderr.write('checked out %4s of %s\n' %
125 ("r" + str(destination_revno), lp_url))
126 sys.stderr.flush()
127
128 if revno != -1 and destination_revno != revno:
129 raise RuntimeError("Expected revno %d but got revno %d" %
130 (revno, destination_revno))
131
132if __name__ == '__main__':
133 parser = optparse.OptionParser(
134 usage="%prog [options]",
135 description=(
136 "Add a lightweight checkout in <target> for each "
137 "corresponding file in <parent>."),
138 add_help_option=False)
139 parser.add_option(
140 '-p', '--parent', dest='parent', default=None,
141 help=("The directory of the parent tree."),
142 metavar="DIR")
143 parser.add_option(
144 '-t', '--target', dest='target', default=curdir,
145 help=("The directory of the target tree."),
146 metavar="DIR")
147 parser.add_option(
148 '-c', '--config', dest='config', default=None,
149 help=("The config file to be used for config-manager."),
150 metavar="DIR")
151 parser.add_option(
152 '-q', '--quiet', dest='verbose', action='store_false',
153 help="Be less verbose.")
154 parser.add_option(
155 '-h', '--help', action='help',
156 help="Show this help message and exit.")
157 parser.set_defaults(verbose=True)
158
159 options, args = parser.parse_args()
160
161 if options.parent is None:
162 parser.error(
163 "Parent directory not specified.")
164
165 if options.target is None:
166 parser.error(
167 "Target directory not specified.")
168
169 sys.exit(main(config_file=options.config,
170 parent_dir=options.parent,
171 target_dir=options.target,
172 verbose=options.verbose))
0173
=== added file 'charms/precise/restish/config-manager.txt'
--- charms/precise/restish/config-manager.txt 1970-01-01 00:00:00 +0000
+++ charms/precise/restish/config-manager.txt 2014-03-05 23:39:46 +0000
@@ -0,0 +1,5 @@
1# After making changes to this file, to ensure that the charm payload
2# is up-to-date do:
3#
4# make
5build/charm-helpers bzr+ssh://bazaar.launchpad.net/~charm-helpers/charm-helpers/devel;revno=99
06
=== modified file 'charms/precise/restish/config.yaml'
--- charms/precise/restish/config.yaml 2014-02-28 21:55:28 +0000
+++ charms/precise/restish/config.yaml 2014-03-05 23:39:46 +0000
@@ -47,3 +47,28 @@
47 type: int47 type: int
48 default: 808048 default: 8080
49 description: "Port the application will be listening."49 description: "Port the application will be listening."
50
51 # Apt info used by charmhelpers
52 install_sources:
53 type: string
54 default: ""
55 description: |
56 YAML list of additional installation sources, as a string. The number
57 of install_sources must match the number of install_keys. For
58 example:
59 install_sources: |
60 - ppa:project1/ppa
61 - ppa:project2/ppa
62 install_keys:
63 type: string
64 default: ""
65 description: |
66 YAML list of GPG keys for installation sources, as a string. For apt
67 repository URLs, use the public key ID used to verify package
68 signatures. For other sources such as PPA, use empty string. This
69 list must have the same number of elements as install_sources, even
70 if the key items are all empty string. An example to go with the
71 above for install_sources:
72 install_keys: |
73 - ""
74 - ""
5075
=== modified file 'charms/precise/restish/hooks/hooks.py'
--- charms/precise/restish/hooks/hooks.py 2014-02-28 21:55:28 +0000
+++ charms/precise/restish/hooks/hooks.py 2014-03-05 23:39:46 +0000
@@ -7,6 +7,8 @@
7import sys7import sys
8import time8import time
99
10import charmhelpers.fetch
11
1012
11def juju_info(msg):13def juju_info(msg):
12 subprocess.check_call(['juju-log', '-l', 'INFO', msg])14 subprocess.check_call(['juju-log', '-l', 'INFO', msg])
@@ -83,14 +85,11 @@
83def install(config):85def install(config):
84 pkgs = [x for x in config['packages'].split(' ') if x]86 pkgs = [x for x in config['packages'].split(' ') if x]
85 pkgs.append('bzr')87 pkgs.append('bzr')
86 pkgs.append('python-pip') # required for restish?88 pkgs.append('python-restish')
8789
88 juju_info('installing apt packages...')90 juju_info('installing apt packages...')
89 subprocess.check_call(['apt-get', 'install', '-y', '-q'] + pkgs)91 charmhelpers.fetch.configure_sources(update=True)
9092 charmhelpers.fetch.apt_install(pkgs)
91 juju_info('installing restish...')
92 restish = 'restish==%s' % config['restish_version']
93 subprocess.check_call(['pip', 'install', restish])
9493
95 if config.get('vcs') == 'tarball':94 if config.get('vcs') == 'tarball':
96 _install_from_tarball(config)95 _install_from_tarball(config)
9796
=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
--- juju-deployer/branch-source-builder.yaml.tmpl 2014-03-05 11:41:47 +0000
+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-03-05 23:39:46 +0000
@@ -11,6 +11,10 @@
11 # need non-default package python-amqplib for this service11 # need non-default package python-amqplib for this service
12 packages: "python-webtest python-mock python-jinja2 python-amqplib"12 packages: "python-webtest python-mock python-jinja2 python-amqplib"
13 json_status_path: api/v1/status13 json_status_path: api/v1/status
14 install_sources: |
15 - ${CI_PPA}
16 install_keys: |
17 - ""
14 bsb-gunicorn:18 bsb-gunicorn:
15 charm: gunicorn19 charm: gunicorn
16 branch: lp:charms/precise/gunicorn@2820 branch: lp:charms/precise/gunicorn@28
1721
=== modified file 'juju-deployer/image-builder.yaml.tmpl'
--- juju-deployer/image-builder.yaml.tmpl 2014-03-05 11:20:09 +0000
+++ juju-deployer/image-builder.yaml.tmpl 2014-03-05 23:39:46 +0000
@@ -10,6 +10,10 @@
10 python_path: ./image-builder:./ci-utils10 python_path: ./image-builder:./ci-utils
11 packages: "python-webtest python-mock python-jinja2 python-amqplib"11 packages: "python-webtest python-mock python-jinja2 python-amqplib"
12 json_status_path: api/v1/status12 json_status_path: api/v1/status
13 install_sources: |
14 - ${CI_PPA}
15 install_keys: |
16 - ""
13 imagebuild-gunicorn:17 imagebuild-gunicorn:
14 charm: gunicorn18 charm: gunicorn
15 branch: lp:charms/precise/gunicorn@2819 branch: lp:charms/precise/gunicorn@28
1620
=== modified file 'juju-deployer/lander.yaml.tmpl'
--- juju-deployer/lander.yaml.tmpl 2014-03-05 11:20:09 +0000
+++ juju-deployer/lander.yaml.tmpl 2014-03-05 23:39:46 +0000
@@ -10,6 +10,10 @@
10 python_path: "./lander:./ci-utils"10 python_path: "./lander:./ci-utils"
11 # need non-default package python-amqplib for this service11 # need non-default package python-amqplib for this service
12 packages: "python-webtest python-mock python-jinja2 python-jenkins"12 packages: "python-webtest python-mock python-jinja2 python-jenkins"
13 install_sources: |
14 - ${CI_PPA}
15 install_keys: |
16 - ""
13 lander-gunicorn:17 lander-gunicorn:
14 charm: gunicorn18 charm: gunicorn
15 branch: lp:charms/precise/gunicorn@2819 branch: lp:charms/precise/gunicorn@28
1620
=== modified file 'juju-deployer/test-runner.yaml.tmpl'
--- juju-deployer/test-runner.yaml.tmpl 2014-03-05 11:20:09 +0000
+++ juju-deployer/test-runner.yaml.tmpl 2014-03-05 23:39:46 +0000
@@ -23,6 +23,10 @@
23 # instance. Arguably a bug in the gunicorn charm.23 # instance. Arguably a bug in the gunicorn charm.
2424
25 packages: "python-webtest python-jinja2 python-amqplib"25 packages: "python-webtest python-jinja2 python-amqplib"
26 install_sources: |
27 - ${CI_PPA}
28 install_keys: |
29 - ""
26 tr-rabbit-worker:30 tr-rabbit-worker:
27 charm: rabbitmq-worker31 charm: rabbitmq-worker
28 options:32 options:

Subscribers

People subscribed via source and target branches