Add support for networking-sfc
Implements: blueprint networking-sfc-support Co-Authored-By: Tim Rozet <trozet@redhat.com> Change-Id: I09ce12298caee6fb2194240f2e19b4771ab797b0
This commit is contained in:
parent
342cc06f52
commit
cd4ab63101
@ -0,0 +1,15 @@
|
||||
Puppet::Type.type(:neutron_sfc_service_config).provide(
|
||||
:openstackconfig,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
|
||||
) do
|
||||
|
||||
def self.file_path
|
||||
'/etc/neutron/conf.d/neutron-server/networking-sfc.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
36
lib/puppet/type/neutron_sfc_service_config.rb
Normal file
36
lib/puppet/type/neutron_sfc_service_config.rb
Normal file
@ -0,0 +1,36 @@
|
||||
Puppet::Type.newtype(:neutron_sfc_service_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from networking-sfc.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value, :array_matching => :all) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
def insync?(is)
|
||||
return true if @should.empty?
|
||||
return false unless is.is_a? Array
|
||||
return false unless is.length == @should.length
|
||||
return (
|
||||
is & @should == is or
|
||||
is & @should.map(&:to_s) == is
|
||||
)
|
||||
end
|
||||
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
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 ['python-networking-sfc'] end
|
||||
|
||||
end
|
@ -39,6 +39,9 @@
|
||||
# [*l2gw_service_config*]
|
||||
# (optional) Manage configuration of l2gw_plugin.ini
|
||||
#
|
||||
# [*sfc_service_config*]
|
||||
# (optional) Manage configuration of networking-sfc.conf
|
||||
#
|
||||
# [*l3_agent_config*]
|
||||
# (optional) Manage configuration of l3_agent.ini
|
||||
#
|
||||
@ -100,6 +103,7 @@ class neutron::config (
|
||||
$bgpvpn_service_config = {},
|
||||
$l2gw_agent_config = {},
|
||||
$l2gw_service_config = {},
|
||||
$sfc_service_config = {},
|
||||
$l3_agent_config = {},
|
||||
$dhcp_agent_config = {},
|
||||
$lbaas_agent_config = {},
|
||||
@ -127,6 +131,7 @@ class neutron::config (
|
||||
validate_hash($bgpvpn_service_config)
|
||||
validate_hash($l2gw_agent_config)
|
||||
validate_hash($l2gw_service_config)
|
||||
validate_hash($sfc_service_config)
|
||||
validate_hash($l3_agent_config)
|
||||
validate_hash($dhcp_agent_config)
|
||||
validate_hash($lbaas_agent_config)
|
||||
@ -150,6 +155,7 @@ class neutron::config (
|
||||
create_resources('neutron_bgpvpn_bagpipe_config', $bgpvpn_bagpipe_config)
|
||||
create_resources('neutron_bgpvpn_service_config', $bgpvpn_service_config)
|
||||
create_resources('neutron_l2gw_agent_config', $l2gw_agent_config)
|
||||
create_resources('neutron_sfc_service_config', $sfc_service_config)
|
||||
create_resources('neutron_l3_agent_config', $l3_agent_config)
|
||||
create_resources('neutron_dhcp_agent_config', $dhcp_agent_config)
|
||||
create_resources('neutron_lbaas_agent_config', $lbaas_agent_config)
|
||||
|
@ -40,6 +40,7 @@ class neutron::deps {
|
||||
Anchor['neutron::config::begin'] -> Neutron_api_paste_ini<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_bgpvpn_bagpipe_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_bgpvpn_service_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_sfc_service_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_dhcp_agent_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_fwaas_service_config<||> ~> Anchor['neutron::config::end']
|
||||
|
@ -36,6 +36,7 @@ class neutron::params {
|
||||
$l2gw_agent_service = 'neutron-l2gw-agent'
|
||||
$nsx_plugin_package = 'vmware-nsx'
|
||||
$nsx_config_file = '/etc/neutron/plugins/vmware/nsx.ini'
|
||||
$sfc_package = 'python-networking-sfc'
|
||||
|
||||
if($::osfamily == 'Redhat') {
|
||||
$nobody_user_group = 'nobody'
|
||||
|
85
manifests/services/sfc.pp
Normal file
85
manifests/services/sfc.pp
Normal file
@ -0,0 +1,85 @@
|
||||
#
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# Author: Bernard Cafarelli <bcafarel@redhat.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: neutron::services::sfc
|
||||
#
|
||||
# Configure the Service Function Chaining Neutron extension
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# Whether to install the sfc extension package
|
||||
# Default to 'present'
|
||||
#
|
||||
# [*sfc_driver*]
|
||||
# (optional) SFC driver to use
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*fc_driver*]
|
||||
# (optional) Flow classifier driver to use
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*sync_db*]
|
||||
# Whether 'sfc-db-sync' should run to create and/or synchronize the
|
||||
# database with networking-sfc specific tables. Default to false
|
||||
#
|
||||
# [*purge_config*]
|
||||
# (optional) Whether to set only the specified config options
|
||||
# in the sfc config.
|
||||
# Default to false.
|
||||
#
|
||||
class neutron::services::sfc (
|
||||
$package_ensure = 'present',
|
||||
$sfc_driver = $::os_service_default,
|
||||
$fc_driver = $::os_service_default,
|
||||
$sync_db = false,
|
||||
$purge_config = false,
|
||||
) {
|
||||
|
||||
include ::neutron::deps
|
||||
include ::neutron::params
|
||||
|
||||
ensure_resource( 'package', $::neutron::params::sfc_package, {
|
||||
ensure => $package_ensure,
|
||||
name => $::neutron::params::sfc_package,
|
||||
tag => ['openstack', 'neutron-package'],
|
||||
})
|
||||
|
||||
neutron_sfc_service_config {
|
||||
'sfc/drivers': value => $sfc_driver;
|
||||
'flowclassifier/drivers': value => $fc_driver;
|
||||
}
|
||||
|
||||
resources { 'neutron_sfc_service_config':
|
||||
purge => $purge_config,
|
||||
}
|
||||
|
||||
if $sync_db {
|
||||
Package<| title == $::neutron::params::sfc_package |> ~> Exec['sfc-db-sync']
|
||||
exec { 'sfc-db-sync':
|
||||
command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --subproject networking-sfc upgrade head',
|
||||
path => '/usr/bin',
|
||||
subscribe => [
|
||||
Anchor['neutron::install::end'],
|
||||
Anchor['neutron::config::end'],
|
||||
Anchor['neutron::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['neutron::dbsync::end'],
|
||||
refreshonly => true
|
||||
}
|
||||
}
|
||||
}
|
4
releasenotes/notes/add_sfc_support-dc48691618415e97.yaml
Normal file
4
releasenotes/notes/add_sfc_support-dc48691618415e97.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Adds ability to configure networking-sfc neutron
|
||||
extension.
|
96
spec/classes/neutron_services_sfc_spec.rb
Normal file
96
spec/classes/neutron_services_sfc_spec.rb
Normal file
@ -0,0 +1,96 @@
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# Author: Tim Rozet <trozet@redhat.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'neutron::services::sfc' do
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:sfc_driver => '<SERVICE DEFAULT>',
|
||||
:fc_driver => '<SERVICE DEFAULT>',
|
||||
:sync_db => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'neutron sfc service plugin' do
|
||||
|
||||
context 'with default params' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
it 'installs sfc package' do
|
||||
is_expected.to contain_package('python-networking-sfc').with(
|
||||
:ensure => params[:package_ensure],
|
||||
:name => platform_params[:sfc_package_name],
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs neutron-db-sync' do
|
||||
is_expected.to contain_exec('sfc-db-sync').with(
|
||||
:command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --subproject networking-sfc upgrade head',
|
||||
:path => '/usr/bin',
|
||||
:subscribe => ['Anchor[neutron::install::end]',
|
||||
'Anchor[neutron::config::end]',
|
||||
'Anchor[neutron::dbsync::begin]'
|
||||
],
|
||||
:notify => 'Anchor[neutron::dbsync::end]',
|
||||
:refreshonly => 'true',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with sfc and classifier drivers' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{ :sfc_driver => 'odl_v2',
|
||||
:fc_driver => 'odl_v2'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures networking-sfc.conf' do
|
||||
is_expected.to contain_neutron_sfc_service_config(
|
||||
'sfc/drivers'
|
||||
).with_value('odl_v2')
|
||||
is_expected.to contain_neutron_sfc_service_config(
|
||||
'flowclassifier/drivers'
|
||||
).with_value('odl_v2')
|
||||
end
|
||||
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())
|
||||
end
|
||||
|
||||
let (:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'RedHat'
|
||||
{ :sfc_package_name => 'python-networking-sfc' }
|
||||
when 'Debian'
|
||||
{ :sfc_package_name => 'python-networking-sfc' }
|
||||
end
|
||||
end
|
||||
it_configures 'neutron sfc service plugin'
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,74 @@
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'openstacklib',
|
||||
'lib')
|
||||
)
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
provider_class = Puppet::Type.type(:neutron_sfc_service_config).provider(:openstackconfig)
|
||||
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
||||
resource = Puppet::Type::Neutron_sfc_service_config.new(
|
||||
{
|
||||
:name => 'DEFAULT/foo',
|
||||
:value => 'bar'
|
||||
}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('DEFAULT')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(provider.file_path).to eq('/etc/neutron/conf.d/neutron-server/networking-sfc.conf')
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Neutron_sfc_service_config.new(
|
||||
{
|
||||
:name => 'dude/foo',
|
||||
:value => 'bar'
|
||||
}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('dude')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(provider.file_path).to eq('/etc/neutron/conf.d/neutron-server/networking-sfc.conf')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Neutron_sfc_service_config.new(
|
||||
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
it 'should ensure absent when value matches ensure_absent_val' do
|
||||
resource = Puppet::Type::Neutron_sfc_service_config.new(
|
||||
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
end
|
20
spec/unit/type/neutron_sfc_service_config_spec.rb
Normal file
20
spec/unit/type/neutron_sfc_service_config_spec.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/neutron_sfc_service_config'
|
||||
|
||||
describe 'Puppet::Type.type(:neutron_sfc_service_config)' do
|
||||
|
||||
before :each do
|
||||
@neutron_sfc_service_config = Puppet::Type.type(:neutron_sfc_service_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'python-networking-sfc')
|
||||
catalog.add_resource package, @neutron_sfc_service_config
|
||||
dependency = @neutron_sfc_service_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@neutron_sfc_service_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user