Merge lp:~2-xtian/charm-helpers/application-version-set into lp:charm-helpers

Proposed by Christian Muirhead on 2016-07-15
Status: Rejected
Rejected by: Stuart Bishop on 2017-03-09
Proposed branch: lp:~2-xtian/charm-helpers/application-version-set
Merge into: lp:charm-helpers
Diff against target: 34 lines (+24/-0)
1 file modified
charmhelpers/core/hookenv.py (+24/-0)
To merge this branch: bzr merge lp:~2-xtian/charm-helpers/application-version-set
Reviewer Review Type Date Requested Status
Stuart Bishop 2016-07-15 Disapprove on 2017-03-09
Review via email: mp+300183@code.launchpad.net

Commit Message

Add charmhelpers.core.hookenv.application_version_set as a convenience wrapper for the application-version-set command. If it's not available, then it falls back to logging the version instead.

Juju 2.0-beta12 adds the application-version-set hook tool that lets a charm tell Juju which version of the charmed software is running. This displayed in the status info for the application, which means that charm authors won't need to jam it into status messages.

Description of the Change

Add charmhelpers.core.hookenv.application_version_set as a convenience wrapper for the application-version-set command. If it's not available, then it falls back to logging the version instead.

Juju 2.0-beta12 adds the application-version-set hook tool that lets a charm tell Juju which version of the charmed software is running. This displayed in the status info for the application, which means that charm authors won't need to jam it into status messages.

To post a comment you must log in.
Stuart Bishop (stub) wrote :

A similar branch got landed, adding core.hookenv.application_version_set()

review: Disapprove

Unmerged revisions

602. By Christian Muirhead on 2016-07-08

Undo inadvertent change to license text

601. By Christian Muirhead on 2016-07-08

Add core.hookenv.application_version_set

This calls the application-version-set hook tool to tell juju what
version of the charmed software is running, which will be displayed in
status. If the application-version-set command doesn't exist it logs
the version instead.

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 2016-07-06 14:41:05 +0000
3+++ charmhelpers/core/hookenv.py 2016-07-15 13:01:11 +0000
4@@ -829,6 +829,30 @@
5 return (status["status"], status["message"])
6
7
8+def application_version_set(version):
9+ """Set the running version of the charmed software
10+
11+ This is used to tell Juju what version of the application is running
12+ (as opposed to the version of the charm). It could be a package
13+ version number or some other useful identifier, such as a Git
14+ hash. The version set will be displayed in "juju status" output for
15+ the application.
16+
17+ If the application-version-set command isn't found then assume this
18+ is juju < 2.0 and log the version instead.
19+ """
20+ cmd = ['application-version-set', version]
21+ try:
22+ ret = subprocess.call(cmd)
23+ if ret == 0:
24+ return
25+ except OSError as e:
26+ if e.errno != errno.ENOENT:
27+ raise
28+ log_message = 'application-version-set: {}'.format(version)
29+ log(log_message, level='INFO')
30+
31+
32 def translate_exc(from_exc, to_exc):
33 def inner_translate_exc1(f):
34 @wraps(f)

Subscribers

People subscribed via source and target branches