def create_image(attributes)
data = {
"Content-Type"=>"application/octet-stream",
"x-image-meta-name" => attributes[:name],
"x-image-meta-disk-format" => attributes[:disk_format],
"x-image-meta-container-format" => attributes[:container_format],
"x-image-meta-size" => attributes[:size],
"x-image-meta-is-public" => attributes[:is_public],
"x-image-meta-owner" => attributes[:owner],
"x-glance-api-copy-from" => attributes[:copy_from]
}
body = String.new
if attributes[:location]
file = File.open(attributes[:location], "rb")
body = file
end
unless attributes[:properties].nil?
attributes[:properties].each do |key,value|
data["x-image-meta-property-#{key}"] = value
end
end
request(
:headers => data,
:body => body,
:expects => 201,
:method => 'POST',
:path => "images"
)
ensure
body.close if body.respond_to?(:close)
end