~corey.bryant/charms/trusty/quantum-gateway/amulet-updates

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/hahelpers/apache.py

  • Committer: Corey Bryant
  • Date: 2014-10-07 21:03:47 UTC
  • Revision ID: corey.bryant@canonical.com-20141007210347-ltczd6bjm0b0yj18
Sync charm-helpers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
)
21
21
 
22
22
 
23
 
def get_cert():
 
23
def get_cert(cn=None):
 
24
    # TODO: deal with multiple https endpoints via charm config
24
25
    cert = config_get('ssl_cert')
25
26
    key = config_get('ssl_key')
26
27
    if not (cert and key):
27
28
        log("Inspecting identity-service relations for SSL certificate.",
28
29
            level=INFO)
29
30
        cert = key = None
 
31
        if cn:
 
32
            ssl_cert_attr = 'ssl_cert_{}'.format(cn)
 
33
            ssl_key_attr = 'ssl_key_{}'.format(cn)
 
34
        else:
 
35
            ssl_cert_attr = 'ssl_cert'
 
36
            ssl_key_attr = 'ssl_key'
30
37
        for r_id in relation_ids('identity-service'):
31
38
            for unit in relation_list(r_id):
32
39
                if not cert:
33
 
                    cert = relation_get('ssl_cert',
 
40
                    cert = relation_get(ssl_cert_attr,
34
41
                                        rid=r_id, unit=unit)
35
42
                if not key:
36
 
                    key = relation_get('ssl_key',
 
43
                    key = relation_get(ssl_key_attr,
37
44
                                       rid=r_id, unit=unit)
38
45
    return (cert, key)
39
46