Sha256: c954f8782efdac5ce2071772b674627779c1f5a9ecf2a0dc2bda10893bb1254d

Contents?: true

Size: 1.46 KB

Versions: 40

Compression:

Stored size: 1.46 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real
        def create_image(server_id, name, metadata={})
          body = { 'createImage' => {
            'name' => name,
            'metadata' => metadata
          }}
          data = server_action(server_id, body)
          image_id = data.headers["Location"].scan(/.*\/(.*)/).flatten[0]
          get_image_details(image_id)
        end
      end

      class Mock
        def create_image(server_id, name, metadata={})
          response = Excon::Response.new
          response.status = 202

          img_id=Fog::Mock.random_numbers(6).to_s

          data = {
            'id'        => img_id,
            'server'     => {"id"=>"3", "links"=>[{"href"=>"http://nova1:8774/admin/servers/#{server_id}", "rel"=>"bookmark"}]},
            'links'     => [{"href"=>"http://nova1:8774/v1.1/admin/images/#{img_id}", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/images/#{img_id}", "rel"=>"bookmark"}],
            'metadata'  => metadata || {},
            'name'      => name || "server_#{rand(999)}",
            'progress'  => 0,
            'status'    => 'SAVING',
            'minDisk'   => 0,
            'minRam'    => 0,
            'updated'   => "",
            'created'   => ""
          }
          self.data[:last_modified][:images][data['id']] = Time.now
          self.data[:images][data['id']] = data
          response.body = { 'image' => data }
          response
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.9 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.8 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.7 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.6 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.5 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.4 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.3 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.2 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.1 lib/fog/openstack/requests/compute/create_image.rb
fog-openstack-0.1.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.37.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.36.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.35.0 lib/fog/openstack/requests/compute/create_image.rb
fog-2.0.0.pre.0 lib/fog/openstack/requests/compute/create_image.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/openstack/requests/compute/create_image.rb
fog-1.34.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.33.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.32.0 lib/fog/openstack/requests/compute/create_image.rb
fog-1.31.0 lib/fog/openstack/requests/compute/create_image.rb