Add support for l2 Gateway
Introduce puppet classes to configure networking-l2gw agent service Introduce puppet classes to configure networking-l2gw plugin Implements: blueprint l2gw-service-integration Change-Id: I1082cbf9665ed9fbb441705a5e2b2aa97aae5d6f Signed-off-by: Peng Liu <pliu@redhat.com>
This commit is contained in:
parent
34b479d5c5
commit
d564aee3ac
15
lib/puppet/provider/neutron_l2gw_agent_config/ini_setting.rb
Normal file
15
lib/puppet/provider/neutron_l2gw_agent_config/ini_setting.rb
Normal file
@ -0,0 +1,15 @@
|
||||
Puppet::Type.type(:neutron_l2gw_agent_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
) do
|
||||
|
||||
def self.file_path
|
||||
'/etc/neutron/l2gateway_agent.ini'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
Puppet::Type.type(:neutron_l2gw_service_config).provide(
|
||||
:openstackconfig,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
|
||||
) do
|
||||
|
||||
def self.file_path
|
||||
'/etc/neutron/l2gw_plugin.ini'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
28
lib/puppet/type/neutron_l2gw_agent_config.rb
Normal file
28
lib/puppet/type/neutron_l2gw_agent_config.rb
Normal file
@ -0,0 +1,28 @@
|
||||
Puppet::Type.newtype(:neutron_l2gw_agent_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from l2 gateway agent config.'
|
||||
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(: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-l2gw-agent']
|
||||
end
|
||||
|
||||
end
|
38
lib/puppet/type/neutron_l2gw_service_config.rb
Normal file
38
lib/puppet/type/neutron_l2gw_service_config.rb
Normal file
@ -0,0 +1,38 @@
|
||||
Puppet::Type.newtype(:neutron_l2gw_service_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from l2gw_plugin.ini'
|
||||
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-l2gw']
|
||||
end
|
||||
|
||||
end
|
130
manifests/agents/l2gw.pp
Normal file
130
manifests/agents/l2gw.pp
Normal file
@ -0,0 +1,130 @@
|
||||
# == Class: neutron::agents::l2gw
|
||||
#
|
||||
# Installs and configures the Neutron L2gw service
|
||||
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (optional) The state of the package
|
||||
# Defaults to present
|
||||
#
|
||||
# [*enabled*]
|
||||
# (optional) The state of the service
|
||||
# Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether to start/stop the service
|
||||
# Defaults to true
|
||||
#
|
||||
# [*debug*]
|
||||
# (optional) Print debug info in logs
|
||||
# Defaults to false
|
||||
#
|
||||
# [*ovsdb_hosts*]
|
||||
# (optional) OVSDB server tuples in the format
|
||||
# Example: ovsdb_hosts = 'ovsdb1:16.95.16.1:6632,ovsdb2:16.95.16.2:6632'
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*enable_manager*]
|
||||
# (optional) connection can be initiated by the ovsdb server.
|
||||
# Defaults to false
|
||||
#
|
||||
# [*manager_table_listening_port*]
|
||||
# (optional) set port number for l2gateway agent, so that it can listen
|
||||
# Defaults to '6632'
|
||||
#
|
||||
# [*l2_gw_agent_priv_key_base_path*]
|
||||
# (optional) Base path to private key file(s).
|
||||
# Example: l2_gw_agent_priv_key_base_path = '/home/someuser/keys'
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*l2_gw_agent_cert_base_path*]
|
||||
# (optional) Base path to cert file(s).
|
||||
# Example: l2_gw_agent_cert_base_path = '/home/someuser/certs'
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*l2_gw_agent_ca_cert_base_path*]
|
||||
# (optional) Base path to ca cert file(s).
|
||||
# Example: l2_gw_agent_ca_cert_base_path = '/home/someuser/ca_certs'
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*periodic_interval*]
|
||||
# (optional) The L2 gateway agent checks connection state with the OVSDB
|
||||
# servers. The interval is number of seconds between attempts.
|
||||
# Example: periodic_interval = 20
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*max_connection_retries*]
|
||||
# (optional) The L2 gateway agent retries to connect to the OVSDB server
|
||||
# Example: max_connection_retries = 10
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*socket_timeout*]
|
||||
# (optional) socket timeout
|
||||
# Defaults to '30'
|
||||
#
|
||||
# [*purge_config*]
|
||||
# (optional) Whether to set only the specified config options
|
||||
# in the l2gateway config.
|
||||
# Default to false.
|
||||
#
|
||||
class neutron::agents::l2gw (
|
||||
$package_ensure = 'present',
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$debug = false,
|
||||
$ovsdb_hosts = $::os_service_default,
|
||||
$enable_manager = false,
|
||||
$manager_table_listening_port = '6632',
|
||||
$l2_gw_agent_priv_key_base_path = $::os_service_default,
|
||||
$l2_gw_agent_cert_base_path = $::os_service_default,
|
||||
$l2_gw_agent_ca_cert_base_path = $::os_service_default,
|
||||
$periodic_interval = $::os_service_default,
|
||||
$max_connection_retries = $::os_service_default,
|
||||
$socket_timeout = '30',
|
||||
$purge_config = false,
|
||||
) {
|
||||
|
||||
include ::neutron::deps
|
||||
include ::neutron::params
|
||||
|
||||
resources { 'neutron_l2gw_agent_config':
|
||||
purge => $purge_config,
|
||||
}
|
||||
|
||||
neutron_l2gw_agent_config {
|
||||
'DEFAULT/debug': value => $debug;
|
||||
'ovsdb/ovsdb_hosts': value => join(any2array($ovsdb_hosts), ',');
|
||||
'ovsdb/enable_manager': value => $enable_manager;
|
||||
'ovsdb/manager_table_listening_port': value => $manager_table_listening_port;
|
||||
'ovsdb/l2_gw_agent_priv_key_base_path': value => $l2_gw_agent_priv_key_base_path;
|
||||
'ovsdb/l2_gw_agent_cert_base_path': value => $l2_gw_agent_cert_base_path;
|
||||
'ovsdb/l2_gw_agent_ca_cert_base_path': value => $l2_gw_agent_ca_cert_base_path;
|
||||
'ovsdb/max_connection_retries': value => $max_connection_retries;
|
||||
'ovsdb/socket_timeout': value => $socket_timeout;
|
||||
'ovsdb/periodic_interval': value => $periodic_interval;
|
||||
}
|
||||
|
||||
if $::neutron::params::l2gw_agent_package {
|
||||
package { 'neutron-l2gw-agent':
|
||||
ensure => $package_ensure,
|
||||
name => $::neutron::params::l2gw_agent_package,
|
||||
tag => ['openstack', 'neutron-package'],
|
||||
}
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
service { 'neutron-l2gw-agent':
|
||||
ensure => $service_ensure,
|
||||
name => $::neutron::params::l2gw_agent_service,
|
||||
enable => $enabled,
|
||||
tag => 'neutron-service',
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,12 @@
|
||||
# [*bgpvpn_service_config*]
|
||||
# (optional) Manage configuration of networking_bgpvpn.conf
|
||||
#
|
||||
# [*l2gw_agent_config*]
|
||||
# (optional) Manage configuration of l2gateway_agent.ini
|
||||
#
|
||||
# [*l2gw_service_config*]
|
||||
# (optional) Manage configuration of l2gw_plugin.ini
|
||||
#
|
||||
# [*l3_agent_config*]
|
||||
# (optional) Manage configuration of l3_agent.ini
|
||||
#
|
||||
@ -85,6 +91,8 @@ class neutron::config (
|
||||
$server_config = {},
|
||||
$api_config = {},
|
||||
$bgpvpn_service_config = {},
|
||||
$l2gw_agent_config = {},
|
||||
$l2gw_service_config = {},
|
||||
$l3_agent_config = {},
|
||||
$dhcp_agent_config = {},
|
||||
$lbaas_agent_config = {},
|
||||
@ -108,6 +116,8 @@ class neutron::config (
|
||||
validate_hash($server_config)
|
||||
validate_hash($api_config)
|
||||
validate_hash($bgpvpn_service_config)
|
||||
validate_hash($l2gw_agent_config)
|
||||
validate_hash($l2gw_service_config)
|
||||
validate_hash($l3_agent_config)
|
||||
validate_hash($dhcp_agent_config)
|
||||
validate_hash($lbaas_agent_config)
|
||||
@ -128,6 +138,7 @@ class neutron::config (
|
||||
create_resources('neutron_config', $server_config)
|
||||
create_resources('neutron_api_config', $api_config)
|
||||
create_resources('neutron_bgpvpn_service_config', $bgpvpn_service_config)
|
||||
create_resources('neutron_l2gw_agent_config', $l2gw_agent_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)
|
||||
@ -143,4 +154,5 @@ class neutron::config (
|
||||
create_resources('neutron_plugin_opencontrail', $plugin_opencontrail_config)
|
||||
create_resources('neutron_plugin_nuage', $plugin_nuage_config)
|
||||
create_resources('neutron_plugin_ml2', $plugin_ml2_config)
|
||||
create_resources('neutron_l2gw_service_config', $l2gw_service_config)
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class neutron::deps {
|
||||
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']
|
||||
Anchor['neutron::config::begin'] -> Neutron_l2gw_agent_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_l3_agent_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_lbaas_agent_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_lbaas_service_config<||> ~> Anchor['neutron::config::end']
|
||||
@ -53,6 +54,7 @@ class neutron::deps {
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_cisco<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_cisco_l2network<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_linuxbridge<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_l2gw_service_config<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_midonet<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_ml2<||> ~> Anchor['neutron::config::end']
|
||||
Anchor['neutron::config::begin'] -> Neutron_plugin_nuage<||> ~> Anchor['neutron::config::end']
|
||||
|
@ -30,6 +30,7 @@ class neutron::params {
|
||||
$l3_agent_service = 'neutron-l3-agent'
|
||||
$metadata_agent_service = 'neutron-metadata-agent'
|
||||
$bgpvpn_plugin_package = 'python-networking-bgpvpn'
|
||||
$l2gw_agent_service = 'neutron-l2gw-agent'
|
||||
|
||||
if($::osfamily == 'Redhat') {
|
||||
$nobody_user_group = 'nobody'
|
||||
@ -55,6 +56,8 @@ class neutron::params {
|
||||
$lbaasv2_agent_package = 'openstack-neutron-lbaas'
|
||||
$metering_agent_package = 'openstack-neutron-metering-agent'
|
||||
$vpnaas_agent_package = 'openstack-neutron-vpnaas'
|
||||
$l2gw_agent_package = 'openstack-neutron-l2gw-agent'
|
||||
$l2gw_package = 'python2-networking-l2gw'
|
||||
if $::operatingsystemrelease =~ /^7.*/ or $::operatingsystem == 'Fedora' {
|
||||
$openswan_package = 'libreswan'
|
||||
} else {
|
||||
@ -92,6 +95,8 @@ class neutron::params {
|
||||
$metadata_agent_package = 'neutron-metadata-agent'
|
||||
$l3_agent_package = 'neutron-l3-agent'
|
||||
$fwaas_package = 'python-neutron-fwaas'
|
||||
$l2gw_agent_package = 'neutron-l2gw-agent'
|
||||
$l2gw_package = 'python-networking-l2gw'
|
||||
} else {
|
||||
fail("Unsupported osfamily ${::osfamily}")
|
||||
}
|
||||
|
74
manifests/services/l2gw.pp
Normal file
74
manifests/services/l2gw.pp
Normal file
@ -0,0 +1,74 @@
|
||||
# This class installs and configures l2gw Neutron Plugin.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*default_interface_name*]
|
||||
# (optional) default interface name of the l2 gateway
|
||||
# Defaults to $::os_service_default
|
||||
# Example: FortyGigE1/0/1
|
||||
#
|
||||
# [*default_device_name*]
|
||||
# (optional) default device name of the l2 gateway
|
||||
# Defaults to $::os_service_default
|
||||
# Example: Switch1
|
||||
#
|
||||
# [*quota_l2_gateway*]
|
||||
# (optional) quota of the l2 gateway
|
||||
# Defaults to $::os_service_default
|
||||
# Example: 10
|
||||
#
|
||||
# [*periodic_monitoring_interval*]
|
||||
# (optional) The periodic interval at which the plugin
|
||||
# checks for the monitoring L2 gateway agent
|
||||
# Defaults to $::os_service_default
|
||||
# Example: 5
|
||||
#
|
||||
# [*service_providers*]
|
||||
# (optional) Array of allowed service types includes L2GW
|
||||
# Must be in form: <service_type>:<name>:<driver>[:default]
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (optional) Ensure state for package.
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*purge_config*]
|
||||
# (optional) Whether to set only the specified config options
|
||||
# in the l2gw config.
|
||||
# Defaults to false.
|
||||
#
|
||||
class neutron::services::l2gw (
|
||||
$default_interface_name = $::os_service_default,
|
||||
$default_device_name = $::os_service_default,
|
||||
$quota_l2_gateway = $::os_service_default,
|
||||
$periodic_monitoring_interval = $::os_service_default,
|
||||
$service_providers = $::os_service_default,
|
||||
$package_ensure = 'present',
|
||||
$purge_config = false,
|
||||
) {
|
||||
|
||||
include ::neutron::deps
|
||||
include ::neutron::params
|
||||
|
||||
if !is_service_default($service_providers) {
|
||||
validate_array($service_providers)
|
||||
}
|
||||
|
||||
ensure_resource( 'package', 'python-networking-l2gw', {
|
||||
'ensure' => $package_ensure,
|
||||
'name' => $::neutron::params::l2gw_package,
|
||||
'tag' => ['neutron-package', 'openstack'],
|
||||
})
|
||||
|
||||
resources { 'neutron_l2gw_service_config':
|
||||
purge => $purge_config,
|
||||
}
|
||||
|
||||
neutron_l2gw_service_config {
|
||||
'DEFAULT/default_interface_name': value => $default_interface_name;
|
||||
'DEFAULT/default_device_name': value => $default_device_name;
|
||||
'DEFAULT/quota_l2_gateway': value => $quota_l2_gateway;
|
||||
'DEFAULT/periodic_monitoring_interval': value => $periodic_monitoring_interval;
|
||||
'service_providers/service_provider': value => $service_providers;
|
||||
}
|
||||
}
|
7
releasenotes/notes/l2gw-support-e05b68b2d8b6142c.yaml
Normal file
7
releasenotes/notes/l2gw-support-e05b68b2d8b6142c.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
prelude: >
|
||||
L2 Gateway (L2GW) is an API framework for OpenStack that offers bridging
|
||||
two or more networks together to make them look at a single broadcast domain.
|
||||
A typical use case is bridging the virtual with the physical networks
|
||||
features:
|
||||
- Add support to deploy l2gw plugin and agent in Neutron.
|
@ -10,6 +10,8 @@ describe 'basic neutron_config resource' do
|
||||
'/etc/neutron/lbaas_agent.ini',
|
||||
'/etc/neutron/metadata_agent.ini',
|
||||
'/etc/neutron/metering_agent.ini',
|
||||
'/etc/neutron/l2gw_plugin.ini',
|
||||
'/etc/neutron/l2gateway_agent.ini',
|
||||
'/etc/neutron/plugins/cisco/cisco_plugins.ini',
|
||||
'/etc/neutron/plugins/cisco/credentials.ini',
|
||||
'/etc/neutron/plugins/cisco/db_conn.ini',
|
||||
@ -43,6 +45,7 @@ describe 'basic neutron_config resource' do
|
||||
File <||> -> Neutron_plugin_linuxbridge <||>
|
||||
File <||> -> Neutron_plugin_ml2 <||>
|
||||
File <||> -> Neutron_plugin_nvp <||>
|
||||
File <||> -> Neutron_l2gw_service_config <||>
|
||||
File <||> -> Neutron_vpnaas_agent_config <||>
|
||||
File <||> -> Neutron_plugin_midonet <||>
|
||||
File <||> -> Neutron_plugin_opencontrail <||>
|
||||
@ -53,6 +56,7 @@ describe 'basic neutron_config resource' do
|
||||
File <||> -> Neutron_plugin_sriov <||>
|
||||
File <||> -> Neutron_sriov_agent_config <||>
|
||||
File <||> -> Neutron_agent_vpp <||>
|
||||
File <||> -> Neutron_l2gw_agent_config <||>
|
||||
|
||||
|
||||
$neutron_directories = ['/etc/neutron',
|
||||
@ -73,6 +77,8 @@ describe 'basic neutron_config resource' do
|
||||
'/etc/neutron/lbaas_agent.ini',
|
||||
'/etc/neutron/metadata_agent.ini',
|
||||
'/etc/neutron/metering_agent.ini',
|
||||
'/etc/neutron/l2gw_plugin.ini',
|
||||
'/etc/neutron/l2gateway_agent.ini',
|
||||
'/etc/neutron/plugins/cisco/cisco_plugins.ini',
|
||||
'/etc/neutron/plugins/cisco/credentials.ini',
|
||||
'/etc/neutron/plugins/cisco/db_conn.ini',
|
||||
@ -544,6 +550,41 @@ describe 'basic neutron_config resource' do
|
||||
ensure_absent_val => 'toto',
|
||||
}
|
||||
|
||||
neutron_l2gw_service_config { 'DEFAULT/thisshouldexist' :
|
||||
value => 'foo',
|
||||
}
|
||||
|
||||
neutron_l2gw_service_config { 'DEFAULT/thisshouldnotexist' :
|
||||
value => '<SERVICE DEFAULT>',
|
||||
}
|
||||
|
||||
neutron_l2gw_service_config { 'DEFAULT/thisshouldexist2' :
|
||||
value => '<SERVICE DEFAULT>',
|
||||
ensure_absent_val => 'toto',
|
||||
}
|
||||
|
||||
neutron_l2gw_service_config { 'DEFAULT/thisshouldnotexist2' :
|
||||
value => 'toto',
|
||||
ensure_absent_val => 'toto',
|
||||
}
|
||||
|
||||
neutron_l2gw_agent_config { 'DEFAULT/thisshouldexist' :
|
||||
value => 'foo',
|
||||
}
|
||||
|
||||
neutron_l2gw_agent_config { 'DEFAULT/thisshouldnotexist' :
|
||||
value => '<SERVICE DEFAULT>',
|
||||
}
|
||||
|
||||
neutron_l2gw_agent_config { 'DEFAULT/thisshouldexist2' :
|
||||
value => '<SERVICE DEFAULT>',
|
||||
ensure_absent_val => 'toto',
|
||||
}
|
||||
|
||||
neutron_l2gw_agent_config { 'DEFAULT/thisshouldnotexist2' :
|
||||
value => 'toto',
|
||||
ensure_absent_val => 'toto',
|
||||
}
|
||||
|
||||
EOS
|
||||
|
||||
@ -570,7 +611,9 @@ describe 'basic neutron_config resource' do
|
||||
'neutron_plugin_plumgrid',
|
||||
'neutron_plugin_sriov',
|
||||
'neutron_sriov_agent_config',
|
||||
'neutron_agent_vpp']
|
||||
'neutron_agent_vpp',
|
||||
'neutron_l2gw_service_config',
|
||||
'neutron_l2gw_agent_config']
|
||||
|
||||
pp_resource_names = " $resource_names = [" + resource_names.collect { |r| " '#{r}'," }.join("\n") + " ]\n"
|
||||
|
||||
|
112
spec/classes/neutron_agents_l2gw_spec.rb
Normal file
112
spec/classes/neutron_agents_l2gw_spec.rb
Normal file
@ -0,0 +1,112 @@
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# Author: Peng Liu <pliu@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::agents::l2gw' do
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:purge_config => false,
|
||||
:enabled => true,
|
||||
:manage_service => true,
|
||||
:debug => false,
|
||||
:enable_manager => false,
|
||||
:manager_table_listening_port => '6632',
|
||||
:socket_timeout => '30',
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
let :test_facts do
|
||||
{ :operatingsystem => 'default',
|
||||
:operatingsystemrelease => 'default'
|
||||
}
|
||||
end
|
||||
shared_examples_for 'neutron l2 gateway agent' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it 'passes purge to resource' do
|
||||
is_expected.to contain_resources('neutron_l2gw_agent_config').with({
|
||||
:purge => false
|
||||
})
|
||||
end
|
||||
|
||||
it 'installs l2gw agent package' do
|
||||
is_expected.to contain_package('neutron-l2gw-agent').with(
|
||||
:ensure => p[:package_ensure],
|
||||
:name => platform_params[:l2gw_agent_package_name],
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures l2gw_plugin.ini' do
|
||||
is_expected.to contain_neutron_l2gw_agent_config('DEFAULT/debug').with_value(p[:debug])
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/enable_manager').with_value(p[:enable_manager])
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/manager_table_listening_port').with_value(p[:manager_table_listening_port])
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/l2_gw_agent_priv_key_base_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/l2_gw_agent_cert_base_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/l2_gw_agent_ca_cert_base_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/periodic_interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/max_connection_retries').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/socket_timeout').with_value(p[:socket_timeout])
|
||||
is_expected.to contain_neutron_l2gw_agent_config('ovsdb/ovsdb_hosts').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
it 'l2 agent service running' do
|
||||
is_expected.to contain_service('neutron-l2gw-agent').with_ensure('running')
|
||||
end
|
||||
|
||||
context 'with multiple ovsdb_hosts' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
{ :ovsdb_hosts => ['host1', 'host2'] }
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures multiple ovsdb_hosts in l2gateway_agent.ini' do
|
||||
is_expected.to contain_neutron_l2gw_agent_config(
|
||||
'ovsdb/ovsdb_hosts'
|
||||
).with_value(p[:ovsdb_hosts].join(','))
|
||||
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'
|
||||
{ :l2gw_agent_package_name => 'openstack-neutron-l2gw-agent' }
|
||||
when 'Debian'
|
||||
{ :l2gw_agent_package_name => 'neutron-l2gw-agent' }
|
||||
end
|
||||
end
|
||||
|
||||
it_configures 'neutron l2 gateway agent'
|
||||
end
|
||||
end
|
||||
end
|
109
spec/classes/neutron_services_l2gw_spec.rb
Normal file
109
spec/classes/neutron_services_l2gw_spec.rb
Normal file
@ -0,0 +1,109 @@
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# Author: Peng Liu <pliu@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::l2gw' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { '::neutron::keystone::authtoken':
|
||||
password => 'passw0rd',
|
||||
}
|
||||
class { 'neutron::server': }
|
||||
class { 'neutron': rabbit_password => 'passw0rd' }"
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{ :package_ensure => 'present',
|
||||
:purge_config => false,
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :default_interface_name => 'foo'}
|
||||
end
|
||||
|
||||
let :test_facts do
|
||||
{ :operatingsystem => 'default',
|
||||
:operatingsystemrelease => 'default'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'neutron l2gw service plugin' do
|
||||
let :p do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it 'passes purge to resource' do
|
||||
is_expected.to contain_resources('neutron_l2gw_service_config').with({
|
||||
:purge => false
|
||||
})
|
||||
end
|
||||
|
||||
it 'should contain python-networking-l2gw package' do
|
||||
is_expected.to contain_package('python-networking-l2gw').with({ :ensure => 'present' })
|
||||
end
|
||||
|
||||
it 'services_provider with default parameter' do
|
||||
is_expected.to contain_neutron_l2gw_service_config('service_providers/service_provider').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
it 'configures l2gw_plugin.ini' do
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_interface_name').with_value(p[:default_interface_name])
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/default_device_name').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/quota_l2_gateway').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_service_config('DEFAULT/periodic_monitoring_interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_neutron_l2gw_service_config('service_providers/service_provider').with_value('<SERVICE DEFAULT>')
|
||||
|
||||
end
|
||||
|
||||
context 'with multiple service providers' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
{ :service_providers => ['provider1', 'provider2'] }
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures multiple service providers in l2gw_plugin.ini' do
|
||||
is_expected.to contain_neutron_l2gw_service_config(
|
||||
'service_providers/service_provider'
|
||||
).with_value(['provider1', 'provider2'])
|
||||
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'
|
||||
{ :l2gw_agent_package_name => 'python2-networking-l2gw' }
|
||||
when 'Debian'
|
||||
{ :l2gw_agent_package_name => 'python-networking-l2gw' }
|
||||
end
|
||||
end
|
||||
|
||||
it_configures 'neutron l2gw 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_l2gw_agent_config).provider(:ini_setting)
|
||||
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
||||
resource = Puppet::Type::Neutron_l2gw_agent_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/l2gateway_agent.ini')
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Neutron_l2gw_agent_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/l2gateway_agent.ini')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Neutron_l2gw_agent_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_l2gw_agent_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
|
@ -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_l2gw_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_l2gw_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/l2gw_plugin.ini')
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Neutron_l2gw_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/l2gw_plugin.ini')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Neutron_l2gw_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_l2gw_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_l2gw_agent_config_spec.rb
Normal file
20
spec/unit/type/neutron_l2gw_agent_config_spec.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/neutron_l2gw_agent_config'
|
||||
|
||||
describe 'Puppet::Type.type(:neutron_l2gw_agent_config)' do
|
||||
|
||||
before :each do
|
||||
@neutron_l2gw_agent_config = Puppet::Type.type(:neutron_l2gw_agent_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 => 'neutron-l2gw-agent')
|
||||
catalog.add_resource package, @neutron_l2gw_agent_config
|
||||
dependency = @neutron_l2gw_agent_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@neutron_l2gw_agent_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
20
spec/unit/type/neutron_l2gw_service_config_spec.rb
Normal file
20
spec/unit/type/neutron_l2gw_service_config_spec.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/neutron_l2gw_service_config'
|
||||
|
||||
describe 'Puppet::Type.type(:nova_plugin_l2gw)' do
|
||||
|
||||
before :each do
|
||||
@neutron_l2gw_service_config = Puppet::Type.type(:neutron_l2gw_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-l2gw')
|
||||
catalog.add_resource package, @neutron_l2gw_service_config
|
||||
dependency = @neutron_l2gw_service_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@neutron_l2gw_service_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user