Update glance_image provider with API v2

Some arguments are deprecated in API v2.
This patch aims to update glance_image provider to fit with the
OpenStack Images API v2.0 (latest stable).

Note: Glance API v2 is by default from OpenStack Folsom release.

Change-Id: Ic06a839324aa0a6e11b16a13ad8927a1da6e13e4
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi 2014-01-20 04:44:40 +01:00 committed by Gerrit Code Review
parent 833c3845a2
commit cea9f69ad5
1 changed files with 9 additions and 9 deletions

View File

@ -50,19 +50,19 @@ Puppet::Type.type(:glance_image).provide(
location = "< #{resource[:source]}"
stdin = true
else
location = "copy_from=#{resource[:source]}"
location = "--copy-from=#{resource[:source]}"
end
# location cannot handle file://
# location does not import, so no sense in doing anything more than this
elsif resource[:location]
location = "location=#{resource[:location]}"
location = "--location=#{resource[:location]}"
else
raise(Puppet::Error, "Must specify either source or location")
end
if stdin
result = auth_glance_stdin('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
result = auth_glance_stdin('image-create', "--name=#{resource[:name]}", "--is-public=#{resource[:is_public]}", "--container-format=#{resource[:container_format]}", "--disk-format=#{resource[:disk_format]}", location)
else
results = auth_glance('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
results = auth_glance('image-create', "--name=#{resource[:name]}", "--is-public=#{resource[:is_public]}", "--container-format=#{resource[:container_format]}", "--disk-format=#{resource[:disk_format]}", location)
end
if results =~ /Added new image with ID: (\S+)/
@property_hash = {
@ -79,24 +79,24 @@ Puppet::Type.type(:glance_image).provide(
end
def destroy
auth_glance('delete', id)
auth_glance('image-delete', id)
@property_hash[:ensure] = :absent
end
def location=(value)
auth_glance('update', id, "location=#{value}")
auth_glance('image-update', id, "--location=#{value}")
end
def is_public=(value)
auth_glance('update', id, "is_public=#{value}")
auth_glance('image-update', id, "--is-public=#{value}")
end
def disk_format=(value)
auth_glance('update', id, "disk_format=#{value}")
auth_glance('image-update', id, "--disk-format=#{value}")
end
def container_format=(value)
auth_glance('update', id, "container_format=#{value}")
auth_glance('image-update', id, "--container-format=#{value}")
end
def id=(id)