~gnuoy/charms/trusty/neutron-api/order-overlay-type

« back to all changes in this revision

Viewing changes to hooks/neutron_api_context.py

  • Committer: james.page at ubuntu
  • Date: 2015-03-31 07:53:39 UTC
  • mfrom: (73.5.12 neutron-api)
  • Revision ID: james.page@ubuntu.com-20150331075339-810385fstrdluc1l
[gnuoy,r=james-page] Add support for Neutron DVR and Router HA

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
    relation_ids,
4
4
    related_units,
5
5
    relation_get,
 
6
    log,
6
7
)
7
8
from charmhelpers.contrib.openstack import context
8
9
from charmhelpers.contrib.hahelpers.cluster import (
9
10
    determine_api_port,
10
11
    determine_apache_port,
11
12
)
 
13
from charmhelpers.contrib.openstack.utils import (
 
14
    os_release,
 
15
)
12
16
 
13
17
 
14
18
def get_l2population():
23
27
    return overlay_net
24
28
 
25
29
 
 
30
def get_l3ha():
 
31
    if config('enable-l3ha'):
 
32
        if os_release('neutron-server') < 'juno':
 
33
            log('Disabling L3 HA, enable-l3ha is not valid before Juno')
 
34
            return False
 
35
        if config('overlay-network-type') not in ['vlan', 'gre', 'vxlan']:
 
36
            log('Disabling L3 HA, enable-l3ha requires the use of the vxlan, '
 
37
                'vlan or gre overlay network')
 
38
            return False
 
39
        if get_l2population():
 
40
            log('Disabling L3 HA, l2-population must be disabled with L3 HA')
 
41
            return False
 
42
        return True
 
43
    else:
 
44
        return False
 
45
 
 
46
 
 
47
def get_dvr():
 
48
    if config('enable-dvr'):
 
49
        if os_release('neutron-server') < 'juno':
 
50
            log('Disabling DVR, enable-dvr is not valid before Juno')
 
51
            return False
 
52
        if config('overlay-network-type') != 'vxlan':
 
53
            log('Disabling DVR, enable-dvr requires the use of the vxlan '
 
54
                'overlay network')
 
55
            return False
 
56
        if get_l3ha():
 
57
            log('Disabling DVR, enable-l3ha must be disabled with dvr')
 
58
            return False
 
59
        if not get_l2population():
 
60
            log('Disabling DVR, l2-population must be enabled to use dvr')
 
61
            return False
 
62
        return True
 
63
    else:
 
64
        return False
 
65
 
 
66
 
26
67
class ApacheSSLContext(context.ApacheSSLContext):
27
68
 
28
69
    interfaces = ['https']
69
110
    def neutron_overlay_network_type(self):
70
111
        return get_overlay_network_type()
71
112
 
 
113
    @property
 
114
    def neutron_dvr(self):
 
115
        return get_dvr()
 
116
 
 
117
    @property
 
118
    def neutron_l3ha(self):
 
119
        return get_l3ha()
 
120
 
72
121
    # Do not need the plugin agent installed on the api server
73
122
    def _ensure_packages(self):
74
123
        pass
91
140
                ctxt['nsx_controllers_list'] = \
92
141
                    config('nsx-controllers').split()
93
142
        ctxt['l2_population'] = self.neutron_l2_population
 
143
        ctxt['enable_dvr'] = self.neutron_dvr
 
144
        ctxt['l3_ha'] = self.neutron_l3ha
 
145
        if self.neutron_l3ha:
 
146
            ctxt['max_l3_agents_per_router'] = \
 
147
                config('max-l3-agents-per-router')
 
148
            ctxt['min_l3_agents_per_router'] = \
 
149
                config('min-l3-agents-per-router')
94
150
        ctxt['overlay_network_type'] = self.neutron_overlay_network_type
95
151
        ctxt['external_network'] = config('neutron-external-network')
96
152
        ctxt['verbose'] = config('verbose')