Read "Private" network NIC MTU and use it for vhost0 interface

* Changes MTU for vhost0, thus changing it for interface vif0/0

Change-Id: Iadc3e5a50ea7a9947dfe2cce6ebfc1a1387695e1
This commit is contained in:
Pavel Basov
2016-07-07 16:09:07 -05:00
committed by Illia Polliul
parent e9df44723c
commit cd2025adb1
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
require 'puppetx/l23_network_scheme'
Puppet::Parser::Functions::newfunction(:get_physdev_mtu, :type => :rvalue, :arity => 1, :doc => <<-EOS
Returns MTU of a physical interface, including cases where it's a bond
EOS
) do |argv|
physdev = argv[0]
cfg = L23network::Scheme.get_config(lookupvar('l3_fqdn_hostname'))
transformations = cfg[:transformations]
interfaces = cfg[:interfaces]
transformations.each do |transform|
if (transform[:action] == 'add-bond') && (transform[:name] == physdev)
mtu = transform[:mtu]
return mtu if mtu
end
end
if interfaces[physdev.to_sym]
mtu = interfaces[physdev.to_sym][:mtu]
return mtu if mtu
end
end

View File

@@ -48,6 +48,7 @@ class contrail {
$netmask_short = netmask_to_cidr($netmask)
$phys_dev = get_private_ifname($interface)
$phys_dev_pci = get_dev_pci_addr($phys_dev)
$phys_dev_mtu = get_physdev_mtu(regsubst($phys_dev, '\..*' , ''))
$vrouter_core_mask = pick($settings['vrouter_core_mask'], '0x3')
# VIPs

View File

@@ -3,6 +3,9 @@ iface vhost0 inet static
pre-up /opt/contrail/bin/if-vhost0
address <%= scope.lookupvar('contrail::address') %>/<%= scope.lookupvar('contrail::netmask_short') %>
network_name contrail
<% if scope.lookupvar('contrail::phys_dev_mtu') -%>
mtu <%= scope.lookupvar('contrail::phys_dev_mtu') -%>
<% end -%>
<% if scope.lookupvar('contrail::gateway') -%>
<% scope.lookupvar('contrail::gateways').each do |gw| -%>
post-up ip route add <%= gw %>/32 via <%= scope.lookupvar('contrail::gateway') %> dev vhost0