Accept hash for ovn_bridge_mappings
Change-Id: I61cf0f01722703159831fcd334762f559e0f7e75
This commit is contained in:
parent
29789848df
commit
10bb026ced
@ -132,7 +132,7 @@ class ovn::controller(
|
||||
String $package_ensure = 'present',
|
||||
Variant[String[1], Array[String[1]]] $ovn_encap_type = 'geneve',
|
||||
Optional[Variant[String, Integer]] $ovn_encap_tos = undef,
|
||||
Variant[String[1], Array[String[1]]] $ovn_bridge_mappings = [],
|
||||
Ovn::BridgeMappings $ovn_bridge_mappings = [],
|
||||
Array[String[1]] $bridge_interface_mappings = [],
|
||||
String[1] $hostname = $facts['networking']['fqdn'],
|
||||
String[1] $ovn_bridge = 'br-int',
|
||||
@ -253,12 +253,19 @@ class ovn::controller(
|
||||
}
|
||||
|
||||
if !empty($ovn_bridge_mappings) {
|
||||
|
||||
$ovn_bridge_mappings_real = $ovn_bridge_mappings ? {
|
||||
Hash => join_keys_to_values($ovn_bridge_mappings, ':'),
|
||||
String => $ovn_bridge_mappings.split(',').strip(),
|
||||
default => $ovn_bridge_mappings,
|
||||
}
|
||||
|
||||
$bridge_items = {
|
||||
'external_ids:ovn-bridge-mappings' => { 'value' => join(any2array($ovn_bridge_mappings), ',') }
|
||||
'external_ids:ovn-bridge-mappings' => { 'value' => join(any2array($ovn_bridge_mappings_real), ',') }
|
||||
}
|
||||
|
||||
if $manage_ovs_bridge {
|
||||
ovn::controller::bridge { $ovn_bridge_mappings:
|
||||
ovn::controller::bridge { $ovn_bridge_mappings_real:
|
||||
mac_table_size => $mac_table_size,
|
||||
before => Service['controller'],
|
||||
require => Service['openvswitch']
|
||||
|
38
spec/type_aliases/bridgemappings_spec.rb
Normal file
38
spec/type_aliases/bridgemappings_spec.rb
Normal file
@ -0,0 +1,38 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'Ovn::BridgeMappings' do
|
||||
describe 'valid types' do
|
||||
context 'with valid types' do
|
||||
[
|
||||
'',
|
||||
'datacentre:br-ex',
|
||||
[],
|
||||
['datacentre:br-ex'],
|
||||
{},
|
||||
{'datacentre' => 'br-ex'}
|
||||
].each do |value|
|
||||
describe value.inspect do
|
||||
it { is_expected.to allow_value(value) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'invalid types' do
|
||||
context 'with garbage inputs' do
|
||||
[
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
[''],
|
||||
{'' => 'br-ex'},
|
||||
{'datacentre' => ''}
|
||||
].each do |value|
|
||||
describe value.inspect do
|
||||
it { is_expected.not_to allow_value(value) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
5
types/bridgemappings.pp
Normal file
5
types/bridgemappings.pp
Normal file
@ -0,0 +1,5 @@
|
||||
type Ovn::BridgeMappings = Variant[
|
||||
String,
|
||||
Array[String[1]],
|
||||
Hash[String[1], String[1]],
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user