Provide support for VPNaaS service_provider
A manifest and provider is needed to configure file /etc/neutron/neutron_vpnaas.conf , so the VPNaaS agent can work correctly when there are no defaults in this configuration file (such as in RDO). Change-Id: I50019d11196e4c6080813d32b3788fc5053074f4 Closes-Bug: #1538971
This commit is contained in:
parent
6dfbc869a8
commit
f497158f4b
@ -0,0 +1,10 @@
|
||||
Puppet::Type.type(:neutron_vpnaas_service_config).provide(
|
||||
:openstackconfig,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
|
||||
) do
|
||||
|
||||
def file_path
|
||||
'/etc/neutron/neutron_vpnaas.conf'
|
||||
end
|
||||
|
||||
end
|
40
lib/puppet/type/neutron_vpnaas_service_config.rb
Normal file
40
lib/puppet/type/neutron_vpnaas_service_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:neutron_vpnaas_service_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from neutron_vpnaas.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
|
||||
# we don't care about the order of items in array, hence
|
||||
# it is necessary to override insync
|
||||
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
|
||||
'neutron-vpnaas-agent'
|
||||
end
|
||||
|
||||
end
|
58
manifests/services/vpnaas.pp
Normal file
58
manifests/services/vpnaas.pp
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# Copyright (C) 2015 Kylinos Inc.
|
||||
#
|
||||
# Author: nanhai liao <nanhai.liao@kylin-cloud.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::vpnaas
|
||||
#
|
||||
# Configure the VPN as a Service Neutron Plugin
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (required) Whether or not to install the VPNaas Neutron plugin package
|
||||
# Defaults to present
|
||||
#
|
||||
# [*service_providers*]
|
||||
# (optional) Array of allowed service types or '<SERVICE DEFAULT>'.
|
||||
# Note: The default upstream value is empty.
|
||||
# If you plan to activate VPNaaS service, you'll need to set this
|
||||
# parameter otherwise neutron-server won't start correctly.
|
||||
# See https://bugs.launchpad.net/puppet-neutron/+bug/1538971
|
||||
# Must be in form <service_type>:<name>:<driver>[:default].
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class neutron::services::vpnaas (
|
||||
$package_ensure = 'present',
|
||||
$service_providers = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::neutron::params
|
||||
|
||||
# agent package contains both agent and service resources
|
||||
ensure_resource( 'package', 'neutron-vpnaas-agent', {
|
||||
ensure => $package_ensure,
|
||||
name => $::neutron::params::vpnaas_agent_package,
|
||||
tag => ['openstack', 'neutron-package'],
|
||||
})
|
||||
|
||||
if !is_service_default($service_providers) {
|
||||
# default value is uncommented setting, so we should not touch it at all
|
||||
neutron_vpnaas_service_config { 'service_providers/service_provider':
|
||||
value => $service_providers,
|
||||
}
|
||||
}
|
||||
}
|
88
spec/classes/neutron_services_vpnaas_spec.rb
Normal file
88
spec/classes/neutron_services_vpnaas_spec.rb
Normal file
@ -0,0 +1,88 @@
|
||||
#
|
||||
# Copyright (C) 2014 Red Hat Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Unit tests for neutron::services::vpnaas class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'neutron::services::vpnaas' do
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:service_providers => '<SERVICE_DEFAULT>'}
|
||||
end
|
||||
|
||||
shared_examples_for 'neutron vpnaas service plugin' do
|
||||
|
||||
context 'with default params' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
it 'installs vpnaas package' do
|
||||
is_expected.to contain_package('neutron-vpnaas-agent').with(
|
||||
:ensure => params[:package_ensure],
|
||||
:name => platform_params[:vpnaas_package_name],
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple service providers' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{ :service_providers => ['provider1', 'provider2'] }
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures neutron_vpnaas.conf' do
|
||||
is_expected.to contain_neutron_vpnaas_service_config(
|
||||
'service_providers/service_provider'
|
||||
).with_value(['provider1', 'provider2'])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian'
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :vpnaas_package_name => 'neutron-vpn-agent'}
|
||||
end
|
||||
|
||||
it_configures 'neutron vpnaas service plugin'
|
||||
end
|
||||
|
||||
context 'on Red Hat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7'
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :vpnaas_package_name => 'openstack-neutron-vpnaas'}
|
||||
end
|
||||
|
||||
it_configures 'neutron vpnaas service plugin'
|
||||
end
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user