]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/neutron/manifests/plugins/ml2/type_driver.pp
af50157a95572a7d3ba284b1da5d3094842e5b1e
[dsa-puppet.git] / 3rdparty / modules / neutron / manifests / plugins / ml2 / type_driver.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 # neutron::plugins::ml2::type_driver used by neutron::plugins::ml2
19 #
20
21 define neutron::plugins::ml2::type_driver (
22   $flat_networks,
23   $tunnel_id_ranges,
24   $network_vlan_ranges,
25   $vni_ranges,
26   $vxlan_group
27 ){
28   if ($name == 'flat') {
29     neutron_plugin_ml2 {
30       'ml2_type_flat/flat_networks': value => join($flat_networks, ',');
31     }
32   }
33   elsif ($name == 'gre') {
34     # tunnel_id_ranges is required in gre
35     if ! $tunnel_id_ranges {
36       fail('when gre is part of type_drivers, tunnel_id_ranges should be given.')
37     }
38
39     validate_tunnel_id_ranges($tunnel_id_ranges)
40
41     neutron_plugin_ml2 {
42       'ml2_type_gre/tunnel_id_ranges': value => join($tunnel_id_ranges, ',');
43     }
44   }
45   elsif ($name == 'vlan') {
46     # network_vlan_ranges is required in vlan
47     if ! $network_vlan_ranges {
48       fail('when vlan is part of type_drivers, network_vlan_ranges should be given.')
49     }
50
51     validate_network_vlan_ranges($network_vlan_ranges)
52
53     neutron_plugin_ml2 {
54       'ml2_type_vlan/network_vlan_ranges': value => join($network_vlan_ranges, ',');
55     }
56   }
57   elsif ($name == 'vxlan') {
58     # vni_ranges and vxlan_group are required in vxlan
59     if (! $vni_ranges) or (! $vxlan_group) {
60       fail('when vxlan is part of type_drivers, vni_ranges and vxlan_group should be given.')
61     }
62     # test multicast ip address (ipv4 else ipv6):
63     case $vxlan_group {
64       /^2[\d.]+$/: {
65         case $vxlan_group {
66           /^(22[4-9]|23[0-9])\.(\d+)\.(\d+)\.(\d+)$/: { }
67           default: { }
68         }
69       }
70       /^ff[\d.]+$/: { }
71       default: {
72         fail("${vxlan_group} is not valid for vxlan_group.")
73       }
74     }
75
76     validate_vni_ranges($vni_ranges)
77
78     neutron_plugin_ml2 {
79       'ml2_type_vxlan/vxlan_group': value => $vxlan_group;
80       'ml2_type_vxlan/vni_ranges':  value => join($vni_ranges, ',');
81     }
82   }
83   elsif ($name == 'local') {
84     warning('local type_driver is useful only for single-box, because it provides no connectivity between hosts')
85   }
86   else {
87     # detect an invalid type_drivers value
88     fail('type_driver unknown.')
89   }
90 }