Merge lp:~gnuoy/charms/precise/haproxy/allow-reverseproxy-charms-by-name into lp:charms/haproxy

Proposed by Liam Young
Status: Merged
Approved by: Juan L. Negron
Approved revision: 59
Merge reported by: Juan L. Negron
Merged at revision: not available
Proposed branch: lp:~gnuoy/charms/precise/haproxy/allow-reverseproxy-charms-by-name
Merge into: lp:charms/haproxy
Diff against target: 20 lines (+3/-0)
1 file modified
hooks/hooks.py (+3/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/precise/haproxy/allow-reverseproxy-charms-by-name
Reviewer Review Type Date Requested Status
Juan L. Negron (community) Approve
Review via email: mp+127191@code.launchpad.net

Description of the change

When a unit joins the haproxy reverseproxy relationship. Check whether there is an existing stanza which matches its name. If there is then add it to that stanza. This allow charms which don't specify a service name to be added to specific haproxy stanzas.

For example is haproxy has been setup already with a musicsearch and videosearch stanza then,

juju deploy solr-jetty musicsearch
juju deploy solr-jetty videosearch
juju add-relation haproxy musicsearch
juju add-relation haproxy videosearch

will now add each unit to the stanza with the corresponding name.

To post a comment you must log in.
Revision history for this message
Juan L. Negron (negronjl) wrote :

Reviewing this now.

-Juan

Revision history for this message
Juan L. Negron (negronjl) wrote :

Approved.

-Juan

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2012-09-17 15:31:30 +0000
3+++ hooks/hooks.py 2012-10-01 06:35:22 +0000
4@@ -344,6 +344,7 @@
5 subprocess.check_output(['relation-list', '--format=json',
6 '-r', relid])):
7 relation_info = relation_get(None, unit, relid)
8+ unit_name = unit.rpartition('/')[0]
9 if type(relation_info) != type({}):
10 sys.exit(0)
11 # Mandatory switches ( hostname, port )
12@@ -361,6 +362,8 @@
13 'juju-log', 'service %s does not exists. ' % \
14 relation_info['service_name']])
15 sys.exit(1)
16+ elif unit_name in services_dict:
17+ service_name = unit_name
18 else:
19 service_name = services_list[0]['service_name']
20 if os.path.exists("%s/%s.is.proxy" % \

Subscribers

People subscribed via source and target branches