diff --git a/lib/puppet/provider/glance_image/openstack.rb b/lib/puppet/provider/glance_image/openstack.rb index b35c1c4c..7678ba31 100644 --- a/lib/puppet/provider/glance_image/openstack.rb +++ b/lib/puppet/provider/glance_image/openstack.rb @@ -140,7 +140,7 @@ Puppet::Type.type(:glance_image).provide( :disk_format => attrs[:disk_format], :min_disk => attrs[:min_disk], :min_ram => attrs[:min_ram], - :properties => properties + :properties => exclude_readonly_props(properties) ) end end @@ -173,7 +173,19 @@ Puppet::Type.type(:glance_image).provide( private + def self.exclude_readonly_props(props) + if props == nil + return nil + end + hidden = ['os_hash_algo', 'os_hash_value', 'os_hidden'] + rv = props.select { |k, v| not hidden.include?(k) } + return rv + end + def props_to_s(props) - props.flat_map{ |k, v| ['--property', "#{k}=#{v}"] } + hidden = ['os_hash_algo', 'os_hash_value', 'os_hidden'] + props.flat_map{ |k, v| + ['--property', "#{k}=#{v}"] unless hidden.include?(k) + }.compact end end diff --git a/spec/acceptance/basic_glance_spec.rb b/spec/acceptance/basic_glance_spec.rb index cca6a973..f9796ab0 100644 --- a/spec/acceptance/basic_glance_spec.rb +++ b/spec/acceptance/basic_glance_spec.rb @@ -38,7 +38,7 @@ describe 'glance class' do expect(r.stdout).to match(/visibility="public"/) expect(r.stdout).to match(/container_format="bare"/) expect(r.stdout).to match(/disk_format="qcow2"/) - expect(r.stdout).to match(/properties="icanhaz='cheezburger'"/) + expect(r.stdout).to include('properties="icanhaz=\'cheezburger\'') expect(r.stdout).to match(/min_ram="64"/) expect(r.stdout).to match(/min_disk="1024"/) end diff --git a/spec/unit/provider/glance_image_spec.rb b/spec/unit/provider/glance_image_spec.rb index aaded117..586891f1 100644 --- a/spec/unit/provider/glance_image_spec.rb +++ b/spec/unit/provider/glance_image_spec.rb @@ -97,7 +97,7 @@ min_disk="1024" min_ram="1024" name="image1" owner="None" -properties="{}" +properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'" protected="False" size="1270" status="active" @@ -150,7 +150,7 @@ min_disk="1024" min_ram="1024" name="image1" owner="5a9e521e17014804ab8b4e8b3de488a4" -properties="something=\'what\', vmware_disktype=\'sparse\'" +properties="something=\'what\', vmware_disktype=\'sparse\', os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'" protected="False" schema="/v2/schemas/image" size="13287936" @@ -187,7 +187,7 @@ min_disk="1024" min_ram="1024" name="image1" owner="None" -properties="something=\'what\', vmware_disktype=\'sparse\'" +properties="something=\'what\', vmware_disktype=\'sparse\', os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'" protected="False" size="1270" status="active" @@ -196,6 +196,7 @@ virtual_size="None" ') instances = provider_class.instances expect(instances.count).to eq(1) + expect(instances[0].properties).to eq({ 'something' => 'what', 'vmware_disktype' => 'sparse' }) end end @@ -238,7 +239,7 @@ min_disk="0" min_ram="0" name="image1" owner="5a9e521e17014804ab8b4e8b3de488a4" -properties="{}" +properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'" protected="False" schema="/v2/schemas/image" size="13287936" @@ -275,7 +276,7 @@ min_ram="0" visibility="public" name="image1" owner="None" -properties="{}" +properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'" protected="False" size="1270" status="active"