Skip to content

Commit 10c9606

Browse files
Emilien MacchiChris Hoge
authored andcommitted
Configure OVS Agent when using ML2 plugin
When running ML2 plugin, Neutron does not read the OVS plugin configuration file, so the Agents can't work (mount tunnels, configure L2, etc). To make it work, you need to move the configuration in ML2 configuration file. Signed-off-by: Emilien Macchi <[email protected]> Change-Id: Id70420a871edc352f80c0446e89dbcde94e5c490 (cherry picked from commit 069d086)
1 parent d91441f commit 10c9606

File tree

4 files changed

+430
-79
lines changed

4 files changed

+430
-79
lines changed

manifests/agents/ml2/ovs.pp

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
#
2+
# Copyright (C) 2014 eNovance SAS <[email protected]>
3+
#
4+
# Author: Emilien Macchi <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# == Class: neutron::agents::ml2::ovs
19+
#
20+
# Setups OVS neutron agent when using ML2 plugin
21+
#
22+
# === Parameters
23+
#
24+
# [*package_ensure*]
25+
# (optional) The state of the package
26+
# Defaults to 'present'
27+
#
28+
# [*enabled*]
29+
# (required) Whether or not to enable the OVS Agent
30+
# Defaults to true
31+
#
32+
# [*bridge_uplinks*]
33+
# (optional) List of interfaces to connect to the bridge when doing
34+
# bridge mapping.
35+
# Defaults to empty list
36+
#
37+
# [*bridge_mapping*]
38+
# (optional) List of <physical_network>:<bridge>
39+
# Defaults to empty list
40+
#
41+
# [*integration_bridge*]
42+
# (optional) Integration bridge in OVS
43+
# Defaults to 'br-int'
44+
#
45+
# [*enable_tunneling*]
46+
# (optional) Enable or not tunneling
47+
# Defaults to false
48+
#
49+
# [*tunnel_types*]
50+
# (optional) List of types of tunnels to use when utilizing tunnels,
51+
# either 'gre' or 'vxlan'.
52+
# Defaults to false
53+
#
54+
# [*local_ip*]
55+
# (optional) Local IP address of GRE tunnel endpoints.
56+
# Required when enabling tunneling
57+
# Defaults to false
58+
#
59+
# [*tunnel_bridge*]
60+
# (optional) Bridge used to transport tunnels
61+
# Defaults to 'br-tun'
62+
#
63+
# [*vxlan_udp_port*]
64+
# (optional) The UDP port to use for VXLAN tunnels.
65+
# Defaults to '4789'
66+
#
67+
# [*polling_interval*]
68+
# (optional) The number of seconds the agent will wait between
69+
# polling for local device changes.
70+
# Defaults to '2"
71+
#
72+
# [*l2_population*]
73+
# (optional) Extension to use alongside ml2 plugin's l2population
74+
# mechanism driver.
75+
# Defaults to false
76+
#
77+
# [*arp_responder*]
78+
# (optional) Enable or not the ARP responder.
79+
# Recommanded when using l2 population mechanism driver.
80+
# Defaults to false
81+
#
82+
# [*firewall_driver*]
83+
# (optional) Firewall driver for realizing neutron security group function.
84+
# Defaults to 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver'.
85+
#
86+
class neutron::agents::ml2::ovs (
87+
$package_ensure = 'present',
88+
$enabled = true,
89+
$bridge_uplinks = [],
90+
$bridge_mappings = [],
91+
$integration_bridge = 'br-int',
92+
$enable_tunneling = false,
93+
$tunnel_types = [],
94+
$local_ip = false,
95+
$tunnel_bridge = 'br-tun',
96+
$vxlan_udp_port = 4789,
97+
$polling_interval = 2,
98+
$l2_population = false,
99+
$arp_responder = false,
100+
$firewall_driver = 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver'
101+
) {
102+
103+
include neutron::params
104+
require vswitch::ovs
105+
106+
if $enable_tunneling and ! $local_ip {
107+
fail('Local ip for ovs agent must be set when tunneling is enabled')
108+
}
109+
110+
Neutron_plugin_ml2<||> ~> Service['neutron-ovs-agent-service']
111+
112+
if ($bridge_mappings != []) {
113+
# bridge_mappings are used to describe external networks that are
114+
# *directly* attached to this machine.
115+
# (This has nothing to do with VM-VM comms over neutron virtual networks.)
116+
# Typically, the network node - running L3 agent - will want one external
117+
# network (often this is on the control node) and the other nodes (all the
118+
# compute nodes) will want none at all. The only other reason you will
119+
# want to add networks here is if you're using provider networks, in which
120+
# case you will name the network with bridge_mappings and add the server's
121+
# interfaces that are attached to that network with bridge_uplinks.
122+
# (The bridge names can be nearly anything, they just have to match between
123+
# mappings and uplinks; they're what the OVS switches will get named.)
124+
125+
# Set config for bridges that we're going to create
126+
# The OVS neutron plugin will talk in terms of the networks in the bridge_mappings
127+
$br_map_str = join($bridge_mappings, ',')
128+
neutron_plugin_ml2 {
129+
'ovs/bridge_mappings': value => $br_map_str;
130+
}
131+
neutron::plugins::ovs::bridge{ $bridge_mappings:
132+
before => Service['neutron-ovs-agent-service'],
133+
}
134+
neutron::plugins::ovs::port{ $bridge_uplinks:
135+
before => Service['neutron-ovs-agent-service'],
136+
}
137+
}
138+
139+
neutron_plugin_ml2 {
140+
'agent/polling_interval': value => $polling_interval;
141+
'agent/l2_population': value => $l2_population;
142+
'agent/arp_responder': value => $arp_responder;
143+
'ovs/integration_bridge': value => $integration_bridge;
144+
}
145+
146+
if ($firewall_driver) {
147+
neutron_plugin_ml2 { 'securitygroup/firewall_driver':
148+
value => $firewall_driver
149+
}
150+
} else {
151+
neutron_plugin_ml2 { 'securitygroup/firewall_driver': ensure => absent }
152+
}
153+
154+
vs_bridge { $integration_bridge:
155+
ensure => present,
156+
before => Service['neutron-ovs-agent-service'],
157+
}
158+
159+
if $enable_tunneling {
160+
vs_bridge { $tunnel_bridge:
161+
ensure => present,
162+
before => Service['neutron-ovs-agent-service'],
163+
}
164+
neutron_plugin_ml2 {
165+
'ovs/enable_tunneling': value => true;
166+
'ovs/tunnel_bridge': value => $tunnel_bridge;
167+
'ovs/local_ip': value => $local_ip;
168+
}
169+
170+
if size($tunnel_types) > 0 {
171+
neutron_plugin_ml2 {
172+
'agent/tunnel_types': value => join($tunnel_types, ',');
173+
}
174+
}
175+
if 'vxlan' in $tunnel_types {
176+
validate_vxlan_udp_port($vxlan_udp_port)
177+
neutron_plugin_ml2 {
178+
'agent/vxlan_udp_port': value => $vxlan_udp_port;
179+
}
180+
}
181+
} else {
182+
neutron_plugin_ml2 {
183+
'ovs/enable_tunneling': value => false;
184+
'ovs/tunnel_bridge': ensure => absent;
185+
'ovs/local_ip': ensure => absent;
186+
}
187+
}
188+
189+
190+
if $::neutron::params::ovs_agent_package {
191+
Package['neutron-ovs-agent'] -> Neutron_plugin_ml2<||>
192+
package { 'neutron-ovs-agent':
193+
ensure => $package_ensure,
194+
name => $::neutron::params::ovs_agent_package,
195+
}
196+
} else {
197+
# Some platforms (RedHat) do not provide a separate
198+
# neutron plugin ovs agent package. The configuration file for
199+
# the ovs agent is provided by the neutron ovs plugin package.
200+
Package['neutron-ovs-agent'] -> Neutron_plugin_ml2<||>
201+
Package['neutron-ovs-agent'] -> Service['ovs-cleanup-service']
202+
203+
if ! defined(Package['neutron-ovs-agent']) {
204+
package { 'neutron-ovs-agent':
205+
ensure => $package_ensure,
206+
name => $::neutron::params::ovs_server_package,
207+
}
208+
}
209+
}
210+
211+
if $enabled {
212+
$service_ensure = 'running'
213+
} else {
214+
$service_ensure = 'stopped'
215+
}
216+
217+
service { 'neutron-ovs-agent-service':
218+
ensure => $service_ensure,
219+
name => $::neutron::params::ovs_agent_service,
220+
enable => $enabled,
221+
require => Class['neutron'],
222+
}
223+
224+
if $::neutron::params::ovs_cleanup_service {
225+
service {'ovs-cleanup-service':
226+
ensure => $service_ensure,
227+
name => $::neutron::params::ovs_cleanup_service,
228+
enable => $enabled,
229+
}
230+
}
231+
}

