~openstack-charmers-archive/charms/precise/swift-storage/old-1501

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2014-10-01 21:28:39 UTC
  • mfrom: (38.3.19 ipv6)
  • Revision ID: james.page@ubuntu.com-20141001212839-508ocwgnrpri0ze6
[xianghui,dosaboy,r=james-page,t=gema] Add IPv6 support using prefer-ipv6 flag

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