Merge "cinder_qos: Fix parsing of associations field"

This commit is contained in:
Zuul 2024-10-09 15:42:36 +00:00 committed by Gerrit Code Review
commit 9458f6c595
2 changed files with 9 additions and 11 deletions

View File

@ -27,12 +27,10 @@ Puppet::Type.type(:cinder_qos).provide(
@property_hash[:properties] = resource[:properties] @property_hash[:properties] = resource[:properties]
@property_hash[:consumer] = resource[:consumer] @property_hash[:consumer] = resource[:consumer]
@property_hash[:name] = name @property_hash[:name] = name
unless resource[:associations].empty? resource[:associations].each do |item|
resource[:associations].each do |item| self.class.request('volume qos', 'associate', [name, item])
self.class.request('volume qos', 'associate', [name, item])
end
@property_hash[:associations] = resource[:associations]
end end
@property_hash[:associations] = resource[:associations]
end end
def destroy def destroy
@ -94,6 +92,6 @@ Puppet::Type.type(:cinder_qos).provide(
end end
def self.string2array(input) def self.string2array(input)
return input.delete("'").split(/,\s/) return input[1..-2].delete("'").split(/,\s/)
end end
end end

View File

@ -58,8 +58,8 @@ properties="{\'key1\': \'value1\', \'key2\': \'value2\'}"
expect(provider_class).to receive(:openstack) expect(provider_class).to receive(:openstack)
.with('volume qos', 'list', '--quiet', '--format', 'csv', []) .with('volume qos', 'list', '--quiet', '--format', 'csv', [])
.and_return('"ID","Name","Consumer","Associations","Properties" .and_return('"ID","Name","Consumer","Associations","Properties"
"28b632e8-6694-4bba-bf68-67b19f619019","qos-1","front-end","my_type1, my_type2","{\'read_iops\': \'value1\', \'write_iops\':\'value2\'}" "28b632e8-6694-4bba-bf68-67b19f619019","qos-1","front-end","[\'my_type1\', \'my_type2\']","{\'read_iops\': \'value1\', \'write_iops\':\'value2\'}"
"4f992f69-14ec-4132-9313-55cc06a6f1f6","qos-2","both","","{}" "4f992f69-14ec-4132-9313-55cc06a6f1f6","qos-2","both","[]","{}"
') ')
instances = provider_class.instances instances = provider_class.instances
expect(instances.count).to eq(2) expect(instances.count).to eq(2)
@ -75,9 +75,9 @@ properties="{\'key1\': \'value1\', \'key2\': \'value2\'}"
end end
describe '#string2array' do describe '#string2array' do
it 'should return an array with key-value' do it 'should return an array' do
s = "key='value', key2='value2'" s = "['foo', 'bar']"
expect(provider_class.string2array(s)).to eq(['key=value', 'key2=value2']) expect(provider_class.string2array(s)).to eq(['foo', 'bar'])
end end
end end
end end