manifests/plugins/ml2.pp

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@
8383
# Min value is 0 and Max value is 16777215.
8484
# Default to empty.
8585
#
86-
# [*enable_security_group*]
87-
# (optionnal) Enable the security group API or not.
88-
# Since the ML2 plugin can concurrently support different L2 agents (or other
89-
# mechanisms) with different configurations, we need to set something to the
90-
# firewall_driver flag to enable security group API.
91-
# Defaults to false.
92-
#
93-
# [*firewall_driver*]
94-
# (optionnal) Set a firewall driver value.
95-
# If enable_security_group is enabled, it should be either true or a custom
96-
# firewall driver.
97-
# Defaults to true.
9886

9987
class neutron::plugins::ml2 (
10088
$type_drivers = ['local', 'flat', 'vlan', 'gre', 'vxlan'],
@@ -105,8 +93,9 @@
10593
$tunnel_id_ranges = ['20:100'],
10694
$vxlan_group = '224.0.0.1',
10795
$vni_ranges = ['10:100'],
108-
$enable_security_group = false,
109-
$firewall_driver = true
96+
# DEPRECATED PARAMS
97+
$enable_security_group = undef,
98+
$firewall_driver = undef
11099
) {
111100

112101
include neutron::params
@@ -155,25 +144,6 @@
155144
'securitygroup/enable_security_group': value => $enable_security_group;
156145
}
157146

