~openstack-charmers-archive/charms/trusty/cinder/next

« back to all changes in this revision

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

  • Committer: Edward Hope-Morley
  • Date: 2015-03-19 09:56:14 UTC
  • mfrom: (78.1.3 cinder.fix-ssl-inject)
  • Revision ID: edward.hope-morley@canonical.com-20150319095614-0uwvyycp2pmsooba
[hopem,r=wolsen]

Fixes SSL cert/key inject from config.

Closes-Bug: 1351401

Show diffs side-by-side

added added

removed removed

Lines of Context:
566
566
def charm_dir():
567
567
    """Return the root directory of the current charm"""
568
568
    return os.environ.get('CHARM_DIR')
 
569
 
 
570
 
 
571
@cached
 
572
def action_get(key=None):
 
573
    """Gets the value of an action parameter, or all key/value param pairs"""
 
574
    cmd = ['action-get']
 
575
    if key is not None:
 
576
        cmd.append(key)
 
577
    cmd.append('--format=json')
 
578
    action_data = json.loads(subprocess.check_output(cmd).decode('UTF-8'))
 
579
    return action_data
 
580
 
 
581
 
 
582
def action_set(values):
 
583
    """Sets the values to be returned after the action finishes"""
 
584
    cmd = ['action-set']
 
585
    for k, v in list(values.items()):
 
586
        cmd.append('{}={}'.format(k, v))
 
587
    subprocess.check_call(cmd)
 
588
 
 
589
 
 
590
def action_fail(message):
 
591
    """Sets the action status to failed and sets the error message.
 
592
 
 
593
    The results set by action_set are preserved."""
 
594
    subprocess.check_call(['action-fail', message])