Merge lp:~abentley/charms/precise/juju-reports/use-configured-port into lp:~juju-qa/charms/precise/juju-reports/trunk

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 30
Proposed branch: lp:~abentley/charms/precise/juju-reports/use-configured-port
Merge into: lp:~juju-qa/charms/precise/juju-reports/trunk
Diff against target: 50 lines (+20/-3)
2 files modified
hooks/common.py (+15/-1)
hooks/website-relation-changed (+5/-2)
To merge this branch: bzr merge lp:~abentley/charms/precise/juju-reports/use-configured-port
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+219733@code.launchpad.net

Commit message

Use the configured port for setting website relation data.

Description of the change

This branch changes the way the website relation is handled, so that the port uses the configured value. Since changes to the config (source or revno) can change the configured port, this is done in the same code as config-changed uses.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.py'
2--- hooks/common.py 2014-05-14 20:08:17 +0000
3+++ hooks/common.py 2014-05-15 16:51:20 +0000
4@@ -45,8 +45,12 @@
5 return config
6
7
8+def get_configured_port(ini):
9+ return ini_get(ini, 'server:main', 'port')
10+
11+
12 def set_port(ini, open_port=True):
13- port = ini_get(ini, 'server:main', 'port')
14+ port = get_configured_port(ini)
15 if port is None:
16 return
17 if open_port:
18@@ -177,6 +181,15 @@
19 return 'mongodb://%s/?replicaSet=%s' % (','.join(host_ports), replset)
20
21
22+def update_website(ini):
23+ relation_settings = {
24+ 'port': get_configured_port(ini),
25+ 'hostname': hookenv.unit_private_ip(),
26+ }
27+ for relation_id in hookenv.relation_ids('website'):
28+ hookenv.relation_set(relation_id, relation_settings)
29+
30+
31 def update_from_config():
32 ini = get_ini()
33 try:
34@@ -202,3 +215,4 @@
35 install_cronjob(config['cron-interval'], config['error-email'])
36 start()
37 set_port(ini, True)
38+ update_website(ini)
39
40=== modified file 'hooks/website-relation-changed'
41--- hooks/website-relation-changed 2013-12-19 15:58:12 +0000
42+++ hooks/website-relation-changed 2014-05-15 16:51:20 +0000
43@@ -1,2 +1,5 @@
44-#!/bin/bash
45-set -eux relation-set port=6543 hostname=`unit-get private-address`
46+#!/usr/bin/env python
47+from common import update_from_config
48+
49+if __name__ == '__main__':
50+ update_from_config()

Subscribers

People subscribed via source and target branches

to all changes: