Enforce correct value for encapsulation type

The ovn-encap-type option accepts vxlan, geneve and stt. Ensure that
only supported values are given.

Note:
stt is already deprecated and is not quote popular in OpenStack
deployments so is not accepted at this moment.

Change-Id: I9365504a7b444b5f06c44aeda2cbb131f9c8aa0a
This commit is contained in:
Takashi Kajinami
2025-01-02 22:36:51 +09:00
parent 5ec71cf171
commit ec80dc8a12
3 changed files with 37 additions and 1 deletions

View File

@@ -147,7 +147,7 @@ class ovn::controller(
String $ovn_remote,
Stdlib::IP::Address $ovn_encap_ip,
String $package_ensure = 'present',
Variant[String[1], Array[String[1]]] $ovn_encap_type = 'geneve',
Variant[Ovn::EncapType, Array[Ovn::EncapType]] $ovn_encap_type = 'geneve',
Optional[Variant[String, Integer]] $ovn_encap_tos = undef,
Ovn::BridgeMappings $ovn_bridge_mappings = [],
Array[String[1]] $bridge_interface_mappings = [],

View File

@@ -0,0 +1,35 @@
require 'spec_helper'
describe 'Ovn::EncapType' do
describe 'valid types' do
context 'with valid types' do
[
'geneve',
'vxlan'
].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
[
'',
'vlan',
true,
false,
1,
['vxlan'],
{'' => 'vxlan'},
{'vxlan' => ''}
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end

1
types/encaptype.pp Normal file
View File

@@ -0,0 +1 @@
type Ovn::EncapType = Enum['geneve', 'vxlan']