Sha256: 82a2c8c1a74dfa7a566dbeff36a60b4150f673a1482a598d9407caa754ff97cc

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        require 'fog/aws/parsers/ec2/create_image'

        # Create a bootable EBS volume AMI
        #
        # ==== Parameters
        # * instance_id<~String> - Instance used to create image.
        # * name<~Name> - Name to give image.
        # * description<~Name> - Description of image.
        # * no_reboot<~Boolean> - Optional, whether or not to reboot the image when making the snapshot
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'imageId'<~String> - The ID of the created AMI.
        #     * 'requestId'<~String> - Id of request.
        def create_image(instance_id, name, description, no_reboot = false)
          request(
            'Action'            => 'CreateImage',
            'InstanceId'        => instance_id,
            'Name'              => name,
            'Description'       => description,
            'NoReboot'          => no_reboot.to_s,
            :parser             => Fog::Parsers::AWS::EC2::CreateImage.new
          )
        end
      end

      class Mock

        def create_image(instance_id, name, description, no_reboot = false)
          response = Excon::Response.new
          if instance_id && !name.empty?
            response.status = 200
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'imageId' => Fog::AWS::Mock.image_id
            }
          else
            response.status = 400
            response.body = {
              'Code' => 'InvalidParameterValue'
            }
            if name.empty?
              response.body['Message'] = "Invalid value '' for name. Must be specified."
            end
          end
          response
        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.28 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.27 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.26 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.25 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.24 lib/fog/aws/requests/ec2/create_image.rb
tecnh-fog-0.2.23.vpc lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.23 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.22 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.21 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.20 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.19 lib/fog/aws/requests/ec2/create_image.rb
fog-0.2.18 lib/fog/aws/requests/ec2/create_image.rb