From 4ff470de3306af3873702a6ec3c69fc8d9716d71 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Fri, 10 Apr 2015 18:42:31 +0100 Subject: [PATCH 1/3] [hopem,r=] Allow ml2 vlan-ranges and network-providers to be configurable. --- config.yaml | 5 +++++ hooks/neutron_api_context.py | 11 +++++++++++ templates/icehouse/ml2_conf.ini | 4 ++-- unit_tests/test_neutron_api_context.py | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 580a8582..aebc84ad 100644 --- a/config.yaml +++ b/config.yaml @@ -73,6 +73,11 @@ options: gre vxlan . + vlan-ranges: + type: string + default: "physnet1:1000:2000" + description: | + Space-delimited list of network provider vlan id ranges. # Quota configuration settings quota-security-group: default: 10 diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index f0ff0d33..de4464a4 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -13,6 +13,9 @@ from charmhelpers.contrib.hahelpers.cluster import ( from charmhelpers.contrib.openstack.utils import ( os_release, ) +from charmhelpers.contrib.openstack.neutron import ( + parse_vlan_range_mappings, +) def get_l2population(): @@ -180,6 +183,14 @@ class NeutronCCContext(context.NeutronContext): continue if ctxt['nova_url']: return ctxt + + vlan_ranges = config('vlan-ranges') + vlan_range_mappings = parse_vlan_range_mappings(vlan_ranges) + if vlan_range_mappings: + providers = sorted(vlan_range_mappings.keys()) + ctxt['network_providers'] = ','.join(providers) + ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) + return ctxt diff --git a/templates/icehouse/ml2_conf.ini b/templates/icehouse/ml2_conf.ini index fd1f80d2..4ade3bcb 100644 --- a/templates/icehouse/ml2_conf.ini +++ b/templates/icehouse/ml2_conf.ini @@ -15,10 +15,10 @@ tunnel_id_ranges = 1:1000 vni_ranges = 1001:2000 [ml2_type_vlan] -network_vlan_ranges = physnet1:1000:2000 +network_vlan_ranges = {{ vlan_ranges }} [ml2_type_flat] -flat_networks = physnet1 +flat_networks = {{ network_providers }} [ovs] enable_tunneling = True diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 8fd91af4..7348d593 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -286,6 +286,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_security_group_rule': 100, 'quota_subnet': 10, 'quota_vip': 10, + 'vlan_ranges': 'physnet1:1000:2000', + 'network_providers': 'physnet1', } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): @@ -317,6 +319,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_security_group_rule': 100, 'quota_subnet': 10, 'quota_vip': 10, + 'vlan_ranges': 'physnet1:1000:2000', + 'network_providers': 'physnet1', } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): @@ -354,6 +358,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_security_group_rule': 100, 'quota_subnet': 10, 'quota_vip': 10, + 'vlan_ranges': 'physnet1:1000:2000', + 'network_providers': 'physnet1', } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): From db4dca52abac0c2d308b0214662c9feec5568c6b Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Mon, 13 Apr 2015 11:15:58 +0100 Subject: [PATCH 2/3] fix neutron api context --- hooks/neutron_api_context.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index de4464a4..bdeaaaa2 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -129,6 +129,25 @@ class NeutronCCContext(context.NeutronContext): def _save_flag_file(self): pass + def get_neutron_api_rel_settings(self): + settings = {} + for rid in relation_ids('neutron-api'): + for unit in related_units(rid): + rdata = relation_get(rid=rid, unit=unit) + cell_type = rdata.get('cell_type') + settings['nova_url'] = rdata.get('nova_url') + settings['restart_trigger'] = rdata.get('restart_trigger') + # If there are multiple nova-cloud-controllers joined to this + # service in a cell deployment then ignore the non-api cell + # ones + if cell_type and not cell_type == "api": + continue + + if settings['nova_url']: + return settings + + return settings + def __call__(self): from neutron_api_utils import api_port ctxt = super(NeutronCCContext, self).__call__() @@ -170,19 +189,9 @@ class NeutronCCContext(context.NeutronContext): ctxt['quota_router'] = config('quota-router') ctxt['quota_floatingip'] = config('quota-floatingip') - for rid in relation_ids('neutron-api'): - for unit in related_units(rid): - rdata = relation_get(rid=rid, unit=unit) - cell_type = rdata.get('cell_type') - ctxt['nova_url'] = rdata.get('nova_url') - ctxt['restart_trigger'] = rdata.get('restart_trigger') - # If there are multiple nova-cloud-controllers joined to this - # service in a cell deployment then ignore the non-api cell - # ones - if cell_type and not cell_type == "api": - continue - if ctxt['nova_url']: - return ctxt + n_api_settings = self.get_neutron_api_rel_settings() + if n_api_settings: + ctxt.update(n_api_settings) vlan_ranges = config('vlan-ranges') vlan_range_mappings = parse_vlan_range_mappings(vlan_ranges) From b8a2c2cb651bb24ef068ba70130994d89983b326 Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 15 Apr 2015 15:25:38 +0100 Subject: [PATCH 3/3] Add ml2 configuration for kilo, disable hyperv mechanism driver. --- templates/kilo/ml2_conf.ini | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 templates/kilo/ml2_conf.ini diff --git a/templates/kilo/ml2_conf.ini b/templates/kilo/ml2_conf.ini new file mode 100644 index 00000000..86b80ec9 --- /dev/null +++ b/templates/kilo/ml2_conf.ini @@ -0,0 +1,36 @@ +# kilo +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +############################################################################### +[ml2] +type_drivers = gre,vxlan,vlan,flat +tenant_network_types = gre,vxlan,vlan,flat +mechanism_drivers = openvswitch,l2population + +[ml2_type_gre] +tunnel_id_ranges = 1:1000 + +[ml2_type_vxlan] +vni_ranges = 1001:2000 + +[ml2_type_vlan] +network_vlan_ranges = {{ vlan_ranges }} + +[ml2_type_flat] +flat_networks = {{ network_providers }} + +[ovs] +enable_tunneling = True +local_ip = {{ local_ip }} + +[agent] +tunnel_types = {{ overlay_network_type }} + +[securitygroup] +{% if neutron_security_groups -%} +enable_security_group = True +firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver +{% else -%} +enable_security_group = False +{% endif -%}