~jjo/charms/trusty/neutron-gateway/add-hostname-resolution-to-etc_hosts-lp1489598

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/hookenv.py

  • Committer: Corey Bryant
  • Date: 2015-08-18 17:34:35 UTC
  • Revision ID: corey.bryant@canonical.com-20150818173435-9zjvt4h9y7eko0ng
[corey.bryant,r=trivial] Sync charm-helpers to pick up Liberty support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import tempfile
35
35
from subprocess import CalledProcessError
36
36
 
37
 
try:
38
 
    from charmhelpers.cli import cmdline
39
 
except ImportError as e:
40
 
    # due to the anti-pattern of partially synching charmhelpers directly
41
 
    # into charms, it's possible that charmhelpers.cli is not available;
42
 
    # if that's the case, they don't really care about using the cli anyway,
43
 
    # so mock it out
44
 
    if str(e) == 'No module named cli':
45
 
        class cmdline(object):
46
 
            @classmethod
47
 
            def subcommand(cls, *args, **kwargs):
48
 
                def _wrap(func):
49
 
                    return func
50
 
                return _wrap
51
 
    else:
52
 
        raise
53
 
 
54
37
import six
55
38
if not six.PY3:
56
39
    from UserDict import UserDict
91
74
        res = func(*args, **kwargs)
92
75
        cache[key] = res
93
76
        return res
 
77
    wrapper._wrapped = func
94
78
    return wrapper
95
79
 
96
80
 
190
174
    return os.environ.get('JUJU_RELATION', None)
191
175
 
192
176
 
193
 
@cmdline.subcommand()
194
177
@cached
195
178
def relation_id(relation_name=None, service_or_unit=None):
196
179
    """The relation ID for the current or a specified relation"""
216
199
    return os.environ.get('JUJU_REMOTE_UNIT', None)
217
200
 
218
201
 
219
 
@cmdline.subcommand()
220
202
def service_name():
221
203
    """The name service group this unit belongs to"""
222
204
    return local_unit().split('/')[0]
223
205
 
224
206
 
225
 
@cmdline.subcommand()
226
207
@cached
227
208
def remote_service_name(relid=None):
228
209
    """The remote service name for a given relation-id (or the current relation)"""