158-
# Specific plugin configuration
159-
if ('openvswitch' in $mechanism_drivers) {
160-
if ($::osfamily == 'RedHat') {
161-
ensure_resource('package', 'neutron-plugin-ovs', {
162-
ensure => present,
163-
name => $::neutron::params::ovs_server_package,
164-
})
165-
Package['neutron-plugin-ovs'] -> Neutron_plugin_ovs<||>
166-
}
167-
if ('l2population' in $mechanism_drivers) {
168-
neutron_plugin_ovs {
169-
'agent/l2_population': value => true;
170-
}
171-
} else {
172-
neutron_plugin_ovs {
173-
'agent/l2_population': value => false;
174-
}
175-
}
176-
}
177147
if ('linuxbridge' in $mechanism_drivers) {
178148
if ($::osfamily == 'RedHat') {
179149
package { 'neutron-plugin-linuxbridge':
@@ -195,13 +165,10 @@
195165
}
196166

197167
if $enable_security_group {
198-
neutron_plugin_ml2 {
199-
'securitygroup/firewall_driver': value => $firewall_driver;
200-
}
201-
} else {
202-
neutron_plugin_ml2 {
203-
'securitygroup/firewall_driver': value => 'neutron.agent.firewall.NoopFirewallDriver';
204-
}
168+
warning('enable_security_group is deprecated. Security is managed by the firewall_drive value in ::neutron::agents::ml2::ovs.')
205169
}
206170

171+
if $firewall_driver {
172+
warning('firewall_driver value is set in ::neutron::agents::ml2::ovs, argument ignored.')
173+
}
207174
}

0 commit comments

Comments
 (0)