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

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

Commit message

Add relationship hooks for handling the jenkaas-slave relationship.

Description of the change

Add relationship hooks for handling the jenkaas-slave relationship.

This doesn't do anything useful yet, but does force the master-address to be available before any of the data_ready actions are executed.

To post a comment you must log in.
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-12 22:40:31 +0000
3+++ hooks/actions.py 2015-06-17 13:52:32 +0000
4@@ -32,7 +32,7 @@
5
6 def install_service_dependencies(service_name):
7 hookenv.log('Installing service dependencies')
8- fetch.configure_sources(update=True)
9+ fetch.apt_update(fatal=True)
10 fetch.apt_install(REQUIRED_PACKAGES, fatal=True)
11
12
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-12 22:40:31 +0000
20+++ hooks/services.py 2015-06-17 13:52:32 +0000
21@@ -1,15 +1,41 @@
22 from charmhelpers.core import hookenv
23 from charmhelpers.core.services.base import ServiceManager
24+from charmhelpers.core.services.helpers import RelationContext
25
26 import actions
27
28
29+class SlaveToMasterProvider(RelationContext):
30+ """Provide data on the jenkaas-slave relationship."""
31+ name = 'jenkaas-slave'
32+ interface = 'jenkaas-slave'
33+
34+ def provide_data(self):
35+ return {
36+ 'slave-address': hookenv.unit_get('private-address'),
37+ }
38+
39+
40+class SlaveToMasterConsumer(RelationContext):
41+ """Requirements for the jenkaas-slave relationship."""
42+ name = 'jenkaas-slave'
43+ interface = 'jenkaas-slave'
44+ required_keys = [
45+ 'master-address',
46+ 'port',
47+ ]
48+
49+
50 def manage():
51 config = hookenv.config()
52 manager = ServiceManager([
53 {
54 'service': 'jenkins-slave',
55- 'required_data': [config],
56+ 'required_data': [
57+ config,
58+ SlaveToMasterConsumer(),
59+ ],
60+ 'provided_data': [SlaveToMasterProvider()],
61 'data_ready': [
62 actions.basenode,
63 actions.install_service_dependencies,
64
65=== modified file 'metadata.yaml'
66--- metadata.yaml 2015-06-12 22:37:23 +0000
67+++ metadata.yaml 2015-06-17 13:52:32 +0000
68@@ -6,3 +6,6 @@
69 description: |
70 Installs the jenkins slave package and connects a jenkins master using
71 juju relations.
72+requires:
73+ jenkaas-slave:
74+ interface: jenkaas-slave

Subscribers

People subscribed via source and target branches