diff --git a/lib/puppet/provider/cinder_qos/openstack.rb b/lib/puppet/provider/cinder_qos/openstack.rb index f2088fdd..6121346d 100644 --- a/lib/puppet/provider/cinder_qos/openstack.rb +++ b/lib/puppet/provider/cinder_qos/openstack.rb @@ -13,9 +13,7 @@ Puppet::Type.type(:cinder_qos).provide( def create properties = [] - unless resource[:consumer].empty? - properties << '--consumer' << resource[:consumer] - end + properties << '--consumer' << resource[:consumer].to_s if resource[:properties] resource[:properties].each do |k, v| properties << '--property' << "#{k}=#{v}" @@ -76,7 +74,7 @@ Puppet::Type.type(:cinder_qos).provide( :ensure => :present, :id => qos[:id], :properties => parse_python_dict(properties), - :consumer => qos[:consumer], + :consumer => qos[:consumer].downcase, :associations => string2array(qos[:associations]) }) end diff --git a/lib/puppet/provider/cinder_type/openstack.rb b/lib/puppet/provider/cinder_type/openstack.rb index 95210194..c20d3979 100644 --- a/lib/puppet/provider/cinder_type/openstack.rb +++ b/lib/puppet/provider/cinder_type/openstack.rb @@ -23,7 +23,7 @@ Puppet::Type.type(:cinder_type).provide( self.class.request('volume type', 'create', properties) @property_hash[:ensure] = :present @property_hash[:properties] = resource[:properties] - @property_hash[:is_public] = resource[:is_public] + @property_hash[:is_public] = resource[:is_public].downcase.to_sym @property_hash[:name] = name unless @resource[:access_project_ids].nil? set_access_project_ids(resource[:access_project_ids]) @@ -85,10 +85,10 @@ Puppet::Type.type(:cinder_type).provide( if type[:is_public] == 'False' type_details = request('volume type', 'show', type[:id]) type[:access_project_ids] = string2array(type_details[:access_project_ids]) - type[:is_public] = false + type[:is_public] = :false else type[:access_project_ids] = [] - type[:is_public] = true + type[:is_public] = :true end end diff --git a/lib/puppet/type/cinder_qos.rb b/lib/puppet/type/cinder_qos.rb index 1a40c4ee..45655531 100644 --- a/lib/puppet/type/cinder_qos.rb +++ b/lib/puppet/type/cinder_qos.rb @@ -31,9 +31,10 @@ Puppet::Type.newtype(:cinder_qos) do end end - newparam(:consumer) do + newproperty(:consumer) do desc 'The consumer QOS' - defaultto('') + newvalues('front-end', 'back-end', 'both') + defaultto('both') end autorequire(:cinder_qos) do diff --git a/lib/puppet/type/cinder_type.rb b/lib/puppet/type/cinder_type.rb index 57d1f58d..3f21c840 100644 --- a/lib/puppet/type/cinder_type.rb +++ b/lib/puppet/type/cinder_type.rb @@ -19,10 +19,10 @@ Puppet::Type.newtype(:cinder_type) do end end - newparam(:is_public, :boolean => true) do + newproperty(:is_public, :boolean => true) do desc 'Whether the type is public or not. Default to `true`' newvalues(:true, :false) - defaultto true + defaultto :true end newproperty(:access_project_ids, :array_matching => :all) do diff --git a/spec/acceptance/10_basic_cinder_spec.rb b/spec/acceptance/10_basic_cinder_spec.rb index e6a073c2..910e109a 100644 --- a/spec/acceptance/10_basic_cinder_spec.rb +++ b/spec/acceptance/10_basic_cinder_spec.rb @@ -38,6 +38,9 @@ describe 'basic cinder' do cinder_qos { 'testqos2': associations => ['qostype1', 'qostype2'] } + cinder_qos { 'testqos3': + consumer => 'front-end', + } EOS diff --git a/spec/unit/provider/cinder_qos/openstack_spec.rb b/spec/unit/provider/cinder_qos/openstack_spec.rb index 6ed67891..815aede0 100644 --- a/spec/unit/provider/cinder_qos/openstack_spec.rb +++ b/spec/unit/provider/cinder_qos/openstack_spec.rb @@ -34,7 +34,7 @@ describe provider_class do describe '#create' do it 'creates a qos' do expect(provider_class).to receive(:openstack) - .with('volume qos', 'create', '--format', 'shell', ['--property', 'key1=value1', '--property', 'key2=value2', 'QoS_1']) + .with('volume qos', 'create', '--format', 'shell', ['--consumer', 'both', '--property', 'key1=value1', '--property', 'key2=value2', 'QoS_1']) .and_return('id="e0df397a-72d5-4494-9e26-4ac37632ff04" name="QoS_1" properties="{\'key1\': \'value1\', \'key2\': \'value2\'}" diff --git a/spec/unit/provider/cinder_type/openstack_spec.rb b/spec/unit/provider/cinder_type/openstack_spec.rb index e5b9bcec..a5a9cabf 100644 --- a/spec/unit/provider/cinder_type/openstack_spec.rb +++ b/spec/unit/provider/cinder_type/openstack_spec.rb @@ -82,8 +82,8 @@ access_project_ids="54f4d231201b4944a5fa4587a09bda23, 54f4d231201b4944a5fa4587a0 expect(instances.count).to eq(2) expect(instances[0].name).to eq('type-1') expect(instances[1].name).to eq('type-2') - expect(instances[0].is_public).to be true - expect(instances[1].is_public).to be false + expect(instances[0].is_public).to be :true + expect(instances[1].is_public).to be :false expect(instances[0].access_project_ids).to match_array([]) expect(instances[1].access_project_ids).to match_array(['54f4d231201b4944a5fa4587a09bda23', '54f4d231201b4944a5fa4587a09bda28']) expect(instances[0].properties).to eq({'key1'=>'value1'})