~gnuoy/charms/trusty/neutron-openvswitch/neutron-contexts

« back to all changes in this revision

Viewing changes to hooks/neutron_ovs_context.py

  • Committer: james.page at ubuntu
  • Date: 2014-09-30 10:15:12 UTC
  • mfrom: (31.2.2 neutron-openvswitch)
  • Revision ID: james.page@ubuntu.com-20140930101512-cl1i4wz6ignmn2c3
[gnuoy,r=james-page] Add l2population driver support, on by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
DATA_BRIDGE = 'br-data'
19
19
 
20
20
 
21
 
def _neutron_security_groups():
22
 
    '''
23
 
    Inspects current neutron-plugin relation and determine if neutron-api has
24
 
    instructed us to use neutron security groups.
25
 
    '''
 
21
def _neutron_api_settings():
 
22
    '''
 
23
    Inspects current neutron-plugin relation
 
24
    '''
 
25
    neutron_settings = {
 
26
        'neutron_security_groups': False,
 
27
        'l2_population': True,
 
28
 
 
29
    }
26
30
    for rid in relation_ids('neutron-plugin-api'):
27
31
        for unit in related_units(rid):
28
 
            sec_group = relation_get('neutron-security-groups',
29
 
                                     rid=rid,
30
 
                                     unit=unit)
31
 
            if sec_group is not None:
32
 
                return sec_group
33
 
    return False
 
32
            rdata = relation_get(rid=rid, unit=unit)
 
33
            if 'l2-population' not in rdata:
 
34
                continue
 
35
            neutron_settings = {
 
36
                'l2_population': rdata['l2-population'],
 
37
                'neutron_security_groups': rdata['neutron-security-groups']
 
38
            }
 
39
            return neutron_settings
 
40
    return neutron_settings
34
41
 
35
42
 
36
43
class OVSPluginContext(context.NeutronContext):
46
53
 
47
54
    @property
48
55
    def neutron_security_groups(self):
49
 
        return _neutron_security_groups()
 
56
        neutron_api_settings = _neutron_api_settings()
 
57
        return neutron_api_settings['neutron_security_groups']
50
58
 
51
59
    def get_data_port(self):
52
60
        data_ports = config('data-port')
88
96
        ovs_ctxt['local_ip'] = \
89
97
            get_address_in_network(config('os-data-network'),
90
98
                                   get_host_ip(unit_get('private-address')))
 
99
        neutron_api_settings = _neutron_api_settings()
91
100
        ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups
 
101
        ovs_ctxt['l2_population'] = neutron_api_settings['l2_population']
92
102
        # TODO: We need to sort out the syslog and debug/verbose options as a
93
103
        # general context helper
94
104
        ovs_ctxt['use_syslog'] = conf['use-syslog']