Merge "Fix cinder-qos provider issue with openstackclient >= 3.8.0"

This commit is contained in:
Zuul 2019-01-02 11:41:29 +00:00 committed by Gerrit Code Review
commit 8a0b58ae16
2 changed files with 22 additions and 1 deletions

View File

@ -64,11 +64,15 @@ Puppet::Type.type(:cinder_qos).provide(
def self.instances
list = request('volume qos', 'list')
list.collect do |qos|
properties = qos[:properties]
unless qos[:specs].nil?
properties = qos[:specs]
end
new({
:name => qos[:name],
:ensure => :present,
:id => qos[:id],
:properties => string2array(qos[:specs]),
:properties => string2array(properties),
:consumer => qos[:consumer],
:associations => string2array(qos[:associations])
})

View File

@ -79,6 +79,23 @@ properties="key1=\'value1\', key2=\'value2\'"
end
end
#Test with python-openstackclient => 3.8.0 output (column header change from 'Specs' to 'Properties')
describe '#instances' do
it 'finds qos' do
provider_class.expects(:openstack)
.with('volume qos', 'list', '--quiet', '--format', 'csv', [])
.returns('"ID","Name","Consumer","Associations","Properties"
"28b632e8-6694-4bba-bf68-67b19f619019","qos-1","front-end","my_type1","read_iops=\'value1\'"
')
instances = provider_class.instances
expect(instances.count).to eq(1)
expect(instances[0].name).to eq('qos-1')
expect(instances[0].associations).to eq(['my_type1'])
expect(instances[0].consumer).to eq('front-end')
expect(instances[0].properties).to eq(['read_iops=value1'])
end
end
describe '#string2array' do
it 'should return an array with key-value' do
s = "key='value', key2='value2'"