Sha256: fb5c2f59d8bf32dbe4eebc1f697e3aab67d52ad90ed8ba8545d8f6eacea0b942

Contents?: true

Size: 1.7 KB

Versions: 39

Compression:

Stored size: 1.7 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 = 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

39 entries across 37 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.10 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.1.30 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.1.29 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.9 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.1.28 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.8 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.7 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.6 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.5 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.4 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.3 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.2 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.3.0 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.2.4 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.2.3 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.2.2 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.2.1 lib/fog/image/openstack/v2/requests/create_image.rb
fog-openstack-0.2.0 lib/fog/image/openstack/v2/requests/create_image.rb
fog-zj-0.1.28 lib/fog/image/openstack/v2/requests/create_image.rb