diff --git a/recipes/default.rb b/recipes/default.rb index 54535dcc..47366dfc 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -218,6 +218,16 @@ end template_file = nil +# Common template values (between ML2 and Openvswitch) +tunnel_types = node['openstack']['network']['openvswitch']['tunnel_types'] +l2_population = 'False' +enable_distributed_routing = 'False' +if ['auto', 'true', true].include?(node['openstack']['network']['l3']['router_distributed']) + tunnel_types = 'gre, vxlan' + l2_population = 'True' + enable_distributed_routing = 'True' +end + case main_plugin when 'bigswitch' @@ -333,7 +343,10 @@ when 'ml2' mode 00644 variables( mechanism_drivers: mechanism_drivers, - local_ip: openvswitch_endpoint.host + local_ip: openvswitch_endpoint.host, + tunnel_types: tunnel_types, + l2_population: l2_population, + enable_distributed_routing: enable_distributed_routing ) notifies :restart, 'service[neutron-server]', :delayed if role_match @@ -372,14 +385,6 @@ when 'openvswitch' openvswitch_endpoint = endpoint 'network-openvswitch' template_file = '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini' - tunnel_types = node['openstack']['network']['openvswitch']['tunnel_types'] - l2_population = 'False' - enable_distributed_routing = 'False' - if ['auto', 'true', true].include?(node['openstack']['network']['l3']['router_distributed']) - tunnel_types = 'gre, vxlan' - l2_population = 'True' - enable_distributed_routing = 'True' - end template template_file do source 'plugins/openvswitch/ovs_neutron_plugin.ini.erb' diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 61cd2e47..0f65907e 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -69,31 +69,57 @@ describe 'openstack-network' do PLUGIN_MAP['brocade'], physical_interface_mappings: '' - it_behaves_like 'core plugin common configurator', - 'ml2', - PLUGIN_MAP['ml2'], - type_drivers: 'local,flat,vlan,gre,vxlan', - tenant_network_types: 'local', - mechanism_drivers: 'openvswitch', - flat_networks: '', - network_vlan_ranges: '', - tunnel_id_ranges: '', - vni_ranges: '', - vxlan_group: '', - enable_security_group: 'True', - enable_ipset: 'True' - # TODO: MRV - # OVS section is in there, need refactor this code to be able to - # handle sections and different attribute namespaces - # - # tenant_network_type: 'local', - # enable_tunneling: 'False', - # integration_bridge: 'br-int', - # tunnel_bridge: 'br-tun', - # local_ip: 'openvswitch_host', - # polling_interval: '2', - # veth_mtu: '1500', - # firewall_driver: 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver' + describe 'ml2' do + let(:file) { chef_run.template('/etc/neutron/plugins/ml2/ml2_conf.ini') } + + it_behaves_like 'core plugin common configurator', + 'ml2', + PLUGIN_MAP['ml2'], + type_drivers: 'local,flat,vlan,gre,vxlan', + tenant_network_types: 'local', + mechanism_drivers: 'openvswitch', + flat_networks: '', + network_vlan_ranges: '', + tunnel_id_ranges: '', + vni_ranges: '', + vxlan_group: '', + enable_security_group: 'True', + enable_ipset: 'True' + + it 'sets related attributes for openvswitch section' do + [ + /^tenant_network_type = local$/, + /^enable_tunneling = False$/, + /^tunnel_type = $/, + /^integration_bridge = br-int$/, + /^tunnel_bridge = br-tun$/, + /^local_ip = 127.0.0.1$/ + ].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('OVS', line) + end + end + + it 'sets related attributes for agent section' do + [ + /^polling_interval = 2$/, + /^tunnel_types = $/, + /^veth_mtu = 1500$/, + /^l2_population = False$/, + /^enable_distributed_routing = False$/ + ].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('agent', line) + end + end + + it 'sets related attributes for securitygroup section' do + [ + /^firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver$/, + /^enable_security_group = True$/ + ].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('securitygroup', line) + end + end + end describe 'cisco' do let(:nexus_switch_value) do {