Fixes vs_config options parsing
Fix the parsing logic which wrongly detects '=' in hash values.
Closes-Bug: #2080944
Change-Id: I8cd8c8f4640941966ac838580dd45ab56cadb6de
(cherry picked from commit 4e4105cf48
)
This commit is contained in:
parent
cfeea1a051
commit
f765702967
@ -15,7 +15,7 @@ Puppet::Type.type(:vs_config).provide(:ovs) do
|
||||
type = 'hash'
|
||||
res = {}
|
||||
value[1..-2].gsub('"','').split(', ').map(&:strip).each do |v|
|
||||
k,val = v.split("=")
|
||||
k,val = v.split('=', 2)
|
||||
res[k] = val
|
||||
end
|
||||
elsif value[0] == '['
|
||||
|
@ -53,6 +53,11 @@ describe 'basic vswitch' do
|
||||
value => 'tcp:127.0.0.1:2300',
|
||||
}
|
||||
|
||||
vs_config { 'external_ids:ovn-cms-options':
|
||||
ensure => present,
|
||||
value => 'enable-chassis-as-gw,availability-zones=nova',
|
||||
}
|
||||
|
||||
vs_config { 'other_config:thisshouldexist':
|
||||
ensure => present,
|
||||
value => 'customvalue',
|
||||
@ -131,12 +136,18 @@ describe 'basic vswitch' do
|
||||
end
|
||||
end
|
||||
|
||||
it 'should get remote addr' do
|
||||
it 'should get ovn remote addr' do
|
||||
command('ovs-vsctl get Open_vSwitch . external_ids:ovn-remote') do |r|
|
||||
expect(r.stdout).to match(/\"tcp:127.0.0.1:2300\"/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should get ovn cms options' do
|
||||
command('ovs-vsctl get Open_vSwitch . external_ids:ovn-cms-options') do |r|
|
||||
expect(r.stdout).to match(/\"enable-chassis-as-gw,availability-zones=nova\"/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should get other config' do
|
||||
command('sudo ovs-vsctl get Open_Vswitch . other_config') do |r|
|
||||
expect(r.stdout).to match(/\"{thishshouldexist=customvalue}"/)
|
||||
|
@ -73,11 +73,12 @@ key3 : [1001, 399, 240, 1200]')
|
||||
expect(described_class).to receive(:vsctl).with(
|
||||
"list", "Open_vSwitch", ".").and_return('key1 : {}
|
||||
key2 : {"hash21"="value21"}
|
||||
key3 : {"hash31"="value31", "hash32"="value32", "hash33"=33}')
|
||||
key3 : {"hash31"="value31", "hash32"="value32", "hash33"=33}
|
||||
key4 : {"hash41"="value41,key42=value42"}')
|
||||
end
|
||||
|
||||
it "should return three resources" do
|
||||
expect(described_class.instances.size).to eq(4)
|
||||
expect(described_class.instances.size).to eq(5)
|
||||
end
|
||||
|
||||
it "should contain valid names and values" do
|
||||
@ -85,7 +86,8 @@ key3 : {"hash31"="value31", "hash32"="value32", "hash33"=33}')
|
||||
"key2:hash21" => "value21",
|
||||
"key3:hash31" => "value31",
|
||||
"key3:hash32" => "value32",
|
||||
"key3:hash33" => "33"}
|
||||
"key3:hash33" => "33",
|
||||
"key4:hash41" => "value41,key42=value42"}
|
||||
described_class.instances.each do |inst|
|
||||
_inst = inst.instance_variable_get("@property_hash")
|
||||
expect(expected_values.key?(_inst[:name])).to eq true
|
||||
|
Loading…
Reference in New Issue
Block a user