lbaas v2 service plugin support.

lbaas v2 services has to be configured for each
lbaas component (Octavia, Haproxy, A10, etc). This
change adds classes to configure octavia and haproxy
at the service level. The lbaas agent class has been
updated to install the v2 agent on debian and manage
the agent services on both debian and redhat.

Change-Id: I39d9a53dd18cd966818d242b8ca1d4a829d73acc
Closes-Bug: 1565754
This commit is contained in:
Matthew Black 2016-04-05 11:59:35 -04:00
parent 3f019235b9
commit 2fec5ca7f6
14 changed files with 337 additions and 37 deletions

View File

@ -4,7 +4,7 @@ Puppet::Type.type(:neutron_lbaas_service_config).provide(
) do
def self.file_path
'/etc/neutron/neutron_lbaas.conf'
'/etc/neutron/neutron.conf'
end
# added for backwards compatibility with older versions of inifile

View File

@ -3,7 +3,7 @@ Puppet::Type.newtype(:neutron_lbaas_service_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from neutron_lbaas.conf'
desc 'Section/setting name to manage from neutron.conf'
newvalues(/\S+\/\S+/)
end
@ -34,7 +34,7 @@ Puppet::Type.newtype(:neutron_lbaas_service_config) do
end
autorequire(:package) do
'neutron-lbaas-agent'
'neutron-server'
end
end

View File

@ -37,6 +37,14 @@
# in the lbaas config.
# Defaults to false.
#
# [*enable_v1*]
# (optional) Whether to use lbaas v1 agent or not.
# Defaults to true
#
# [*enable_v2*]
# (optional) Whether to use lbaas v2 agent or not.
# Defaults to false
#
class neutron::agents::lbaas (
$package_ensure = present,
$enabled = true,
@ -47,6 +55,8 @@ class neutron::agents::lbaas (
$user_group = $::neutron::params::nobody_user_group,
$manage_haproxy_package = true,
$purge_config = false,
$enable_v1 = true,
$enable_v2 = false,
) {
include ::neutron::params
@ -54,6 +64,10 @@ class neutron::agents::lbaas (
Neutron_config<||> ~> Service['neutron-lbaas-service']
Neutron_lbaas_agent_config<||> ~> Service['neutron-lbaas-service']
if $enable_v1 and $enable_v2 {
fail('neutron agents LBaaS enable_v1 and enable_v2 parameters cannot both be true')
}
case $device_driver {
/\.haproxy/: {
Package <| title == $::neutron::params::haproxy_package |> -> Package <| title == 'neutron-lbaas-agent' |>
@ -86,20 +100,41 @@ class neutron::agents::lbaas (
name => $::neutron::params::lbaas_agent_package,
tag => ['openstack', 'neutron-package'],
})
if $::osfamily == 'Debian' {
ensure_packages(['neutron-lbaasv2-package'], {
ensure => $package_ensure,
name => $::neutron::params::lbaasv2_agent_package,
tag => ['openstack', 'neutron-package'],
})
Package['neutron'] -> Package['neutron-lbaasv2-package']
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
if $enable_v1 {
$service_v1_ensure = 'running'
$service_v2_ensure = 'stopped'
} elsif $enable_v2 {
$service_v1_ensure = 'stopped'
$service_v2_ensure = 'running'
} else {
$service_ensure = 'stopped'
$service_v1_ensure = 'stopped'
$service_v2_ensure = 'stopped'
}
Package['neutron'] ~> Service['neutron-lbaas-service']
Package['neutron-lbaas-agent'] ~> Service['neutron-lbaas-service']
}
service { 'neutron-lbaas-service':
ensure => $service_ensure,
ensure => $service_v1_ensure,
name => $::neutron::params::lbaas_agent_service,
enable => $enabled,
enable => $enable_v1,
require => Class['neutron'],
tag => 'neutron-service',
}
service { 'neutron-lbaasv2-service':
ensure => $service_v2_ensure,
name => $::neutron::params::lbaasv2_agent_service,
enable => $enable_v2,
require => Class['neutron'],
tag => 'neutron-service',
}

View File

@ -61,6 +61,9 @@ class neutron::params {
$lbaas_agent_package = 'openstack-neutron-lbaas'
$lbaas_agent_service = 'neutron-lbaas-agent'
$lbaasv2_agent_package = false
$lbaasv2_agent_service = 'neutron-lbaasv2-agent'
$haproxy_package = 'haproxy'
$metering_agent_package = 'openstack-neutron-metering-agent'
@ -147,6 +150,9 @@ class neutron::params {
$lbaas_agent_package = 'neutron-lbaas-agent'
$lbaas_agent_service = 'neutron-lbaas-agent'
$lbaasv2_agent_package = 'neutron-lbaasv2-agent'
$lbaasv2_agent_service = 'neutron-lbaasv2-agent'
$haproxy_package = 'haproxy'
$metering_agent_package = 'neutron-metering-agent'

View File

@ -358,6 +358,7 @@ class neutron::server (
Neutron_config<||> ~> Service['neutron-server']
Neutron_api_config<||> ~> Service['neutron-server']
Neutron_lbaas_service_config<||> ~> Service['neutron-server']
Class['neutron::policy'] ~> Service['neutron-server']
Neutron_config<||> -> Neutron_network<||>
@ -419,6 +420,7 @@ class neutron::server (
if ($::neutron::params::server_package) {
Package['neutron-server'] -> Neutron_api_config<||>
Package['neutron-server'] -> Neutron_config<||>
Package['neutron-server'] -> Neutron_lbaas_service_config<||>
Package['neutron-server'] -> Service['neutron-server']
Package['neutron-server'] -> Class['neutron::policy']
package { 'neutron-server':

View File

@ -22,10 +22,6 @@
#
# === Parameters:
#
# [*package_ensure*]
# (required) Whether or not to install the LBaaS Neutron plugin package
# present
#
# [*service_providers*]
# (optional) Array of allowed service types or '<SERVICE DEFAULT>'.
# Note: The default upstream value is empty.
@ -35,24 +31,34 @@
# Must be in form <service_type>:<name>:<driver>[:default].
# Defaults to $::os_service_default
#
# === Deprecated Parameters
#
# [*package_ensure*]
# (optional) Deprecated. Used to install the lbaas v2 agent. This was moved into
# neutron::agents::lbaas as the lbaas services handles scheduling of new load balancers
# Defaults to false
#
class neutron::services::lbaas (
$package_ensure = 'present',
$package_ensure = false,
$service_providers = $::os_service_default,
) {
include ::neutron::params
# agent package contains both agent and service resources
ensure_resource( 'package', 'neutron-lbaas-agent', {
ensure => $package_ensure,
name => $::neutron::params::lbaas_agent_package,
tag => ['openstack', 'neutron-package'],
})
if $package_ensure {
warning('Package ensure is deprecated. The neutron::agents::lbaas class should be used to install the agent')
# agent package contains both agent and service resources
ensure_resource( 'package', 'neutron-lbaas-agent', {
ensure => $package_ensure,
name => $::neutron::params::lbaas_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_lbaas_service_config { 'service_providers/service_provider':
value => $service_providers,
}
Package<| tag == 'neutron-package' |> -> Neutron_lbaas_service_config<||>
}
}

View File

@ -0,0 +1,68 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.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::lbaas::haproxy
#
# Configure the haproxy LBaaS service provider
#
# === Parameters:
#
# [*interface_driver*]
# (optional) The driver to manage the virtual interface
# Defaults to $::os_service_default
#
# [*periodic_interval*]
# (optional) Seconds between periodic task runs
# Defaults to $::os_service_default
#
# [*loadbalancer_state_path*]
# (optional) Location to store config and state files
# Defaults to $::os_service_default
#
# [*user_group*]
# (optional) The user/group to run haproxy.
# Defaults to $::os_service_default
#
# [*send_gratuitous_arp*]
# (optional) Send gratuitous arps to flush the arp cache
# when VIP is deleted and re-added.
# Defaults to $::os_service_default
#
# [*jinja_config_template*]
# (optional) The template location to be used for haproxy.
# Defaults to $::os_service_default
#
#
class neutron::services::lbaas::haproxy(
$interface_driver = $::os_service_default,
$periodic_interval = $::os_service_default,
$loadbalancer_state_path = $::os_service_default,
$user_group = $::os_service_default,
$send_gratuitous_arp = $::os_service_default,
$jinja_config_template = $::os_service_default
) {
neutron_config {
'haproxy/interface_driver': value => $interface_driver;
'haproxy/periodic_interval': value => $periodic_interval;
'haproxy/loadbalancer_state_path': value => $loadbalancer_state_path;
'haproxy/user_group': value => $user_group;
'haproxy/send_gratuitous_arp': value => $send_gratuitous_arp;
'haproxy/jinja_config_template': value => $jinja_config_template;
}
}

View File

@ -0,0 +1,57 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.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::lbaas::octavia
#
# Configure the Octavia LBaaS service provider
#
# === Parameters:
#
# [*base_url*]
# (optional) The url endpoint for Octavia.
# Defaults to 'https://127.0.0.1:9876'
#
# [*request_poll_interval*]
# (optional) Interval in sections to poll octavia when
# entity is created, updated, or deleted
# Defaults to $::os_service_default
#
# [*request_poll_timeout*]
# (optional) Time to stop polling octavia when status
# of an entity does not change.
# Defaults to $::os_service_default
#
# [*allocates_vip*]
# (optional) Whether Octavia is responsible for allocating
# the VIP.
# Defaults to $::os_service_default
#
class neutron::services::lbaas::octavia(
$base_url = 'http://127.0.0.1:9876',
$request_poll_interval = $::os_service_default,
$request_poll_timeout = $::os_service_default,
$allocates_vip = $::os_service_default
) {
neutron_config {
'octavia/base_url': value => $base_url;
'octavia/request_poll_interval': value => $request_poll_interval;
'octavia/request_poll_timeout': value => $request_poll_timeout;
'octavia/allocates_vip': value => $allocates_vip;
}
}

View File

@ -0,0 +1,9 @@
---
features:
- Added octavia lbaas v2 services class.
- Added haproxy lbaas v2 services class.
- Added option to use either v1 or v2 agent in neutron agents lbaas.
deprecations:
- The lbaas v2 agent package ensure in neutron services lbaas
has been deprecated, the agent should be installed from
neutron agents lbaas.

View File

@ -76,6 +76,8 @@ describe 'basic neutron' do
class { '::neutron::services::lbaas':
service_providers => 'LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default',
}
class { '::neutron::services::lbaas::haproxy': }
class { '::neutron::services::lbaas::octavia': }
EOS

View File

@ -576,8 +576,7 @@ describe 'basic neutron_config resource' do
'/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',
'/etc/neutron/neutron_lbaas.conf']
'/etc/neutron/plugins/ml2/sriov_agent.ini']
$neutron_files.each do |neutron_conf_file|
describe file(neutron_conf_file) do
@ -592,7 +591,7 @@ describe 'basic neutron_config resource' do
end
end
describe file('/etc/neutron/neutron_lbaas.conf') do
describe file('/etc/neutron/neutron.conf') do
it { is_expected.to contain('thisshouldexist3=value1') }
it { is_expected.to contain('thisshouldexist3=value2') }
end

View File

@ -0,0 +1,63 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.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.
#
# Unit tests for neutron::services::lbaas::haproxy class
#
require 'spec_helper'
describe 'neutron::services::lbaas::haproxy' do
let :default_params do
{ :interface_driver => '<SERVICE_DEFAULT>',
:periodic_interval => '<SERVICE_DEFAULT>',
:loadbalancer_state_path => '<SERVICE_DEFAULT>',
:user_group => '<SERVICE_DEFAULT>',
:send_gratuitous_arp => '<SERVICE_DEFAULT>',
:jinja_config_template => '<SERVICE_DEFAULT>'}
end
context 'with default params' do
let :params do
default_params
end
it 'configures haproxy service plugin' do
is_expected.to contain_neutron_config('haproxy/interface_driver').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('haproxy/periodic_interval').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('haproxy/loadbalancer_state_path').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('haproxy/user_group').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('haproxy/send_gratuitous_arp').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('haproxy/jinja_config_template').with_value('<SERVICE_DEFAULT>')
end
end
context 'when interface driver and gratuitous arp is set' do
let :params do
default_params.merge(
{ :interface_driver => 'neutron.agent.linux.interface.OVSInterfaceDriver',
:send_gratuitous_arp => true,
}
)
end
it 'configures haproxy service plugin custom parameters' do
is_expected.to contain_neutron_config('haproxy/interface_driver').with_value('neutron.agent.linux.interface.OVSInterfaceDriver')
is_expected.to contain_neutron_config('haproxy/send_gratuitous_arp').with_value(true)
end
end
end

View File

@ -0,0 +1,63 @@
#
# Copyright (C) 2016 Matthew J. Black
#
# Author: Matthew J. Black <mjblack@gmail.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.
#
# Unit tests for neutron::services::lbaas::octavia class
#
require 'spec_helper'
describe 'neutron::services::lbaas::octavia' do
let :default_params do
{ :base_url => 'http://127.0.0.1:9876',
:request_poll_interval => '<SERVICE_DEFAULT>',
:request_poll_timeout => '<SERVICE_DEFAULT>',
:allocates_vip => '<SERVICE_DEFAULT>'}
end
context 'with default params' do
let :params do
default_params
end
it 'configures octavia service plugin' do
is_expected.to contain_neutron_config('octavia/base_url').with_value('http://127.0.0.1:9876')
is_expected.to contain_neutron_config('octavia/request_poll_interval').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('octavia/request_poll_timeout').with_value('<SERVICE_DEFAULT>')
is_expected.to contain_neutron_config('octavia/allocates_vip').with_value('<SERVICE_DEFAULT>')
end
end
context 'when base_url is set' do
let :params do
default_params.merge(
{ :base_url => 'http://octavia.example.org:9876',
:request_poll_interval => '3',
:request_poll_timeout => '100',
:allocates_vip => 'false'
}
)
end
it 'configures octavia service plugin custom parameters' do
is_expected.to contain_neutron_config('octavia/base_url').with_value('http://octavia.example.org:9876')
is_expected.to contain_neutron_config('octavia/request_poll_interval').with_value('3')
is_expected.to contain_neutron_config('octavia/request_poll_timeout').with_value('100')
is_expected.to contain_neutron_config('octavia/allocates_vip').with_value('false')
end
end
end

View File

@ -23,8 +23,7 @@ require 'spec_helper'
describe 'neutron::services::lbaas' do
let :default_params do
{ :package_ensure => 'present',
:service_providers => '<SERVICE_DEFAULT>'}
{ :service_providers => '<SERVICE_DEFAULT>'}
end
shared_examples_for 'neutron lbaas service plugin' do
@ -33,13 +32,6 @@ describe 'neutron::services::lbaas' do
let :params do
default_params
end
it 'installs lbaas package' do
is_expected.to contain_package('neutron-lbaas-agent').with(
:ensure => params[:package_ensure],
:name => platform_params[:lbaas_package_name],
)
end
end
context 'with multiple service providers' do
@ -49,13 +41,12 @@ describe 'neutron::services::lbaas' do
)
end
it 'configures neutron_lbaas.conf' do
it 'configures neutron.conf' do
is_expected.to contain_neutron_lbaas_service_config(
'service_providers/service_provider'
).with_value(['provider1', 'provider2'])
end
end
end
context 'on Debian platforms' do
@ -66,7 +57,7 @@ describe 'neutron::services::lbaas' do
end
let :platform_params do
{ :lbaas_package_name => 'neutron-lbaas-agent'}
{}
end
it_configures 'neutron lbaas service plugin'
@ -81,10 +72,9 @@ describe 'neutron::services::lbaas' do
end
let :platform_params do
{ :lbaas_package_name => 'openstack-neutron-lbaas'}
{}
end
it_configures 'neutron lbaas service plugin'
end
end