-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a puppet class to install the plugin package and configure the OVN plugin Closes-bug: #1566280 Change-Id: I9d33721ef80938b955b18c6e97e10000b144ce2f
- Loading branch information
1 parent
1941fd8
commit 1fb8dd5
Showing
8 changed files
with
307 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Puppet::Type.type(:neutron_plugin_ovn).provide( | ||
:ini_setting, | ||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) | ||
) do | ||
|
||
def file_path | ||
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Puppet::Type.newtype(:neutron_plugin_ovn) do | ||
|
||
ensurable | ||
|
||
newparam(:name, :namevar => true) do | ||
desc 'Section/setting name to manage from networking-ovn.ini' | ||
newvalues(/\S+\/\S+/) | ||
end | ||
|
||
newproperty(:value) do | ||
desc 'The value of the setting to be defined.' | ||
munge do |value| | ||
value = value.to_s.strip | ||
value.capitalize! if value =~ /^(true|false)$/i | ||
value | ||
end | ||
|
||
end | ||
|
||
newparam(:secret, :boolean => true) do | ||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.' | ||
newvalues(:true, :false) | ||
defaultto false | ||
end | ||
|
||
newparam(:ensure_absent_val) do | ||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified' | ||
defaultto('<SERVICE DEFAULT>') | ||
end | ||
|
||
autorequire(:package) do | ||
'neutron-plugin-ovn' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# This class installs and configures the OVN Neutron plugin | ||
# | ||
# === Parameters | ||
# | ||
# [*ovsdb_connection*] | ||
# (required) The connection string for the native OVSDB backend. | ||
# | ||
# [*ovsdb_connection_timeout*] | ||
# (optional) Timeout in seconds for the OVSDB connection transaction | ||
# Defaults to $::os_service_default | ||
# | ||
# [*neutron_sync_mode*] | ||
# (optional) The synchronization mode of OVN with Neutron DB. | ||
# Valid values are - ['log', 'off', 'repair'] | ||
# off - synchronization is off | ||
# log - during neutron-server startup check to see if OVN is in sync with | ||
# the Neutron database. Log warnings for any inconsistencies found so | ||
# that an admin can investigate. | ||
# repair - during neutron-server startup, automatically create resources | ||
# found in Neutron but not in OVN. Also remove resources from OVN | ||
# that are no longer in Neutron. | ||
# Defaults to $::os_service_default | ||
# | ||
# [*ovn_l3_mode*] | ||
# (optional) Whether to use OVN native L3 support. Do not change the | ||
# value for existing deployments that contain routers. | ||
# Type: boolean | ||
# Defaults to $::os_service_default | ||
# | ||
# [*vif_type*] | ||
# (optional) Type of VIF to be used for ports. | ||
# Valid values are ['ovs', 'vhostuser'] | ||
# Defaults to $::os_service_default | ||
|
||
class neutron::plugins::ovn( | ||
$ovsdb_connection, | ||
$ovsdb_connection_timeout = $::os_service_default, | ||
$neutron_sync_mode = $::os_service_default, | ||
$ovn_l3_mode = $::os_service_default, | ||
$vif_type = $::os_service_default, | ||
) { | ||
|
||
include ::neutron::params | ||
|
||
if ! is_service_default($ovn_l3_mode) { | ||
validate_bool($ovn_l3_mode) | ||
} | ||
|
||
if ! ( $vif_type in ['ovs', 'vhostuser', $::os_service_default] ) { | ||
fail( 'Invalid value for vif_type parameter' ) | ||
} | ||
|
||
if ! ( $neutron_sync_mode in ['off', 'log', 'repair', $::os_service_default] ) { | ||
fail( 'Invalid value for neutron_sync_mode parameter' ) | ||
} | ||
|
||
package {'neutron-plugin-ovn': | ||
ensure => present, | ||
name => $::neutron::params::ovn_plugin_package, | ||
tag => 'openstack' | ||
} | ||
|
||
Neutron_plugin_ovn<||> ~> Service['neutron-server'] | ||
|
||
ensure_resource('file', '/etc/neutron/plugins/networking-ovn', { | ||
ensure => directory, | ||
owner => 'root', | ||
group => 'neutron', | ||
mode => '0640'} | ||
) | ||
|
||
# Ensure the neutron package is installed before config is set | ||
# under both RHEL and Ubuntu | ||
if $::neutron::params::server_package { | ||
Package['neutron-server'] -> Neutron_plugin_ovn<||> | ||
} else { | ||
Package['neutron'] -> Neutron_plugin_ovn<||> | ||
} | ||
|
||
if $::osfamily == 'Debian' { | ||
file_line { '/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG': | ||
path => '/etc/default/neutron-server', | ||
match => '^NEUTRON_PLUGIN_CONFIG=(.*)$', | ||
line => "NEUTRON_PLUGIN_CONFIG=${::neutron::params::ovn_config_file}", | ||
require => [ Package['neutron-server'], Package['neutron-plugin-ovn'] ], | ||
notify => Service['neutron-server'], | ||
} | ||
} | ||
|
||
if $::osfamily == 'Redhat' { | ||
file { '/etc/neutron/plugin.ini': | ||
ensure => link, | ||
target => $::neutron::params::ovn_config_file, | ||
require => Package[$::neutron::params::ovn_plugin_package], | ||
} | ||
} | ||
|
||
neutron_plugin_ovn { | ||
'ovn/ovsdb_connection': value => $ovsdb_connection; | ||
'ovn/ovsdb_connection_timeout': value => $ovsdb_connection_timeout; | ||
'ovn/neutron_sync_mode': value => $neutron_sync_mode; | ||
'ovn/ovn_l3_mode': value => $ovn_l3_mode; | ||
'ovn/vif_type': value => $vif_type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
features: | ||
- Add support for OVN driver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
require 'spec_helper' | ||
|
||
describe 'neutron::plugins::ovn' do | ||
|
||
let :pre_condition do | ||
"class { 'neutron::server': auth_password => 'password' } | ||
class { 'neutron': rabbit_password => 'passw0rd' }" | ||
end | ||
|
||
let :default_params do | ||
{ | ||
:ovsdb_connection => 'tcp:127.0.0.1:6641', | ||
:ovsdb_connection_timeout => '60', | ||
:neutron_sync_mode => 'log', | ||
:ovn_l3_mode => true, | ||
:vif_type => 'ovs', | ||
} | ||
end | ||
|
||
let :test_facts do | ||
{ :operatingsystem => 'default', | ||
:operatingsystemrelease => 'default' | ||
} | ||
end | ||
|
||
shared_examples_for 'neutron ovn plugin' do | ||
|
||
let :params do | ||
{} | ||
end | ||
|
||
before do | ||
params.merge!(default_params) | ||
end | ||
|
||
it 'should perform default configuration of' do | ||
is_expected.to contain_neutron_plugin_ovn('ovn/ovsdb_connection').with_value(params[:ovsdb_connection]) | ||
is_expected.to contain_neutron_plugin_ovn('ovn/ovsdb_connection_timeout').with_value(params[:ovsdb_connection_timeout]) | ||
is_expected.to contain_neutron_plugin_ovn('ovn/neutron_sync_mode').with_value(params[:neutron_sync_mode]) | ||
is_expected.to contain_neutron_plugin_ovn('ovn/ovn_l3_mode').with_value(params[:ovn_l3_mode]) | ||
is_expected.to contain_neutron_plugin_ovn('ovn/vif_type').with_value(params[:vif_type]) | ||
end | ||
|
||
end | ||
|
||
shared_examples_for 'Validating parameters' do | ||
let :params do | ||
{} | ||
end | ||
|
||
before :each do | ||
params.clear | ||
params.merge!(default_params) | ||
end | ||
|
||
it 'should fail with undefined ovsdb_connection' do | ||
params.delete(:ovsdb_connection) | ||
is_expected.to raise_error(Puppet::Error) | ||
end | ||
|
||
it 'should fail with invalid neutron_sync_mode' do | ||
params[:neutron_sync_mode] = 'invalid' | ||
is_expected.to raise_error(Puppet::Error, /Invalid value for neutron_sync_mode parameter/) | ||
end | ||
|
||
it 'should fail with invalid vif_type' do | ||
params[:vif_type] = 'invalid' | ||
is_expected.to raise_error(Puppet::Error, /Invalid value for vif_type parameter/) | ||
params.delete(:vif_type) | ||
is_expected.to contain_neutron_plugin_ovn('ovn/vif_type').with_value('<SERVICE DEFAULT>') | ||
end | ||
end | ||
|
||
shared_examples_for 'debian specific' do | ||
let :params do | ||
default_params | ||
end | ||
|
||
it 'configures /etc/default/neutron-server' do | ||
is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( | ||
:path => '/etc/default/neutron-server', | ||
:match => '^NEUTRON_PLUGIN_CONFIG=(.*)$', | ||
:line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugins/networking-ovn/networking-ovn.ini', | ||
:require => ['Package[neutron-server]', 'Package[neutron-plugin-ovn]'], | ||
:notify => 'Service[neutron-server]') | ||
end | ||
end | ||
|
||
shared_examples_for 'redhat specific' do | ||
let :params do | ||
default_params | ||
end | ||
|
||
it 'should create plugin symbolic link' do | ||
is_expected.to contain_file('/etc/neutron/plugin.ini').with( | ||
:ensure => 'link', | ||
:target => '/etc/neutron/plugins/networking-ovn/networking-ovn.ini', | ||
:require => 'Package[python-networking-ovn]') | ||
end | ||
end | ||
|
||
on_supported_os({ | ||
:supported_os => OSDefaults.get_supported_os | ||
}).each do |os,facts| | ||
context "on #{os}" do | ||
let (:facts) do | ||
facts.merge(OSDefaults.get_facts({:processorcount => 8})) | ||
end | ||
|
||
case facts[:osfamily] | ||
when 'Debian' | ||
it_configures 'debian specific' | ||
when 'RedHat' | ||
it_configures 'redhat specific' | ||
end | ||
it_configures 'neutron ovn plugin' | ||
it_configures 'Validating parameters' | ||
end | ||
end | ||
end |