Method: Ropenstack::Image::Version2#upload_image_from_file
- Defined in:
- lib/ropenstack/image/v2.rb
#upload_image_from_file(name, disk_format, container_format, minDisk, minRam, is_public, file) ⇒ Object
Upload an image to the Image Service from a file, takes in a ruby file object. More convoluted than it should be because for a bug in Quantum which just returns an error no matter the outcome.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ropenstack/image/v2.rb', line 80 def upload_image_from_file(name, disk_format, container_format, minDisk, minRam, is_public, file) data = { "name" => name, "disk_format" => disk_format, "container_format" => container_format, "minDisk" => minDisk, "minRam" => minRam, "public" => is_public } imagesBefore = images() post_request(address("images"), data, @token, false) imagesAfter = images() foundNewImage = true image = nil imagesAfter.each do |imageA| imagesBefore.each do |imageB| if(imageA == imageB) foundNewImage = false end end if(foundNewImage) image = imageA break end end return put_octect(address(image["file"]), file.read, false) end |