~alexlist/charms/trusty/ceilometer/add-execd-preinstall

« back to all changes in this revision

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

  • Committer: James Page
  • Date: 2013-12-17 15:33:49 UTC
  • Revision ID: james.page@canonical.com-20131217153349-47887o8box1vsb0v
Resync helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
285
285
    return rels
286
286
 
287
287
 
 
288
@cached
 
289
def is_relation_made(relation, keys='private-address'):
 
290
    '''
 
291
    Determine whether a relation is established by checking for
 
292
    presence of key(s).  If a list of keys is provided, they
 
293
    must all be present for the relation to be identified as made
 
294
    '''
 
295
    if isinstance(keys, str):
 
296
        keys = [keys]
 
297
    for r_id in relation_ids(relation):
 
298
        for unit in related_units(r_id):
 
299
            context = {}
 
300
            for k in keys:
 
301
                context[k] = relation_get(k, rid=r_id,
 
302
                                          unit=unit)
 
303
            if None not in context.values():
 
304
                return True
 
305
    return False
 
306
 
 
307
 
288
308
def open_port(port, protocol="TCP"):
289
309
    """Open a service network port"""
290
310
    _args = ['open-port']