Merge pull request #619 from enovance/neutron-refacto

Refactor all Neutron configuration to be more flexible and support different backends
This commit is contained in:
Yanis Guenane 2014-09-19 09:37:43 -04:00
commit 8481286a93
17 changed files with 269 additions and 472 deletions

View File

@ -53,6 +53,7 @@ class cloud::compute::hypervisor(
include 'cloud::compute'
include 'cloud::telemetry'
include 'cloud::network'
include 'cloud::network::vswitch'
if $libvirt_type == 'kvm' and ! $::vtx {
fail('libvirt_type is set to KVM and VTX seems to be disabled on this node.')

View File

@ -36,16 +36,14 @@
# Defaults to true
#
# [*tunnel_eth*]
# (optional) Which interface we connect to create overlay tunnels.
# Defaults to '127.0.0.1'
# Deprecated.
#
# [*provider_vlan_ranges*]
# (optionnal) VLAN range for provider networks
# Defaults to ['physnet1:1000:2999']
#
# [*provider_bridge_mappings*]
# (optionnal) Bridge mapping for provider networks
# Defaults to ['physnet1:br-eth1']
# Deprecated.
#
# [*flat_networks*]
# (optionnal) List of physical_network names with which flat networks
@ -55,16 +53,13 @@
# Default to ['public'].
#
# [*external_int*]
# (optionnal) Network interface to bind the external provider network
# Defaults to 'eth1'.
# Deprecated.
#
# [*external_bridge*]
# (optionnal) OVS bridge used to bind external provider network
# Defaults to 'br-pub'.
# Deprecated.
#
# [*manage_ext_network*]
# (optionnal) Manage or not external network with provider network API
# Defaults to false.
# Deprecated.
#
# [*use_syslog*]
# (optional) Use syslog for logging
@ -79,9 +74,7 @@
# Defaults to '120'
#
# [*tunnel_types*]
# (optional) Handled tunnel types
# Defaults to ['gre']
# Possible value ['local', 'flat', 'vlan', 'gre', 'vxlan']
# Deprecated.
#
# [*tenant_network_types*]
# (optional) Handled tenant network types
@ -93,28 +86,39 @@
# Defaults to ['gre', 'vlan', 'flat']
# Possible value ['local', 'flat', 'vlan', 'gre', 'vxlan']
#
# [*ml2_enabled*]
# (optional) Enable or not ML2 plugin
# Defaults to true
#
class cloud::network(
$verbose = true,
$debug = true,
$rabbit_hosts = ['127.0.0.1:5672'],
$rabbit_password = 'rabbitpassword',
$tunnel_eth = '127.0.0.1',
$api_eth = '127.0.0.1',
$provider_vlan_ranges = ['physnet1:1000:2999'],
$provider_bridge_mappings = ['public:br-pub'],
$use_syslog = true,
$log_facility = 'LOG_LOCAL0',
$dhcp_lease_duration = '120',
$flat_networks = ['public'],
$external_int = 'eth1',
$external_bridge = 'br-pub',
$manage_ext_network = false,
$tunnel_types = ['gre'],
$tenant_network_types = ['gre'],
$type_drivers = ['gre', 'vlan', 'flat'],
$ml2_enabled = true,
# DEPRECATED PARAMETERS
$tunnel_eth = false,
$tunnel_types = false,
$provider_bridge_mappings = false,
$external_int = false,
$external_bridge = false,
$manage_ext_network = false,
) {
# Deprecated parameters warning
if $tunnel_eth or $tunnel_types or $provider_bridge_mappings or $external_int or $external_bridge or $manage_ext_network {
warning('This parameter is deprecated to move in cloud::network::vswitch class.')
}
# Disable twice logging if syslog is enabled
if $use_syslog {
$log_dir = false
@ -128,8 +132,17 @@ class cloud::network(
$log_dir = '/var/log/neutron'
}
if $::osfamily == 'RedHat' {
kmod::load { 'ip_gre': }
if $ml2_enabled {
$core_plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
class { 'neutron::plugins::ml2':
type_drivers => $type_drivers,
tenant_network_types => $tenant_network_types,
network_vlan_ranges => $provider_vlan_ranges,
tunnel_id_ranges => ['1:10000'],
flat_networks => $flat_networks,
mechanism_drivers => ['openvswitch','l2population'],
enable_security_group => true
}
}
class { 'neutron':
@ -144,67 +157,11 @@ class cloud::network(
log_facility => $log_facility,
use_syslog => $use_syslog,
dhcp_agents_per_network => '2',
core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin',
core_plugin => $core_plugin,
service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'],
log_dir => $log_dir,
dhcp_lease_duration => $dhcp_lease_duration,
report_interval => '30',
}
class { 'neutron::agents::ovs':
enable_tunneling => true,
tunnel_types => $tunnel_types,
bridge_mappings => $provider_bridge_mappings,
local_ip => $tunnel_eth
}
class { 'neutron::plugins::ml2':
type_drivers => $type_drivers,
tenant_network_types => $tenant_network_types,
network_vlan_ranges => $provider_vlan_ranges,
tunnel_id_ranges => ['1:10000'],
flat_networks => $flat_networks,
mechanism_drivers => ['openvswitch','l2population'],
enable_security_group => true
}
# TODO(EmilienM) Temporary, need to be fixed upstream.
# There is an issue when using ML2 + OVS: neutron services don't read OVS
# config file, only ML2. I need to patch puppet-neutron.
# Follow-up: https://github.com/enovance/puppet-openstack-cloud/issues/199
neutron_plugin_ml2 {
'agent/tunnel_types': value => $tunnel_types;
'agent/l2_population': value => true;
'agent/polling_interval': value => '15';
'OVS/local_ip': value => $tunnel_eth;
'OVS/enable_tunneling': value => true;
'OVS/integration_bridge': value => 'br-int';
'OVS/tunnel_bridge': value => 'br-tun';
'OVS/bridge_mappings': value => $provider_bridge_mappings;
'securitygroup/firewall_driver': value => 'neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver';
}
# TODO(EmilienM), Temporary, it's a bug in Debian packages. GH#342
file { '/var/lib/neutron':
ensure => 'directory',
owner => 'neutron',
group => 'neutron',
mode => '0755'
}
if $manage_ext_network {
vs_port {$external_int:
ensure => present,
bridge => $external_bridge
}
if defined('neutron::server') {
neutron_network {'public':
provider_network_type => 'flat',
provider_physical_network => 'public',
shared => true,
router_external => true
}
}
}
}

View File

@ -15,6 +15,10 @@
#
# Network Controller node (API + Scheduler)
#
# [*manage_ext_network*]
# (optionnal) Manage or not external network with provider network API
# Defaults to false.
#
class cloud::network::controller(
$neutron_db_host = '127.0.0.1',
@ -32,7 +36,8 @@ class cloud::network::controller(
$nova_admin_username = 'nova',
$nova_admin_tenant_name = 'services',
$nova_admin_password = 'novapassword',
$nova_region_name = 'RegionOne'
$nova_region_name = 'RegionOne',
$manage_ext_network = false,
) {
include 'cloud::network'
@ -60,12 +65,21 @@ class cloud::network::controller(
nova_region_name => $nova_region_name
}
if $manage_ext_network {
neutron_network {'public':
provider_network_type => 'flat',
provider_physical_network => 'public',
shared => true,
router_external => true
}
}
# Note(EmilienM):
# We check if DB tables are created, if not we populate Neutron DB.
# It's a hack to fit with our setup where we run MySQL/Galera
Neutron_config<| |> ->
exec {'neutron_db_sync':
command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head',
command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
path => '/usr/bin',
user => 'neutron',
unless => "/usr/bin/mysql neutron -h ${neutron_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables",

View File

@ -23,6 +23,7 @@ class cloud::network::dhcp(
) {
include 'cloud::network'
include 'cloud::network::vswitch'
class { 'neutron::agents::dhcp':
debug => $debug,

View File

@ -23,6 +23,7 @@ class cloud::network::l3(
) {
include 'cloud::network'
include 'cloud::network::vswitch'
if ! $ext_provider_net {
vs_bridge{'br-ex':

View File

@ -22,6 +22,7 @@ class cloud::network::lbaas(
) {
include 'cloud::network'
include 'cloud::network::vswitch'
class { 'neutron::agents::lbaas':
manage_haproxy_package => $manage_haproxy_pkg,

View File

@ -31,6 +31,7 @@ class cloud::network::metadata(
) {
include 'cloud::network'
include 'cloud::network::vswitch'
class { 'neutron::agents::metadata':
enabled => $enabled,

View File

@ -19,6 +19,7 @@
class cloud::network::vpn{
include 'cloud::network'
include 'cloud::network::vswitch'
class { 'neutron::agents::vpnaas': }

View File

@ -0,0 +1,83 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.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.
#
# Network vswitch class
#
# === Parameters:
#
# [*driver*]
# (optional) Neutron vswitch driver
# Currently, only ml2_ovs is supported.
# Defaults to 'ml2_ovs'
#
# [*tunnel_eth*]
# (optional) Interface IP used to build the tunnels
# Defaults to '127.0.0.1'
#
# [*tunnel_typeis]
# (optional) List of types of tunnels to use when utilizing tunnels
# Defaults to ['gre']
#
# [*provider_bridge_mappings*]
# (optional) List of <physical_network>:<bridge>
#
# [*external_int*]
# (optionnal) Network interface to bind the external provider network
# Defaults to 'eth1'.
#
# [*external_bridge*]
# (optionnal) OVS bridge used to bind external provider network
# Defaults to 'br-pub'.
#
# [*manage_ext_network*]
# (optionnal) Manage or not external network with provider network API
# Defaults to false.
#
class cloud::network::vswitch(
$driver = 'ml2_ovs',
$tunnel_types = ['gre'],
$provider_bridge_mappings = ['public:br-pub'],
$tunnel_eth = '127.0.0.1',
$manage_ext_network = false,
$external_int = 'eth1',
$external_bridge = 'br-pub',
) {
include 'cloud::network'
if $driver == 'ml2_ovs' {
class { 'neutron::agents::ml2::ovs':
enable_tunneling => true,
l2_population => true,
polling_interval => '15',
tunnel_types => $tunnel_types,
bridge_mappings => $provider_bridge_mappings,
local_ip => $tunnel_eth
}
if $::osfamily == 'RedHat' {
kmod::load { 'ip_gre': }
}
if $manage_ext_network {
vs_port {$external_int:
ensure => present,
bridge => $external_bridge
}
}
}
}

View File

@ -56,18 +56,16 @@ describe 'cloud::compute::hypervisor' do
class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tenant_network_types => ['gre'],
type_drivers => ['gre', 'vlan', 'flat'],
log_facility => 'LOG_LOCAL0' }"
end
@ -152,12 +150,6 @@ describe 'cloud::compute::hypervisor' do
:log_dir => false,
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['gre'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre','vlan','flat'],
:tenant_network_types => ['gre'],
@ -465,40 +457,6 @@ describe 'cloud::compute::hypervisor' do
)
end
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
end
context 'on Debian platforms' do
@ -510,10 +468,6 @@ describe 'cloud::compute::hypervisor' do
}
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack compute hypervisor'
end
@ -525,10 +479,6 @@ describe 'cloud::compute::hypervisor' do
}
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack compute hypervisor'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::controller' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -57,6 +52,7 @@ describe 'cloud::network::controller' do
:nova_admin_tenant_name => 'services',
:nova_admin_password => 'novapassword',
:nova_region_name => 'RegionOne',
:manage_ext_network => false,
:api_eth => '10.0.0.1' }
end
@ -79,12 +75,6 @@ describe 'cloud::network::controller' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -94,7 +84,6 @@ describe 'cloud::network::controller' do
:flat_networks => ['public'],
:enable_security_group => true
)
should_not contain__neutron_network('public')
end
it 'configure neutron server' do
@ -121,7 +110,7 @@ describe 'cloud::network::controller' do
end
it 'checks if Neutron DB is populated' do
should contain_exec('neutron_db_sync').with(
:command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head',
:command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
:path => '/usr/bin',
:user => 'neutron',
:unless => '/usr/bin/mysql neutron -h 10.0.0.1 -u neutron -psecrete -e "show tables" | /bin/grep Tables',
@ -130,44 +119,10 @@ describe 'cloud::network::controller' do
)
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'configure provider external network' do
should contain_neutron_network('public').with(
:provider_network_type => 'flat',
:provider_physical_network => 'public',
:shared => true,
:router_external => true
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
context 'on Debian platforms' do
@ -176,10 +131,6 @@ describe 'cloud::network::controller' do
:processorcount => '2' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network controller'
end
@ -189,10 +140,6 @@ describe 'cloud::network::controller' do
:processorcount => '2' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network controller'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::dhcp' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -67,12 +62,6 @@ describe 'cloud::network::dhcp' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -101,40 +90,6 @@ describe 'cloud::network::dhcp' do
)
should contain_file('/etc/neutron/dnsmasq-neutron.conf').with_content(/^dhcp-option-force=26,1400$/)
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
end
shared_examples_for 'openstack network dhcp with custom nameserver' do
@ -183,10 +138,6 @@ describe 'cloud::network::dhcp' do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network dhcp'
it_configures 'openstack network dhcp with custom nameserver'
end
@ -196,10 +147,6 @@ describe 'cloud::network::dhcp' do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network dhcp'
it_configures 'openstack network dhcp with custom nameserver'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::l3' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -67,12 +62,6 @@ describe 'cloud::network::l3' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -101,57 +90,6 @@ describe 'cloud::network::l3' do
)
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
before do
params.merge!(
:ext_provider_net => true,
)
end
it 'configure neutron l3 without br-ex' do
should contain_class('neutron::agents::l3').with(
:debug => true,
:external_network_bridge => ''
)
end
it 'do not configure br-ex bridge' do
should_not contain_vs_bridge('br-ex')
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
context 'without TSO/GSO/GRO on Red Hat systems' do
before :each do
facts.merge!( :osfamily => 'RedHat')
@ -200,10 +138,6 @@ describe 'cloud::network::l3' do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network l3'
end
@ -212,10 +146,6 @@ describe 'cloud::network::l3' do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network l3'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::lbaas' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -67,12 +62,6 @@ describe 'cloud::network::lbaas' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -116,40 +105,6 @@ describe 'cloud::network::lbaas' do
should contain_package('haproxy').with(:ensure => 'present')
end
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
end
context 'on Debian platforms' do
@ -157,10 +112,6 @@ describe 'cloud::network::lbaas' do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network lbaas'
end
@ -169,10 +120,6 @@ describe 'cloud::network::lbaas' do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network lbaas'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::metadata' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -75,12 +70,6 @@ describe 'cloud::network::metadata' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -106,40 +95,6 @@ describe 'cloud::network::metadata' do
)
should contain_neutron_metadata_agent_config('DEFAULT/nova_metadata_protocol').with(:value => 'https')
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
end
context 'on Debian platforms' do
@ -148,10 +103,6 @@ describe 'cloud::network::metadata' do
:processorcount => '8' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network metadata'
end
@ -161,10 +112,6 @@ describe 'cloud::network::metadata' do
:processorcount => '8' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network metadata'
end

View File

@ -25,19 +25,14 @@ describe 'cloud::network::vpn' do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => false,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tunnel_types => ['vxlan'],
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
@ -62,12 +57,6 @@ describe 'cloud::network::vpn' do
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::agents::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['vxlan'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
@ -83,40 +72,6 @@ describe 'cloud::network::vpn' do
it 'configure neutron vpnaas' do
should contain_class('neutron::agents::vpnaas')
end
context 'when using provider external network' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['public:br-pub'],
flat_networks => ['public'],
external_int => 'eth1',
external_bridge => 'br-pub',
manage_ext_network => true,
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
it 'should not configure provider external network' do
should_not contain__neutron_network('public')
end
end
end
context 'on Debian platforms' do
@ -124,10 +79,6 @@ describe 'cloud::network::vpn' do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :gre_module_name => 'gre' }
end
it_configures 'openstack network vpnaas'
end
@ -136,10 +87,6 @@ describe 'cloud::network::vpn' do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :gre_module_name => 'ip_gre' }
end
it_configures 'openstack network vpnaas'
end

View File

@ -0,0 +1,122 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.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 cloud::network::vswitch class
#
require 'spec_helper'
describe 'cloud::network::vswitch' do
shared_examples_for 'openstack network vswitch' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
flat_networks => ['public'],
external_bridge => 'br-pub',
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
tenant_network_types => ['vxlan'],
type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
log_facility => 'LOG_LOCAL0' }"
end
let :params do
{ :tunnel_eth => '10.0.1.1' }
end
it 'configure neutron common' do
should contain_class('neutron').with(
:allow_overlapping_ips => true,
:dhcp_agents_per_network => '2',
:verbose => true,
:debug => true,
:log_facility => 'LOG_LOCAL0',
:use_syslog => true,
:rabbit_user => 'neutron',
:rabbit_hosts => ['10.0.0.1'],
:rabbit_password => 'secrete',
:rabbit_virtual_host => '/',
:bind_host => '10.0.0.1',
:core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin',
:service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'],
:log_dir => false,
:dhcp_lease_duration => '10',
:report_interval => '30'
)
should contain_class('neutron::plugins::ml2').with(
:type_drivers => ['gre', 'vlan', 'flat', 'vxlan'],
:tenant_network_types => ['vxlan'],
:mechanism_drivers => ['openvswitch','l2population'],
:tunnel_id_ranges => ['1:10000'],
:network_vlan_ranges => ['physnet1:1000:2999'],
:flat_networks => ['public'],
:enable_security_group => true
)
end
context 'when running ML2 plugin with OVS driver' do
it 'configure neutron vswitch' do
should contain_class('neutron::agents::ml2::ovs').with(
:enable_tunneling => true,
:tunnel_types => ['gre'],
:bridge_mappings => ['public:br-pub'],
:local_ip => '10.0.1.1'
)
end
end
context 'when using provider external network' do
before do
params.merge!(
:manage_ext_network=> true,
)
end
it 'configure br-pub bridge' do
should contain_vs_bridge('br-pub')
end
it 'configure eth1 in br-pub' do
should contain_vs_port('eth1').with(
:ensure => 'present',
:bridge => 'br-pub'
)
end
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'openstack network vswitch'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'openstack network vswitch'
end
end