memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / plugins / ml2.pp
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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 # Configure the neutron server to use the ML2 plugin.
19 # This configures the plugin for the API server, but does nothing
20 # about configuring the agents that must also run and share a config
21 # file with the OVS plugin if both are on the same machine.
22 #
23 # === Parameters
24 #
25 # [*type_drivers*]
26 #   (optional) List of network type driver entrypoints to be loaded
27 #   from the neutron.ml2.type_drivers namespace.
28 #   Could be an array that can have these elements:
29 #   local, flat, vlan, gre, vxlan
30 #   Defaults to ['local', 'flat', 'vlan', 'gre', 'vxlan'].
31 #
32 # [*tenant_network_types*]
33 #   (optional) Ordered list of network_types to allocate as tenant networks.
34 #   The value 'local' is only useful for single-box testing
35 #   but provides no connectivity between hosts.
36 #   Should be an array that can have these elements:
37 #   local, flat, vlan, gre, vxlan
38 #   Defaults to ['local', 'flat', 'vlan', 'gre', 'vxlan'].
39 #
40 # [*mechanism_drivers*]
41 #   (optional) An ordered list of networking mechanism driver
42 #   entrypoints to be loaded from the neutron.ml2.mechanism_drivers namespace.
43 #   Should be an array that can have these elements:
44 #   logger, test, linuxbridge, openvswitch, hyperv, ncs, arista, cisco_nexus,
45 #   l2population, sriovnicswitch
46 #   Default to ['openvswitch', 'linuxbridge'].
47 #
48 # [*flat_networks*]
49 #   (optional) List of physical_network names with which flat networks
50 #   can be created. Use * to allow flat networks with arbitrary
51 #   physical_network names.
52 #   Should be an array.
53 #   Default to *.
54 #
55 # [*network_vlan_ranges*]
56 #   (optional) List of <physical_network>:<vlan_min>:<vlan_max> or
57 #   <physical_network> specifying physical_network names
58 #   usable for VLAN provider and tenant networks, as
59 #   well as ranges of VLAN tags on each available for
60 #   allocation to tenant networks.
61 #   Should be an array with vlan_min = 1 & vlan_max = 4094 (IEEE 802.1Q)
62 #   Default to empty.
63 #
64 # [*tunnel_id_ranges*]
65 #   (optional) Comma-separated list of <tun_min>:<tun_max> tuples
66 #   enumerating ranges of GRE tunnel IDs that are
67 #   available for tenant network allocation
68 #   Should be an array with tun_max +1 - tun_min > 1000000
69 #   Default to empty.
70 #
71 # [*vxlan_group*]
72 #   (optional) Multicast group for VXLAN.
73 #   Multicast group for VXLAN. If unset, disables VXLAN enable sending allocate
74 #   broadcast traffic to this multicast group. When left unconfigured, will
75 #   disable multicast VXLAN mode
76 #   Should be an Multicast IP (v4 or v6) address.
77 #   Default to 'None'.
78 #
79 # [*vni_ranges*]
80 #   (optional) Comma-separated list of <vni_min>:<vni_max> tuples
81 #   enumerating ranges of VXLAN VNI IDs that are
82 #   available for tenant network allocation.
83 #   Min value is 0 and Max value is 16777215.
84 #   Default to empty.
85 #
86 # [*enable_security_group*]
87 #   (optional) Controls if neutron security group is enabled or not.
88 #   It should be false when you use nova security group.
89 #   Defaults to true.
90 #
91 # [*supported_pci_vendor_devs*]
92 #   (optional) Supported PCI vendor devices, defined by
93 #   vendor_id:product_id according to the PCI ID
94 #   Repository. Should be an array of devices.
95 #   Defaults to ['15b3:1004', '8086:10ca'] (Intel & Mellanox SR-IOV capable NICs)
96 #
97 # [*sriov_agent_required*]
98 #   (optional) SRIOV neutron agent is required for port binding.
99 #   Only set to true if SRIOV network adapters support VF link state setting
100 #   and if admin state management is desired.
101 #   Defaults to false.
102 #
103
104 class neutron::plugins::ml2 (
105   $type_drivers              = ['local', 'flat', 'vlan', 'gre', 'vxlan'],
106   $tenant_network_types      = ['local', 'flat', 'vlan', 'gre', 'vxlan'],
107   $mechanism_drivers         = ['openvswitch', 'linuxbridge'],
108   $flat_networks             = ['*'],
109   $network_vlan_ranges       = ['physnet1:1000:2999'],
110   $tunnel_id_ranges          = ['20:100'],
111   $vxlan_group               = '224.0.0.1',
112   $vni_ranges                = ['10:100'],
113   $enable_security_group     = true,
114   $package_ensure            = 'present',
115   $supported_pci_vendor_devs = ['15b3:1004', '8086:10ca'],
116   $sriov_agent_required      = false,
117 ) {
118
119   include neutron::params
120
121   Neutron_plugin_ml2<||> ~> Service<| title == 'neutron-server' |>
122
123   validate_array($mechanism_drivers)
124   if ! $mechanism_drivers {
125     warning('Without networking mechanism driver, ml2 will not communicate with L2 agents')
126   }
127
128   if $::operatingsystem == 'Ubuntu' {
129     file_line { '/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG':
130       path    => '/etc/default/neutron-server',
131       match   => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
132       line    => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugin.ini',
133       require => File['/etc/neutron/plugin.ini'],
134     }
135     Package<| title == 'neutron-server' |>
136     -> File_line['/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG']
137     ~> Service<| title == 'neutron-server' |>
138   }
139
140   # In RH, the link is used to start Neutron process but in Debian, it's used only
141   # to manage database synchronization.
142   file {'/etc/neutron/plugin.ini':
143     ensure  => link,
144     target  => '/etc/neutron/plugins/ml2/ml2_conf.ini'
145   }
146
147   # Some platforms do not have a dedicated ml2 plugin package
148   if $::neutron::params::ml2_server_package {
149     package { 'neutron-plugin-ml2':
150       ensure => $package_ensure,
151       name   => $::neutron::params::ml2_server_package,
152     }
153     Package['neutron-plugin-ml2'] -> Neutron_plugin_ml2<||>
154     Package['neutron-plugin-ml2'] -> File['/etc/neutron/plugin.ini']
155   } else {
156     Package <| title == 'neutron-server' |> -> Neutron_plugin_ml2<||>
157     Package['neutron'] -> File['/etc/neutron/plugin.ini']
158   }
159
160   neutron::plugins::ml2::type_driver { $type_drivers:
161     flat_networks       => $flat_networks,
162     tunnel_id_ranges    => $tunnel_id_ranges,
163     network_vlan_ranges => $network_vlan_ranges,
164     vni_ranges          => $vni_ranges,
165     vxlan_group         => $vxlan_group,
166   }
167
168   neutron::plugins::ml2::mech_driver { $mechanism_drivers:
169     supported_pci_vendor_devs => $supported_pci_vendor_devs,
170     sriov_agent_required      => $sriov_agent_required,
171   }
172
173   neutron_plugin_ml2 {
174     'ml2/type_drivers':                     value => join($type_drivers, ',');
175     'ml2/tenant_network_types':             value => join($tenant_network_types, ',');
176     'ml2/mechanism_drivers':                value => join($mechanism_drivers, ',');
177     'securitygroup/enable_security_group':  value => $enable_security_group;
178   }
179
180   Neutron_plugin_ml2<||> ~> Exec<| title == 'neutron-db-sync' |>
181
182 }