Support for FreeBSD
Experimental support for FreeBSD. Requires a fairly recent version of FreeBSD with pkgng installed. The ovs commands remain exactly the same, however it is necessary to replace invocations of the ip command with and equivalent ifconfig command in FreeBSD. Also, appropriate setting of the datapath is also required to make a bridge actually appear as an interface. Specified the default expected parameters for vswitch::ovs when used under FreeBSD. Also, some minor changes were made to the vswitch::ovs parameters, most notably the addition of a status parameter for the required services (ovs-vswitchd,ovsdb-server). Change-Id: I4c3923d17ac04402ac94ccea01e1d8ffcb5c0e4f
This commit is contained in:
parent
c40dc3aa21
commit
55637faa6f
@ -1,8 +1,12 @@
|
||||
require 'puppet'
|
||||
|
||||
Puppet::Type.type(:vs_bridge).provide(:ovs) do
|
||||
commands :vsctl => 'ovs-vsctl'
|
||||
commands :ip => 'ip'
|
||||
commands :vsctl => 'ovs-vsctl'
|
||||
if Facter.value(:operatingsystem) == 'FreeBSD'
|
||||
commands :ifconfig => 'ifconfig'
|
||||
else
|
||||
commands :ip => 'ip'
|
||||
end
|
||||
|
||||
def exists?
|
||||
vsctl("br-exists", @resource[:name])
|
||||
@ -12,12 +16,21 @@ Puppet::Type.type(:vs_bridge).provide(:ovs) do
|
||||
|
||||
def create
|
||||
vsctl('add-br', @resource[:name])
|
||||
ip('link', 'set', @resource[:name], 'up')
|
||||
if Facter.value(:operatingsystem) == 'FreeBSD'
|
||||
vsctl('set','bridge',@resource[:name],'datapath_type=netdev')
|
||||
ifconfig(@resource[:name],'up')
|
||||
else
|
||||
ip('link', 'set', @resource[:name], 'up')
|
||||
end
|
||||
external_ids = @resource[:external_ids] if @resource[:external_ids]
|
||||
end
|
||||
|
||||
def destroy
|
||||
ip('link', 'set', @resource[:name], 'down')
|
||||
if Facter.value(:operatingsystem) == 'FreeBSD'
|
||||
ifconfig(@resource[:name],'down')
|
||||
else
|
||||
ip('link', 'set', @resource[:name], 'down')
|
||||
end
|
||||
vsctl('del-br', @resource[:name])
|
||||
end
|
||||
|
||||
|
@ -71,6 +71,24 @@ class vswitch::ovs(
|
||||
name => $::vswitch::params::ovs_service_name,
|
||||
}
|
||||
}
|
||||
'FreeBSD': {
|
||||
Package {
|
||||
provider => 'pkgng',
|
||||
}
|
||||
service { 'ovsdb-server':
|
||||
ensure => true,
|
||||
enable => true,
|
||||
name => $::vswitch::params::ovsdb_service_name,
|
||||
status => $::vswitch::params::ovsdb_status,
|
||||
}
|
||||
~>
|
||||
service { 'openvswitch':
|
||||
ensure => true,
|
||||
enable => true,
|
||||
name => $::vswitch::params::ovs_service_name,
|
||||
status => $::vswitch::params::ovs_status,
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail( "${::osfamily} not yet supported by puppet-vswitch")
|
||||
}
|
||||
|
@ -14,6 +14,15 @@ class vswitch::params {
|
||||
$ovs_service_name = 'openvswitch-switch'
|
||||
$provider = 'ovs'
|
||||
}
|
||||
'FreeBSD': {
|
||||
$ovs_package_name = 'openvswitch'
|
||||
$ovs_pkg_provider = 'pkgng'
|
||||
$provider = 'ovs'
|
||||
$ovs_service_name = 'ovs-vswitchd'
|
||||
$ovsdb_service_name = 'ovsdb-server'
|
||||
$ovs_status = "/usr/sbin/service ${ovs_service_name} onestatus"
|
||||
$ovsdb_status = "/usr/sbin/service ${ovsdb_service_name} onestatus"
|
||||
}
|
||||
default: {
|
||||
fail " Osfamily ${::osfamily} not supported yet"
|
||||
}
|
||||
|
@ -35,8 +35,19 @@ describe 'vswitch::ovs' do
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch ovs' do
|
||||
let :freebsd_platform_params do {
|
||||
:ovs_package_name => 'openvswitch',
|
||||
:ovs_service_name => 'ovs-vswitchd',
|
||||
:ovsdb_service_name => 'ovsdb-server',
|
||||
:provider => 'ovs',
|
||||
:service_hasstatus => nil,
|
||||
:ovsdb_hasstatus => nil,
|
||||
:service_status => '/usr/sbin/service ovs-vswitchd onestatus',
|
||||
:ovsdb_status => '/usr/sbin/service ovsdb-server onestatus',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch ovs' do
|
||||
it 'contains params' do
|
||||
is_expected.to contain_class('vswitch::params')
|
||||
end
|
||||
@ -174,4 +185,59 @@ describe 'vswitch::ovs' do
|
||||
it_configures 'do not install dkms'
|
||||
end
|
||||
|
||||
context 'on FreeBSD with default parameters' do
|
||||
let :params do default_params end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'FreeBSD',
|
||||
:operatingsystem => 'FreeBSD',
|
||||
}
|
||||
end
|
||||
let :platform_params do freebsd_platform_params end
|
||||
|
||||
it_configures 'vswitch ovs'
|
||||
it_configures 'do not install dkms'
|
||||
|
||||
it 'configures ovsdb service' do
|
||||
is_expected.to contain_service('ovsdb-server').with(
|
||||
:ensure => true,
|
||||
:enable => true,
|
||||
:name => platform_params[:ovsdb_service_name],
|
||||
:hasstatus => platform_params[:ovsdb_hasstatus],
|
||||
:status => platform_params[:ovsdb_status],
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on FreeBSD with parameters' do
|
||||
let :params do {
|
||||
:package_ensure => 'latest',
|
||||
}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'FreeBSD',
|
||||
:operatingsystem => 'FreeBSD',
|
||||
}
|
||||
end
|
||||
let :platform_params do freebsd_platform_params end
|
||||
|
||||
it_configures 'vswitch ovs'
|
||||
it_configures 'do not install dkms'
|
||||
|
||||
it 'configures ovsdb service' do
|
||||
is_expected.to contain_service(platform_params[:ovsdb_service_name]).with(
|
||||
:ensure => true,
|
||||
:enable => true,
|
||||
:name => platform_params[:ovsdb_service_name],
|
||||
:hasstatus => platform_params[:ovsdb_hasstatus],
|
||||
:status => platform_params[:ovsdb_status],
|
||||
)
|
||||
end
|
||||
|
||||
it 'ovs-vswitchd requires ovsdb-server' do
|
||||
is_expected.to contain_service(platform_params[:ovsdb_service_name]).that_notifies("Service[#{platform_params[:ovs_package_name]}]")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user