Allow greater flexibility in the kind of parameter passed to ml2.pp

Currently the user is forced to pass an array for some values such as
$network_vlan_ranges when an actual string would be definitly a correct
value.

This was done because later on the processing, the code relies on
function that expects an array, yes join() we are talking about you.

The use of any2array() can give us the flexibility to receive either a
string or an array.

The affected variables are the following :

 * type_drivers
 * tenant_network_types
 * mechanism_drivers
 * flat_networks
 * network_vlan_ranges
 * tunnel_id_ranges
 * vxlan_group
 * vni_ranges
 * supported_pci_vendor_devs

Change-Id: I0496e2f855f251a77329163845f87efe1b93cbb1
This commit is contained in:
Yanis Guenane
2015-09-08 16:07:28 +02:00
parent 2551810e8a
commit e00d74cff8
4 changed files with 21 additions and 25 deletions

View File

@@ -59,14 +59,14 @@
# well as ranges of VLAN tags on each available for
# allocation to tenant networks.
# Should be an array with vlan_min = 1 & vlan_max = 4094 (IEEE 802.1Q)
# Default to empty.
# Default to 'physnet1:1000:2999'.
#
# [*tunnel_id_ranges*]
# (optional) Comma-separated list of <tun_min>:<tun_max> tuples
# enumerating ranges of GRE tunnel IDs that are
# available for tenant network allocation
# Should be an array with tun_max +1 - tun_min > 1000000
# Default to empty.
# Default to '20:100'.
#
# [*vxlan_group*]
# (optional) Multicast group for VXLAN.
@@ -74,14 +74,14 @@
# broadcast traffic to this multicast group. When left unconfigured, will
# disable multicast VXLAN mode
# Should be an Multicast IP (v4 or v6) address.
# Default to 'None'.
# Default to '224.0.0.1'.
#
# [*vni_ranges*]
# (optional) Comma-separated list of <vni_min>:<vni_max> tuples
# enumerating ranges of VXLAN VNI IDs that are
# available for tenant network allocation.
# Min value is 0 and Max value is 16777215.
# Default to empty.
# Default to '10:100'.
#
# [*enable_security_group*]
# (optional) Controls if neutron security group is enabled or not.
@@ -120,11 +120,11 @@ class neutron::plugins::ml2 (
$type_drivers = ['local', 'flat', 'vlan', 'gre', 'vxlan'],
$tenant_network_types = ['local', 'flat', 'vlan', 'gre', 'vxlan'],
$mechanism_drivers = ['openvswitch', 'linuxbridge'],
$flat_networks = ['*'],
$network_vlan_ranges = ['physnet1:1000:2999'],
$tunnel_id_ranges = ['20:100'],
$flat_networks = '*',
$network_vlan_ranges = 'physnet1:1000:2999',
$tunnel_id_ranges = '20:100',
$vxlan_group = '224.0.0.1',
$vni_ranges = ['10:100'],
$vni_ranges = '10:100',
$enable_security_group = true,
$package_ensure = 'present',
$supported_pci_vendor_devs = ['15b3:1004', '8086:10ca'],
@@ -137,7 +137,6 @@ class neutron::plugins::ml2 (
Neutron_plugin_ml2<||> ~> Service<| title == 'neutron-server' |>
validate_array($mechanism_drivers)
if ! $mechanism_drivers {
warning('Without networking mechanism driver, ml2 will not communicate with L2 agents')
}
@@ -195,9 +194,9 @@ class neutron::plugins::ml2 (
}
neutron_plugin_ml2 {
'ml2/type_drivers': value => join($type_drivers, ',');
'ml2/tenant_network_types': value => join($tenant_network_types, ',');
'ml2/mechanism_drivers': value => join($mechanism_drivers, ',');
'ml2/type_drivers': value => join(any2array($type_drivers), ',');
'ml2/tenant_network_types': value => join(any2array($tenant_network_types), ',');
'ml2/mechanism_drivers': value => join(any2array($mechanism_drivers), ',');
'ml2/path_mtu': value => $path_mtu;
'securitygroup/enable_security_group': value => $enable_security_group;
}
@@ -211,8 +210,5 @@ class neutron::plugins::ml2 (
neutron_plugin_ml2 {
'ml2/physical_network_mtus': value => join($physical_network_mtus, ',');
}
}
Neutron_plugin_ml2<||> ~> Exec<| title == 'neutron-db-sync' |>
} Neutron_plugin_ml2<||> ~> Exec<| title == 'neutron-db-sync' |>
}

View File

@@ -32,7 +32,7 @@ define neutron::plugins::ml2::mech_driver (
){
if ($name == 'sriovnicswitch') {
neutron_plugin_ml2 {
'ml2_sriov/supported_pci_vendor_devs': value => join($supported_pci_vendor_devs, ',');
'ml2_sriov/supported_pci_vendor_devs': value => join(any2array($supported_pci_vendor_devs), ',');
'ml2_sriov/agent_required': value => $sriov_agent_required;
}
}

View File

@@ -48,7 +48,7 @@ define neutron::plugins::ml2::type_driver (
){
if ($name == 'flat') {
neutron_plugin_ml2 {
'ml2_type_flat/flat_networks': value => join($flat_networks, ',');
'ml2_type_flat/flat_networks': value => join(any2array($flat_networks), ',');
}
}
elsif ($name == 'gre') {
@@ -60,7 +60,7 @@ define neutron::plugins::ml2::type_driver (
validate_tunnel_id_ranges($tunnel_id_ranges)
neutron_plugin_ml2 {
'ml2_type_gre/tunnel_id_ranges': value => join($tunnel_id_ranges, ',');
'ml2_type_gre/tunnel_id_ranges': value => join(any2array($tunnel_id_ranges), ',');
}
}
elsif ($name == 'vlan') {
@@ -72,7 +72,7 @@ define neutron::plugins::ml2::type_driver (
validate_network_vlan_ranges($network_vlan_ranges)
neutron_plugin_ml2 {
'ml2_type_vlan/network_vlan_ranges': value => join($network_vlan_ranges, ',');
'ml2_type_vlan/network_vlan_ranges': value => join(any2array($network_vlan_ranges), ',');
}
}
elsif ($name == 'vxlan') {
@@ -98,7 +98,7 @@ define neutron::plugins::ml2::type_driver (
neutron_plugin_ml2 {
'ml2_type_vxlan/vxlan_group': value => $vxlan_group;
'ml2_type_vxlan/vni_ranges': value => join($vni_ranges, ',');
'ml2_type_vxlan/vni_ranges': value => join(any2array($vni_ranges), ',');
}
}
elsif ($name == 'local') {

View File

@@ -32,11 +32,11 @@ describe 'neutron::plugins::ml2' do
{ :type_drivers => ['local', 'flat', 'vlan', 'gre', 'vxlan'],
:tenant_network_types => ['local', 'flat', 'vlan', 'gre', 'vxlan'],
:mechanism_drivers => ['openvswitch', 'linuxbridge'],
:flat_networks => ['*'],
:network_vlan_ranges => ['10:50'],
:tunnel_id_ranges => ['20:100'],
:flat_networks => '*',
:network_vlan_ranges => '10:50',
:tunnel_id_ranges => '20:100',
:vxlan_group => '224.0.0.1',
:vni_ranges => ['10:100'],
:vni_ranges => '10:100',
:path_mtu => '0',
:physical_network_mtus => '',
:package_ensure => 'present' }