~1chb1n/charms/trusty/nova-cloud-controller/15.10-stable-flip-tests-helper-syncs

« back to all changes in this revision

Viewing changes to hooks/nova_cc_context.py

Check in start of py redux.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from charmhelpers.core.hookenv import relation_ids, relation_set
 
3
from charmhelpers.core.host import apt_install, filter_installed_packages
 
4
from charmhelpers.contrib.openstack import context, utils
 
5
 
 
6
#from charmhelpers.contrib.hahelpers.cluster import (
 
7
#    determine_api_port,
 
8
#    determine_haproxy_port,
 
9
#)
 
10
 
 
11
 
 
12
class ApacheSSLContext(context.ApacheSSLContext):
 
13
 
 
14
    interfaces = ['https']
 
15
    external_ports = []
 
16
    service_namespace = 'nova'
 
17
 
 
18
    def __call__(self):
 
19
        # late import to work around circular dependency
 
20
        from nova_cc_utils import determine_ports
 
21
        self.external_ports = determine_ports()
 
22
        return super(ApacheSSLContext, self).__call__()
 
23
 
 
24
 
 
25
class VolumeServiceContext(context.OSContextGenerator):
 
26
    interfaces = []
 
27
 
 
28
    def __call__(self):
 
29
        ctxt = {}
 
30
 
 
31
        os_vers = utils.get_os_codename_package('nova-common')
 
32
 
 
33
        if (relation_ids('nova-volume-service') and
 
34
           os_vers in ['essex', 'folsom']):
 
35
            # legacy nova-volume support, only supported in E and F
 
36
            ctxt['volume_service_config'] = 'nova.volume.api.API'
 
37
            install_pkg = filter_installed_packages(['nova-api-os-volume'])
 
38
            if install_pkg:
 
39
                apt_install(install_pkg)
 
40
        elif relation_ids('cinder-volume-service'):
 
41
            ctxt['volume_service_config'] = 'nova.volume.cinder.API'
 
42
            # kick all compute nodes to know they should use cinder now.
 
43
            [relation_set(volume_service='cinder', rid=rid)
 
44
             for rid in relation_ids('cloud-compute')]
 
45
        return ctxt
 
46
 
 
47
 
 
48
class HAProxyContext(context.OSContextGenerator):
 
49
    interfaces = ['ceph']
 
50
 
 
51
    def __call__(self):
 
52
        '''
 
53
        Extends the main charmhelpers HAProxyContext with a port mapping
 
54
        specific to this charm.
 
55
        Also used to extend nova.conf context with correct api_listening_ports
 
56
        '''
 
57
        # TODO