Merge lp:~fginther/charms/trusty/jenkaas/add-slave-relation into lp:~canonical-ci-engineering/charms/trusty/jenkaas/trunk

Proposed by Francis Ginther
Status: Merged
Approved by: Francis Ginther
Approved revision: 23
Merged at revision: 5
Proposed branch: lp:~fginther/charms/trusty/jenkaas/add-slave-relation
Merge into: lp:~canonical-ci-engineering/charms/trusty/jenkaas/trunk
Diff against target: 81 lines (+31/-3)
3 files modified
hooks/actions.py (+5/-0)
hooks/services.py (+23/-3)
metadata.yaml (+3/-0)
To merge this branch: bzr merge lp:~fginther/charms/trusty/jenkaas/add-slave-relation
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+262219@code.launchpad.net

Commit message

Add relationship hooks for handling the jenkaas-slave relationship.

Description of the change

Add relationship hooks and boilerplate for handling the jenkaas-slave relationship.

This doesn't do anything useful yet, just accepts the relationship from a jenkaas-slave. install_slaves() will report:

{'jenkaas-slave': {u'jenkaas-slave:0': {'jenkaas/0': {u'private-address': u'10.25.176.81', u'master-address': u'10.25.176.81', u'port': u'48484'}, u'jenkaas-slave/0': {u'private-address': u'10.25.176.82', u'slave-address': u'10.25.176.82'}}}}

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/actions.py'
2--- hooks/actions.py 2015-06-16 15:39:39 +0000
3+++ hooks/actions.py 2015-06-17 13:51:03 +0000
4@@ -54,3 +54,8 @@
5 hookenv.log('Installing dependency packages')
6 fetch.apt_update()
7 fetch.apt_install(DEPS_PKGES, options=['--fix-broken', ], fatal=True)
8+
9+
10+def install_slaves(service_name):
11+ hookenv.log('Installing slaves')
12+ hookenv.log(hookenv.relations())
13
14=== added symlink 'hooks/jenkaas-slave-relation-changed'
15=== target is u'hooks.py'
16=== added symlink 'hooks/jenkaas-slave-relation-joined'
17=== target is u'hooks.py'
18=== modified file 'hooks/services.py'
19--- hooks/services.py 2015-06-16 15:38:14 +0000
20+++ hooks/services.py 2015-06-17 13:51:03 +0000
21@@ -1,26 +1,46 @@
22 from charmhelpers.core import hookenv
23 from charmhelpers.core.services.base import ServiceManager
24-from charmhelpers.core.services import helpers
25+from charmhelpers.core.services.helpers import (
26+ RelationContext,
27+ render_template,
28+)
29
30 import actions
31
32
33+class MasterToSlaveProvider(RelationContext):
34+ """Provide data on the jenkaas-slave relationship."""
35+ name = 'jenkaas-slave'
36+ interface = 'jenkaas-slave'
37+
38+ def provide_data(self):
39+ return {
40+ 'master-address': hookenv.unit_get('private-address'),
41+ 'port': 48484,
42+ }
43+
44+
45 def manage():
46 config = hookenv.config()
47 manager = ServiceManager([
48 {
49 'service': 'jenkaas',
50- 'required_data': [config],
51+ 'required_data': [
52+ config,
53+ ],
54+ 'provided_data': [MasterToSlaveProvider()],
55 'data_ready': [
56 actions.basenode,
57 actions.install_jenkins_dep_pkges,
58 actions.install_jenkins,
59 actions.install_plugins,
60- helpers.render_template(
61+ render_template(
62 source='upstart.conf',
63 target='/etc/init/jenkaas.conf'),
64+ actions.install_slaves,
65 actions.log_start,
66 ],
67+ 'ports': [48484],
68 },
69 ])
70 manager.manage()
71
72=== modified file 'metadata.yaml'
73--- metadata.yaml 2015-06-15 18:17:25 +0000
74+++ metadata.yaml 2015-06-17 13:51:03 +0000
75@@ -4,3 +4,6 @@
76 maintainer:
77 description: |
78 Runs jenkins server from a given service tarball (provided as files/jenkaas.tgz).
79+provides:
80+ jenkaas-slave:
81+ interface: jenkaas-slave

Subscribers

People subscribed via source and target branches