Add Solaris support

This patch adds Solaris support for configuration of openvswitch.

Change-Id: I9372eae6d084443f8e6bc7110b566e69b92d2a99
This commit is contained in:
Drew Fisher 2016-03-22 12:56:59 -06:00
parent bec7a21324
commit 1794f54fbe
5 changed files with 95 additions and 0 deletions

View File

@ -4,6 +4,8 @@ Puppet::Type.type(:vs_bridge).provide(:ovs) do
commands :vsctl => 'ovs-vsctl'
if Facter.value(:operatingsystem) == 'FreeBSD'
commands :ifconfig => 'ifconfig'
elsif Facter.value(:operatingsystem) == 'Solaris'
commands :ipadm => '/usr/sbin/ipadm'
else
commands :ip => 'ip'
end
@ -19,6 +21,8 @@ Puppet::Type.type(:vs_bridge).provide(:ovs) do
if Facter.value(:operatingsystem) == 'FreeBSD'
vsctl('set','bridge',@resource[:name],'datapath_type=netdev')
ifconfig(@resource[:name],'up')
elsif Facter.value(:operatingsystem) == 'Solaris'
ipadm('create-ip', @resource[:name])
else
ip('link', 'set', @resource[:name], 'up')
end

View File

@ -98,6 +98,21 @@ class vswitch::ovs(
status => $::vswitch::params::ovs_status,
}
}
'Solaris': {
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")
}

View File

@ -23,6 +23,13 @@ class vswitch::params {
$ovs_status = "/usr/sbin/service ${ovs_service_name} onestatus"
$ovsdb_status = "/usr/sbin/service ${ovsdb_service_name} onestatus"
}
'Solaris': {
$ovs_package_name = 'service/network/openvswitch'
$ovs_service_name = 'application/openvswitch/vswitch-server:default'
$ovsdb_service_name = 'application/openvswitch/ovsdb-server:default'
$ovs_status = "/usr/bin/svcs -H -o state ${ovs_service_name} | grep online"
$ovsdb_status = "/usr/bin/svcs -H -o state ${ovsdb_service_name} | grep online"
}
default: {
fail " Osfamily ${::osfamily} not supported yet"
}

View File

@ -31,6 +31,10 @@
{
"operatingsystem":"FreeBSD",
"operatingsystemrelease": [ "10.0", "11.0" ]
},
{
"operatingsystem":"Solaris",
"operatingsystemrelease": [ "11.3", "12.0" ]
}
],
"requirements": [

View File

@ -47,6 +47,18 @@ describe 'vswitch::ovs' do
}
end
let :solaris_platform_params do {
:ovs_package_name => 'service/network/openvswitch',
:ovs_service_name => 'application/openvswitch/vswitch-server:default',
:ovsdb_service_name => 'application/openvswitch/ovsdb-server:default',
:provider => 'ovs',
:service_hasstatus => nil,
:ovsdb_hasstatus => nil,
:service_status => '/usr/bin/svcs -H -o state application/openvswitch/vswitch-server:default | grep online',
:ovsdb_status => '/usr/bin/svcs -H -o state application/openvswitch/ovsdb-server:default | grep online',
}
end
shared_examples_for 'vswitch ovs' do
it 'contains params' do
is_expected.to contain_class('vswitch::params')
@ -250,4 +262,57 @@ describe 'vswitch::ovs' do
end
end
context 'on Solaris with default parameters' do
let :params do default_params end
let :facts do
{:osfamily => 'Solaris',
:operatingsystem => 'Solaris',
:ovs_version => '2.3.1',
}
end
let :platform_params do solaris_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 Solaris with parameters' do
let :params do {
:package_ensure => 'latest',
}
end
let :facts do
{:osfamily => 'Solaris',
:operatingsystem => 'Solaris',
:ovs_version => '2.3.1',
}
end
let :platform_params do solaris_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
end