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

Proposed by Francis Ginther
Status: Merged
Approved by: Francis Ginther
Approved revision: 6
Merged at revision: 4
Proposed branch: lp:~fginther/charms/trusty/jenkaas-slave/configure-slave
Merge into: lp:~canonical-ci-engineering/charms/trusty/jenkaas-slave/trunk
Diff against target: 52 lines (+25/-0)
2 files modified
hooks/actions.py (+24/-0)
hooks/services.py (+1/-0)
To merge this branch: bzr merge lp:~fginther/charms/trusty/jenkaas-slave/configure-slave
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+262375@code.launchpad.net

Commit message

Configure the upstart config files for the slave service to connect to the jenkaas master.

Description of the change

Configure the upstart config files for the slave service to connect to the jenkaas master.

The master charm still needs to be updated to configure the slave so that it can actually connect.

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

Looks good. I didn't know you could use the comma in a with block, neato!

review: Approve
Revision history for this message
Francis Ginther (fginther) wrote :

> Looks good. I didn't know you could use the comma in a with block, neato!

Yep, it saves having to do a nested indent with a second 'with'.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/actions.py'
--- hooks/actions.py 2015-06-16 19:02:24 +0000
+++ hooks/actions.py 2015-06-18 18:10:39 +0000
@@ -1,6 +1,8 @@
1import glob1import glob
2import os2import os
3import shutil
3import subprocess4import subprocess
5import tempfile
46
5from charmhelpers import fetch7from charmhelpers import fetch
6from charmhelpers.core import hookenv8from charmhelpers.core import hookenv
@@ -44,5 +46,27 @@
44 subprocess.check_call(['dpkg', '-i', package])46 subprocess.check_call(['dpkg', '-i', package])
4547
4648
49def configure_slave(service_name):
50 hookenv.log('Configuring the slave')
51 unit_name = hookenv.local_unit().replace('/', '-')
52 master_url = 'http://{}:8080/'.format(
53 hookenv.relation_get('master-address'))
54 hookenv.log('Configuring {} to connect to {}'.format(
55 unit_name, master_url))
56
57 config_path = '/etc/default/jenkins-slave'
58 _unused, temp_path = tempfile.mkstemp()
59 with open(config_path) as in_file, open(temp_path, 'w') as out_file:
60 for line in in_file:
61 if 'JENKINS_HOSTNAME=' in line:
62 line = 'JENKINS_HOSTNAME={}\n'.format(unit_name)
63 if 'JENKINS_URL=' in line:
64 line = 'JENKINS_URL={}\n'.format(master_url)
65 out_file.write(line)
66 shutil.move(temp_path, config_path)
67 # Set the file permissions to their original value
68 os.chmod(config_path, 0o644)
69
70
47def log_start(service_name):71def log_start(service_name):
48 hookenv.log('Starting service {}'.format(SERVICE_NAME))72 hookenv.log('Starting service {}'.format(SERVICE_NAME))
4973
=== modified file 'hooks/services.py'
--- hooks/services.py 2015-06-17 13:34:28 +0000
+++ hooks/services.py 2015-06-18 18:10:39 +0000
@@ -40,6 +40,7 @@
40 actions.basenode,40 actions.basenode,
41 actions.install_service_dependencies,41 actions.install_service_dependencies,
42 actions.install_service_packages,42 actions.install_service_packages,
43 actions.configure_slave,
43 actions.log_start,44 actions.log_start,
44 ],45 ],
45 },46 },

Subscribers

People subscribed via source and target branches