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_presetup {
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 if ($public_nic == '') or ($public_nic_ip == '') or ($public_nic == "br-ex") or ($public_nic == "br_ex") {
33 notify {"Skipping augeas, public_nic ${public_nic}, public_nic_ip ${public_nic_ip}":}
35 exec {'ovs-vsctl -t 10 -- --may-exist add-br br-ex':
36 path => ["/usr/sbin/", "/usr/bin/"],
37 unless => 'ip addr show br-ex | grep "inet "',
38 before => Exec['restart-network-public-nic-ip'],
41 exec {'systemctl restart network':
42 path => ["/usr/sbin/", "/usr/bin/"],
43 refreshonly => 'true',
46 exec {'restart-network-public-nic-ip':
47 command => 'systemctl restart network',
48 path => ["/usr/sbin/", "/usr/bin/"],
49 onlyif => 'ip addr show | grep $(ip addr show br-ex | grep -Eo "inet [\.0-9]+" | cut -d " " -f2) | grep -v br-ex',
53 #reconfigure public interface to be ovsport
54 augeas { "main-$public_nic":
55 context => "/files/etc/sysconfig/network-scripts/ifcfg-$public_nic",
68 "set BOOTPROTO static",
70 "set IPV6_AUTOCONF no",
73 "set OVS_BRIDGE br-ex",
77 before => Class["quickstack::pacemaker::params"],
78 require => Service["openvswitch"],
82 #create br-ex interface
83 file { 'external_bridge':
84 path => '/etc/sysconfig/network-scripts/ifcfg-br-ex',
88 content => template('trystack/br_ex.erb'),
89 before => Class["quickstack::pacemaker::params"],
92 exec {'ovs-vsctl -t 10 -- --may-exist add-br br-ex':
93 path => ["/usr/sbin/", "/usr/bin/"],
96 exec {'systemctl restart network':
97 path => ["/usr/sbin/", "/usr/bin/"],
98 refreshonly => 'true',