Fix properties for glance_image provider
There are some changes in Glance where it now does som calculus on the image and adds these three new values to the image properties. [1] This change fixes so we dont update these properties when we flush or create the glance_image resource. It also changes the spec acceptance so it tests if our custom property is there and not the only property. [1] https://github.com/openstack/glance/blob/master/releasenotes/notes/multihash-081466a98601da20.yaml Co-Authored-By: Alex Schultz <aschultz@redhat.com> Change-Id: I7f1245be6c2446f0d4336630e800da3e110f3408
This commit is contained in:
parent
a65de83e2c
commit
f0137bfc94
|
@ -140,7 +140,7 @@ Puppet::Type.type(:glance_image).provide(
|
||||||
:disk_format => attrs[:disk_format],
|
:disk_format => attrs[:disk_format],
|
||||||
:min_disk => attrs[:min_disk],
|
:min_disk => attrs[:min_disk],
|
||||||
:min_ram => attrs[:min_ram],
|
:min_ram => attrs[:min_ram],
|
||||||
:properties => properties
|
:properties => exclude_readonly_props(properties)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -173,7 +173,19 @@ Puppet::Type.type(:glance_image).provide(
|
||||||
|
|
||||||
private
|
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)
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe 'glance class' do
|
||||||
expect(r.stdout).to match(/visibility="public"/)
|
expect(r.stdout).to match(/visibility="public"/)
|
||||||
expect(r.stdout).to match(/container_format="bare"/)
|
expect(r.stdout).to match(/container_format="bare"/)
|
||||||
expect(r.stdout).to match(/disk_format="qcow2"/)
|
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_ram="64"/)
|
||||||
expect(r.stdout).to match(/min_disk="1024"/)
|
expect(r.stdout).to match(/min_disk="1024"/)
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,7 +97,7 @@ min_disk="1024"
|
||||||
min_ram="1024"
|
min_ram="1024"
|
||||||
name="image1"
|
name="image1"
|
||||||
owner="None"
|
owner="None"
|
||||||
properties="{}"
|
properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'"
|
||||||
protected="False"
|
protected="False"
|
||||||
size="1270"
|
size="1270"
|
||||||
status="active"
|
status="active"
|
||||||
|
@ -150,7 +150,7 @@ min_disk="1024"
|
||||||
min_ram="1024"
|
min_ram="1024"
|
||||||
name="image1"
|
name="image1"
|
||||||
owner="5a9e521e17014804ab8b4e8b3de488a4"
|
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"
|
protected="False"
|
||||||
schema="/v2/schemas/image"
|
schema="/v2/schemas/image"
|
||||||
size="13287936"
|
size="13287936"
|
||||||
|
@ -187,7 +187,7 @@ min_disk="1024"
|
||||||
min_ram="1024"
|
min_ram="1024"
|
||||||
name="image1"
|
name="image1"
|
||||||
owner="None"
|
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"
|
protected="False"
|
||||||
size="1270"
|
size="1270"
|
||||||
status="active"
|
status="active"
|
||||||
|
@ -196,6 +196,7 @@ virtual_size="None"
|
||||||
')
|
')
|
||||||
instances = provider_class.instances
|
instances = provider_class.instances
|
||||||
expect(instances.count).to eq(1)
|
expect(instances.count).to eq(1)
|
||||||
|
expect(instances[0].properties).to eq({ 'something' => 'what', 'vmware_disktype' => 'sparse' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,7 +239,7 @@ min_disk="0"
|
||||||
min_ram="0"
|
min_ram="0"
|
||||||
name="image1"
|
name="image1"
|
||||||
owner="5a9e521e17014804ab8b4e8b3de488a4"
|
owner="5a9e521e17014804ab8b4e8b3de488a4"
|
||||||
properties="{}"
|
properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'"
|
||||||
protected="False"
|
protected="False"
|
||||||
schema="/v2/schemas/image"
|
schema="/v2/schemas/image"
|
||||||
size="13287936"
|
size="13287936"
|
||||||
|
@ -275,7 +276,7 @@ min_ram="0"
|
||||||
visibility="public"
|
visibility="public"
|
||||||
name="image1"
|
name="image1"
|
||||||
owner="None"
|
owner="None"
|
||||||
properties="{}"
|
properties="os_hash_algo=\'abc123\', os_hash_value=\'test123\', os_hidden=\'true\'"
|
||||||
protected="False"
|
protected="False"
|
||||||
size="1270"
|
size="1270"
|
||||||
status="active"
|
status="active"
|
||||||
|
|
Loading…
Reference in New Issue