Merge lp:~hloeung/charm-helpers/principal-unit-charm into lp:charm-helpers

Proposed by Haw Loeung
Status: Rejected
Rejected by: Haw Loeung
Proposed branch: lp:~hloeung/charm-helpers/principal-unit-charm
Merge into: lp:charm-helpers
Diff against target: 19 lines (+9/-0)
1 file modified
charmhelpers/core/hookenv.py (+9/-0)
To merge this branch: bzr merge lp:~hloeung/charm-helpers/principal-unit-charm
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+330473@code.launchpad.net

Description of the change

Add ability to return the name of the charm of the principal unit. For example from an nrpe subordinate related to the nagios charm, it would return 'nagios' (see https://code.launchpad.net/~hloeung/nrpe-charm/+git/nrpe-charm/+merge/330474).

To post a comment you must log in.

Unmerged revisions

790. By Haw Loeung

Fixed principal vs. unit.

789. By Haw Loeung

Add ability to return the name of the charm of the principal unit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/hookenv.py'
2--- charmhelpers/core/hookenv.py 2017-08-28 08:18:34 +0000
3+++ charmhelpers/core/hookenv.py 2017-09-09 11:45:03 +0000
4@@ -226,6 +226,15 @@
5 return None
6
7
8+def principal_unit_charm():
9+ """Returns the name of the charm of the principal unit, otherwise None"""
10+ unit = principal_unit()
11+ if not unit:
12+ return None
13+ md = _metadata_unit(unit)
14+ return md.pop('name', None)
15+
16+
17 @cached
18 def remote_service_name(relid=None):
19 """The remote service name for a given relation-id (or the current relation)"""

Subscribers

People subscribed via source and target branches