~openstack-charmers-archive/charms/precise/heat/trunk

« back to all changes in this revision

Viewing changes to hooks/heat_context.py

  • Committer: yolanda.robla at canonical
  • Date: 2013-11-29 15:36:45 UTC
  • Revision ID: yolanda.robla@canonical.com-20131129153645-3wrbgxucz92igmf3
charm cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import subprocess
 
2
 
 
3
from charmhelpers.core.hookenv import config
1
4
from charmhelpers.contrib.openstack import context
2
5
 
3
6
 
13
16
                                                      ctxt['service_port'])
14
17
        ctxt['keystone_ec2_url'] = ec2_tokens
15
18
        return ctxt
 
19
 
 
20
 
 
21
class EncryptionContext(context.OSContextGenerator):
 
22
    def __call__(self):
 
23
        ctxt = {}
 
24
 
 
25
        encryption = config("encryption-key")
 
26
        if not encryption:
 
27
            # generate random key
 
28
            cmd = ['hexdump', '-n', 16, '-v', '-e', '\'/1 "%02x"\'', '/dev/random']
 
29
            encryption = subprocess.check_output(cmd).strip()
 
30
 
 
31
        ctxt['encryption_key'] = encryption
 
32
        return ctxt