Use common function to parse python dict
Depends-on: https://review.opendev.org/931722 Change-Id: Ie3b29bd3a4a764d5213988db5ccedd971b8749b0
This commit is contained in:
parent
bb1eba7195
commit
2dcade3439
@ -77,7 +77,7 @@ Puppet::Type.type(:cinder_qos).provide(
|
||||
:name => qos[:name],
|
||||
:ensure => :present,
|
||||
:id => qos[:id],
|
||||
:properties => pythondict2hash(properties),
|
||||
:properties => parse_python_dict(properties),
|
||||
:consumer => qos[:consumer],
|
||||
:associations => string2array(qos[:associations])
|
||||
})
|
||||
@ -96,8 +96,4 @@ Puppet::Type.type(:cinder_qos).provide(
|
||||
def self.string2array(input)
|
||||
return input.delete("'").split(/,\s/)
|
||||
end
|
||||
|
||||
def self.pythondict2hash(input)
|
||||
return JSON.parse(input.gsub(/'/, '"'))
|
||||
end
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ Puppet::Type.type(:cinder_type).provide(
|
||||
:name => type[:name],
|
||||
:ensure => :present,
|
||||
:id => type[:id],
|
||||
:properties => pythondict2hash(type[:properties]),
|
||||
:properties => parse_python_dict(type[:properties]),
|
||||
:is_public => type[:is_public],
|
||||
:access_project_ids => type[:access_project_ids]
|
||||
})
|
||||
@ -116,8 +116,4 @@ Puppet::Type.type(:cinder_type).provide(
|
||||
def self.string2array(input)
|
||||
return input.delete("'").split(/,\s/)
|
||||
end
|
||||
|
||||
def self.pythondict2hash(input)
|
||||
return JSON.parse(input.gsub(/'/, '"'))
|
||||
end
|
||||
end
|
||||
|
@ -80,12 +80,5 @@ properties="{\'key1\': \'value1\', \'key2\': \'value2\'}"
|
||||
expect(provider_class.string2array(s)).to eq(['key=value', 'key2=value2'])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pythondict2hash' do
|
||||
it 'should return a hash when provided with a python dict' do
|
||||
s = "{'key': 'value', 'key2': 'value2'}"
|
||||
expect(provider_class.pythondict2hash(s)).to eq({'key'=>'value', 'key2'=>'value2'})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -97,12 +97,5 @@ access_project_ids="54f4d231201b4944a5fa4587a09bda23, 54f4d231201b4944a5fa4587a0
|
||||
expect(provider_class.string2array(s)).to eq(['key=value', 'key2=value2'])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pythondict2hash' do
|
||||
it 'should return a hash when provided with a python dict' do
|
||||
s = "{'key': 'value', 'key2': 'value2'}"
|
||||
expect(provider_class.pythondict2hash(s)).to eq({'key'=>'value', 'key2'=>'value2'})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user