Skip to content

Commit

Permalink
Add support for OVN plugin
Browse files Browse the repository at this point in the history
Added a puppet class to install the plugin package and
configure the OVN plugin

Closes-bug: #1566280
Change-Id: I9d33721ef80938b955b18c6e97e10000b144ce2f
  • Loading branch information
anbu-enovance committed Apr 14, 2016
1 parent 1941fd8 commit 1fb8dd5
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb
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
35 changes: 35 additions & 0 deletions lib/puppet/type/neutron_plugin_ovn.rb
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
6 changes: 6 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
# [*plugin_opencontrail_config*]
# (optional) Manage configuration of plugins/opencontrail/ContrailPlugin.ini
#
# [*plugin_ovn_config*]
# (optional) Manage configuration of plugins/networking-ovn/networking-ovn.ini
#
# [*plugin_nuage_config*]
# (optional) Manage configuration of plugins/nuage/plugin.ini
#
Expand Down Expand Up @@ -94,6 +97,7 @@
$plugin_midonet_config = {},
$plugin_plumgrid_config = {},
$plugin_opencontrail_config = {},
$plugin_ovn_config = {},
$plugin_nuage_config = {},
$plugin_ml2_config = {},
) {
Expand All @@ -113,6 +117,7 @@
validate_hash($plugin_midonet_config)
validate_hash($plugin_plumgrid_config)
validate_hash($plugin_opencontrail_config)
validate_hash($plugin_ovn_config)
validate_hash($plugin_nuage_config)
validate_hash($plugin_ml2_config)

Expand All @@ -130,6 +135,7 @@
create_resources('neutron_plugin_midonet', $plugin_midonet_config)
create_resources('neutron_plugin_plumgrid', $plugin_plumgrid_config)
create_resources('neutron_plugin_opencontrail', $plugin_opencontrail_config)
create_resources('neutron_plugin_ovn', $plugin_ovn_config)
create_resources('neutron_plugin_nuage', $plugin_nuage_config)
create_resources('neutron_plugin_ml2', $plugin_ml2_config)
}
6 changes: 6 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
$midonet_server_package = 'python-neutron-plugin-midonet'
$midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini'

$ovn_plugin_package = 'python-networking-ovn'
$ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini'

$plumgrid_plugin_package = 'networking-plumgrid'
$plumgrid_pythonlib_package = 'plumgrid-pythonlib'
$plumgrid_config_file = '/etc/neutron/plugins/plumgrid/plumgrid.ini'
Expand Down Expand Up @@ -127,6 +130,9 @@
$midonet_server_package = 'python-neutron-plugin-midonet'
$midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini'

$ovn_plugin_package = 'python-networking-ovn'
$ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini'

$plumgrid_plugin_package = 'networking-plumgrid'
$plumgrid_pythonlib_package = 'plumgrid-pythonlib'
$plumgrid_config_file = '/etc/neutron/plugins/plumgrid/plumgrid.ini'
Expand Down
105 changes: 105 additions & 0 deletions manifests/plugins/ovn.pp
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;
}
}
3 changes: 3 additions & 0 deletions releasenotes/notes/ovn_support-c404cdc8f8624632.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
features:
- Add support for OVN driver.
22 changes: 22 additions & 0 deletions spec/acceptance/neutron_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
File <||> -> Neutron_vpnaas_agent_config <||>
File <||> -> Neutron_plugin_midonet <||>
File <||> -> Neutron_plugin_opencontrail <||>
File <||> -> Neutron_plugin_ovn <||>
File <||> -> Neutron_agent_linuxbridge <||>
File <||> -> Neutron_agent_ovs <||>
File <||> -> Neutron_plugin_plumgrid <||>
Expand All @@ -41,6 +42,7 @@
'/etc/neutron/plugins/nicira',
'/etc/neutron/plugins/midonet',
'/etc/neutron/plugins/opencontrail',
'/etc/neutron/plugins/networking-ovn',
'/etc/neutron/plugins/plumgrid']
$neutron_files = [ '/etc/neutron/api-paste.ini',
Expand All @@ -61,6 +63,7 @@
'/etc/neutron/vpn_agent.ini',
'/etc/neutron/plugins/midonet/midonet.ini',
'/etc/neutron/plugins/opencontrail/ContrailPlugin.ini',
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
'/etc/neutron/plugins/plumgrid/plumgrid.ini',
'/etc/neutron/plugins/ml2/ml2_conf_sriov.ini',
'/etc/neutron/plugins/ml2/sriov_agent.ini']
Expand Down Expand Up @@ -397,6 +400,24 @@
ensure_absent_val => 'toto',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist' :
value => '<SERVICE DEFAULT>',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldexist2' :
value => '<SERVICE DEFAULT>',
ensure_absent_val => 'toto',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist2' :
value => 'toto',
ensure_absent_val => 'toto',
}
neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
Expand Down Expand Up @@ -552,6 +573,7 @@
'/etc/neutron/vpn_agent.ini',
'/etc/neutron/plugins/midonet/midonet.ini',
'/etc/neutron/plugins/opencontrail/ContrailPlugin.ini',
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
'/etc/neutron/plugins/plumgrid/plumgrid.ini',
'/etc/neutron/plugins/ml2/ml2_conf_sriov.ini',
'/etc/neutron/plugins/ml2/sriov_agent.ini',
Expand Down
120 changes: 120 additions & 0 deletions spec/classes/neutron_plugins_ovn_spec.rb
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

0 comments on commit 1fb8dd5

Please sign in to comment.