Fix glance_image for local images

When trying to upload an image from the local file system, the
resource provider was failing. Fixing it to use the --file option
for the glance client instead of going through stdin.

Change-Id: Ic6bade025d28e2eb33f86c2d4421b65d06e8274c
This commit is contained in:
Javier Pena 2014-11-05 11:06:47 +01:00
parent fced3226c2
commit 90bf62341d
1 changed files with 2 additions and 8 deletions

View File

@ -43,12 +43,10 @@ Puppet::Type.type(:glance_image).provide(
end
def create
stdin = nil
if resource[:source]
# copy_from cannot handle file://
if resource[:source] =~ /^\// # local file
location = "< #{resource[:source]}"
stdin = true
location = "--file=#{resource[:source]}"
else
location = "--copy-from=#{resource[:source]}"
end
@ -59,11 +57,7 @@ Puppet::Type.type(:glance_image).provide(
else
raise(Puppet::Error, "Must specify either source or location")
end
if stdin
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('image-create', "--name=#{resource[:name]}", "--is-public=#{resource[:is_public]}", "--container-format=#{resource[:container_format]}", "--disk-format=#{resource[:disk_format]}", location)
end
results = auth_glance('image-create', "--name=#{resource[:name]}", "--is-public=#{resource[:is_public]}", "--container-format=#{resource[:container_format]}", "--disk-format=#{resource[:disk_format]}", location)
id = nil