~hopem/charms/trusty/nova-cloud-controller/grizzly

« back to all changes in this revision

Viewing changes to hooks/nova_cc_context.py

[hopem,r=wolsen]

Fixes novnc SSL (ha and single unit)

Closes-Bug: 1441143

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
1
3
from charmhelpers.core.hookenv import (
2
4
    config,
3
5
    relation_ids,
329
331
            servers = []
330
332
 
331
333
        ctxt['memcached_servers'] = ','.join(servers)
 
334
 
 
335
        # Configure nova-novncproxy https if nova-api is using https.
 
336
        if https():
 
337
            cn = resolve_address(endpoint_type=INTERNAL)
 
338
            if cn:
 
339
                cert_filename = 'cert_{}'.format(cn)
 
340
                key_filename = 'key_{}'.format(cn)
 
341
            else:
 
342
                cert_filename = 'cert'
 
343
                key_filename = 'key'
 
344
 
 
345
            ssl_dir = '/etc/apache2/ssl/nova'
 
346
            cert = os.path.join(ssl_dir, cert_filename)
 
347
            key = os.path.join(ssl_dir, key_filename)
 
348
            if os.path.exists(cert) and os.path.exists(key):
 
349
                ctxt['ssl_cert'] = cert
 
350
                ctxt['ssl_key'] = key
 
351
 
332
352
        return ctxt