|
| 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 | +} |
0 commit comments