glance_image provider fails with puppet >= 3.0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
puppet-glance |
Fix Released
|
High
|
Ivan Chavero (imcsk8) | ||
Havana |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
The glance_image provider fails to detect existing images with puppet 3.x (tested with 3.1.1 & 3.2.2) and adds images at each puppet run …
This is the output of "puppet resource …" using puppet 2.7.22
root@
2.7.22
root@
glance_image { 'cirros':
ensure => 'present',
container
disk_format => 'qcow2',
id => '85169467-
is_public => 'Yes',
}
root@
glance_image { 'cirros':
ensure => 'present',
container
disk_format => 'qcow2',
id => '85169467-
is_public => 'Yes',
}
This is the output of "puppet resource …" using puppet 3.2.2
root@
3.2.2
root@
glance_image { '["cirros"]':
ensure => 'present',
container
disk_format => '["qcow2"]',
id => '["85169467-
is_public => '["Yes"]',
}
root@
glance_image { 'cirros':
ensure => 'absent',
}
affects: | puppet-openstack → puppet-glance |
Changed in puppet-glance: | |
importance: | Undecided → High |
status: | New → Triaged |
Changed in puppet-glance: | |
assignee: | nobody → Ivan Chavero (imcsk8) (ichavero-ichavero) |
Changed in puppet-glance: | |
milestone: | none → 4.0.0 |
Changed in puppet-glance: | |
status: | Fix Committed → Fix Released |
After a quite painful debugging i found that the self.get_ glance_ image_attrs function converts directly to string the result of a split operation, this split is done on the output of a glance show call [1]:
(auth_glance( 'show', id).split("\n") || []).collect do |line|
attrs[ line.split( ': ').first.downcase] = line.split(': ')[1..-1].to_s
end
this function is called from the instances function that is used by prefetch which populates the @property_hash variable with the wrong values:
#<Puppet: :Type:: Glance_ image:: ProviderGl 75d0d8 @property_ hash={: ensure= >:present, :name=> "[\"cirros\ "]", :is_public= >"[\"Yes\ "]", :container_format \"1ffa10a0- a587-4c21- 8af3-e667f6e123 fd\"]", :disk_format= >"[\"qcow2\ "]"}>
ance:0x00000004
=>"[\"bare\"]", :id=>"[
in ruby 2.0.0 and 1.9 if you do a var.to_s operation over an array you'll get a string representation of the array not the contents of the array eg:
$ irb
irb(main):001:0> name = ["cirros"]
=> ["cirros"]
irb(main):002:0> txtvar = name.to_s
=> "[\"cirros\"]"
irb(main):003:0> print txtvar
["cirros"]=> nil
which differs from the ruby 1.8 behaviour in which the to_s operation on an array returns the contents of the array as a string:
$ irb18
irb(main):001:0> name = ["cirros"]
=> ["cirros"]
irb(main):002:0> txtvar = name.to_s
=> "cirros"
irb(main):003:0> print txtvar
cirros=> nil
instead of calling to_s we can the pop function to get the correct value (this also works in ruby 1.8):
irb(main):004:0> txtvar = name.pop
=> "cirros"
irb(main):005:0> print txtvar
cirros=> nil
[1] https:/ /github. com/stackforge/ puppet- glance/ blob/master/ lib/puppet/ provider/ glance. rb#L129