Sha256: dafd7208bfe680499cbdc480c31eb47e01c9b7afb8ce1e4b732b326155e76a71

Contents?: true

Size: 1.62 KB

Versions: 14

Compression:

Stored size: 1.62 KB

Contents

module Fog
  module Image
    class OpenStack
      class V2
        class Real

          def create_image(image)
            location = image.delete :location
            headers = {}
            headers["Location"] = location if location

            request(
                :headers => headers,
                :expects => [201],
                :method => 'POST',
                :path => "images",
                :body => Fog::JSON.encode(image)
            )
          end

        end


        class Mock
          def create_image(attributes)
            response = Excon::Response.new
            response.status = 201

            image_id = Fog::Mock.random_hex(32)
            image = self.data[:images][image_id] = {
                'tags' => attributes[:tags] || [],
                'name' => attributes[:name],
                'size' => nil,
                'min_disk' => attributes[:min_disk] || 0,
                'disk_format' => attributes[:disk_format] || 'raw',
                'created_at' => Time.now.strftime('%FT%T.%6N'),
                'container_format' => attributes[:container_format] || 'bare',
                'deleted_at' => nil,
                'updated_at' => Time.now.strftime('%FT%T.%6N'),
                'checksum' => nil,
                'id' => image_id,
                'visibility' => attributes[:visibility] || 'public',
                'status' => 'queued',
                'min_ram' => attributes[:min_ram] || 0,
                'owner' => attributes[:owner] || Fog::Mock.random_hex(32)
            }
            response.body = image
            response
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.9 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.8 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.7 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.6 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.5 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.4 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.3 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.2 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.1 lib/fog/openstack/requests/image_v2/create_image.rb
fog-openstack-0.1.0 lib/fog/openstack/requests/image_v2/create_image.rb
fog-1.37.0 lib/fog/openstack/requests/image_v2/create_image.rb
fog-1.36.0 lib/fog/openstack/requests/image_v2/create_image.rb
fog-1.35.0 lib/fog/openstack/requests/image_v2/create_image.rb