Merge lp:~pwlars/charms/trusty/snappy-device-agent/separate-service-dirs into lp:~canonical-hw-cert/charms/trusty/snappy-device-agent/trunk

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: 7
Merged at revision: 7
Proposed branch: lp:~pwlars/charms/trusty/snappy-device-agent/separate-service-dirs
Merge into: lp:~canonical-hw-cert/charms/trusty/snappy-device-agent/trunk
Diff against target: 69 lines (+12/-6)
3 files modified
hooks/actions.py (+7/-3)
hooks/services.py (+4/-2)
templates/upstart.conf (+1/-1)
To merge this branch: bzr merge lp:~pwlars/charms/trusty/snappy-device-agent/separate-service-dirs
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+274782@code.launchpad.net

Description of the change

This will be needed later down the road for hosting things like adb agents that may need to be combined onto a single host system.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Using this right now with snappy x86 generic, and seems to work well.

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-10-05 15:10:06 +0000
3+++ hooks/actions.py 2015-10-16 20:46:22 +0000
4@@ -7,7 +7,7 @@
5 from charmhelpers.core import hookenv
6 from charmhelpers.payload import (archive, execd)
7
8-SERVICE_NAME = 'snappy-device-agents'
9+SERVICE_NAME = hookenv.service_name()
10 AGENT_CONFIGFILE = 'spi-agent.conf'
11 DEVICE_CONFIGFILE = 'default.yaml'
12 REQUIRED_PACKAGES = [
13@@ -28,11 +28,15 @@
14
15
16 def _service_dir():
17- template = '/srv/{}/{}'
18- return template.format(config['environment'], SERVICE_NAME)
19+ # This is dir where the provisioning kit will live after extraction
20+ # The tarball needs to extract to snappy-device-agents and we
21+ # extract it from one level up
22+ template = '/srv/snappy-device-agents/{}/snappy-device-agents'
23+ return template.format(SERVICE_NAME)
24
25
26 def _agent_dir():
27+ # This is the dir where the SPI Agent will live after extraction
28 template = '{}/spi-agent'
29 return template.format(_service_dir())
30
31
32=== modified file 'hooks/services.py'
33--- hooks/services.py 2015-08-14 20:10:33 +0000
34+++ hooks/services.py 2015-10-16 20:46:22 +0000
35@@ -9,9 +9,11 @@
36
37 def manage():
38 config = hookenv.config()
39+ service_name = hookenv.service_name()
40+ config['service_name'] = service_name
41 manager = ServiceManager([
42 {
43- 'service': 'snappy-proposed-selftest-agent',
44+ 'service': 'snappy-device-agent-{}'.format(service_name),
45 'required_data': [config],
46 'data_ready': [
47 actions.basenode,
48@@ -20,7 +22,7 @@
49 actions.install_python_packages,
50 helpers.render_template(
51 source='upstart.conf',
52- target='/etc/init/snappy-proposed-selftest-agent.conf'),
53+ target='/etc/init/snappy-device-agent-{}.conf'.format(service_name)),
54 actions.log_start,
55 ],
56 },
57
58=== modified file 'templates/upstart.conf'
59--- templates/upstart.conf 2015-08-14 20:10:33 +0000
60+++ templates/upstart.conf 2015-10-16 20:46:22 +0000
61@@ -11,7 +11,7 @@
62 # unless it fails 15 times within 5 seconds
63 respawn limit 15 5
64
65-env SERVICE_DIR=/srv/{{ environment }}/snappy-device-agents
66+env SERVICE_DIR=/srv/snappy-device-agents/{{ service_name }}/snappy-device-agents
67 env SERVICE_USER=ubuntu
68
69 script

Subscribers

People subscribed via source and target branches