Sha256: 3809408dc93dd58a5fc4365e07b6924c28cb1b1b5868130ce0407e5ebdeba4e4

Contents?: true

Size: 1.46 KB

Versions: 23

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
          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

23 entries across 23 versions & 7 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
michiels-fog-1.3.1 lib/fog/openstack/requests/compute/create_image.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
fog-1.3.1 lib/fog/openstack/requests/compute/create_image.rb
fog-1.3.0 lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
fog-1.2.0 lib/fog/openstack/requests/compute/create_image.rb
ktheory-fog-1.1.2 lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
fog-1.1.2 lib/fog/openstack/requests/compute/create_image.rb
fog_tractical-1.1.4 lib/fog/openstack/requests/compute/create_image.rb
fog_tractical-1.1.3 lib/fog/openstack/requests/compute/create_image.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb
fog-1.1.1 lib/fog/openstack/requests/compute/create_image.rb
fog-1.1.0 lib/fog/openstack/requests/compute/create_image.rb