config/puppet-manifests/src/modules/platform/manifests/vswitch.pp
Steven Webster 99ef34d919 Puppet: enforce OVS init/config order
During debugging of a separate, unrelated issue, it was found that
there were instances of ports being added to OVS bridges after
the dpdk-init config option was passed to OVS.

Although there doesn't seem to be an actual execution error here,
it seems proper to ensure that the dpdk-init happens before DPDK
enabled ports are added.

Change-Id: Ib42d1404682fcbd1e98841e15302f1b86c98fcc4
Signed-off-by: Steven Webster <steven.webster@windriver.com>
2018-10-15 13:54:02 -04:00

154 lines
3.6 KiB
Puppet

class platform::vswitch::params(
$iommu_enabled = true,
$hugepage_dir = '/mnt/huge-1048576kB',
$driver_type = 'vfio-pci',
$vswitch_class = ::platform::vswitch::ovs,
) { }
class platform::vswitch
inherits ::platform::vswitch::params {
Class[$name] -> Class['::platform::network']
$enable_unsafe_noiommu_mode = bool2num(!$iommu_enabled)
exec {'vfio-iommu-mode':
command => "echo ${enable_unsafe_noiommu_mode} > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode",
require => Kmod::Load[$driver_type],
}
include $vswitch_class
}
define platform::vswitch::ovs::device(
$pci_addr,
$driver_type,
) {
exec { "ovs-bind-device: $title":
path => ["/usr/bin", "/usr/sbin", "/usr/share/openvswitch/scripts"],
command => "dpdk-devbind.py --bind=${driver_type} ${pci_addr}"
}
}
define platform::vswitch::ovs::bridge(
$datapath_type = 'netdev',
$attributes = [],
) {
exec { "ovs-add-br: ${title}":
command => template("platform/ovs.add-bridge.erb")
} ->
exec { "ovs-link-up: ${title}":
command => "ip link set ${name} up",
}
}
define platform::vswitch::ovs::port(
$type = 'port',
$bridge,
$attributes = [],
$interfaces,
) {
exec { "ovs-add-port: ${title}":
command => template("platform/ovs.add-port.erb"),
logoutput => true
}
}
define platform::vswitch::ovs::address(
$ifname,
$address,
$prefixlen,
) {
exec { "ovs-add-address: ${title}":
command => "ip addr replace ${address}/${prefixlen} dev ${ifname}",
}
}
define platform::vswitch::ovs::flow(
$bridge,
$attributes = [],
$actions,
) {
exec { "ovs-add-flow: ${title}":
command => template("platform/ovs.add-flow.erb"),
logoutput => true
}
}
class platform::vswitch::ovs(
$devices = {},
$bridges = {},
$ports = {},
$addresses = {},
$flows = {},
) inherits ::platform::vswitch::params {
if $::platform::params::vswitch_type == 'ovs' {
include ::vswitch::ovs
} elsif $::platform::params::vswitch_type == 'ovs-dpdk' {
include ::vswitch::dpdk
Exec['vfio-iommu-mode'] ->
Platform::Vswitch::Ovs::Device<||> ->
Platform::Vswitch::Ovs::Bridge<||>
create_resources('platform::vswitch::ovs::device', $devices, {
driver_type => $driver_type,
before => Service['openvswitch']
})
Mount[$hugepage_dir] -> Service['openvswitch']
$dpdk_configs = {
'other_config:dpdk-hugepage-dir' => { value => $hugepage_dir },
}
$dpdk_dependencies = {
wait => false,
require => Service['openvswitch'],
notify => Vs_config['other_config:dpdk-init'],
}
create_resources ('vs_config', $dpdk_configs, $dpdk_dependencies)
Vs_config<||> -> Platform::Vswitch::Ovs::Bridge<||>
}
if $::platform::params::vswitch_type =~ '^ovs' {
# clean bridges and ports before applying current configuration
exec { "ovs-clean":
command => template("platform/ovs.clean.erb"),
provider => shell,
require => Service['openvswitch']
} ->
Platform::Vswitch::Ovs::Bridge<||> -> Platform::Vswitch::Ovs::Port<||>
Platform::Vswitch::Ovs::Bridge<||> -> Platform::Vswitch::Ovs::Address<||>
Platform::Vswitch::Ovs::Port<||> -> Platform::Vswitch::Ovs::Flow<||>
}
create_resources('platform::vswitch::ovs::bridge', $bridges, {
require => Service['openvswitch']
})
create_resources('platform::vswitch::ovs::port', $ports, {
require => Service['openvswitch']
})
create_resources('platform::vswitch::ovs::address', $addresses, {
require => Service['openvswitch']
})
create_resources('platform::vswitch::ovs::flow', $flows, {
require => Service['openvswitch']
})
}