1 #Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 class opnfv::external_net_setup {
17 if $public_gateway == '' { fail('public_gateway is empty') }
18 if $public_dns == '' { fail('public_dns is empty') }
19 if $public_network == '' { fail('public_network is empty') }
20 if $public_subnet == '' { fail('public_subnet is empty') }
21 if $public_allocation_start == '' { fail('public_allocation_start is empty') }
22 if $public_allocation_end == '' { fail('public_allocation_end is empty') }
23 if !$controllers_hostnames_array { fail('controllers_hostnames_array is empty') }
24 $controllers_hostnames_array_str = $controllers_hostnames_array
25 $controllers_hostnames_array = split($controllers_hostnames_array, ',')
28 $public_nic = get_nic_from_network("$public_network")
29 $public_nic_ip = get_ip_from_nic("$public_nic")
30 $public_nic_netmask = get_netmask_from_nic("$public_nic")
32 Anchor[ 'neutron configuration anchor end' ]
34 #update bridge-mappings to physnet1
37 path => '/etc/neutron/plugin.ini',
41 #update bridge-mappings to physnet1
42 file_line { 'bridge_mapping':
44 path => '/etc/neutron/plugin.ini',
45 line => 'bridge_mappings = physnet1:br-ex',
48 Exec["pcs-neutron-server-set-up"]
50 ##this way we only let controller1 create the neutron resources
51 ##controller1 should be the active neutron-server at provisioining time
53 if $hostname == $controllers_hostnames_array[0] {
54 Exec["all-neutron-nodes-are-up"]
56 neutron_network { 'provider_network':
58 name => 'provider_network',
59 admin_state_up => true,
60 provider_network_type => flat,
61 provider_physical_network => 'physnet1',
62 router_external => true,
63 tenant_name => 'admin',
66 neutron_subnet { 'provider_subnet':
68 name => provider_subnet,
69 cidr => $public_subnet,
70 gateway_ip => $public_gateway,
71 allocation_pools => [ "start=${public_allocation_start},end=${public_allocation_end}" ],
72 dns_nameservers => $public_dns,
73 network_name => 'provider_network',
74 tenant_name => 'admin',
77 neutron_router { 'provider_router':
79 name => 'provider_router',
80 admin_state_up => true,
81 gateway_network_name => 'provider_network',
82 tenant_name => 'admin',