Class: ImageOptimize::ImageBundleEc2Base

Inherits:
ImageBundleBase show all
Defined in:
lib/image_bundle/image_bundle_ec2.rb

Overview

Base class for snapshoting and registration of EC2 images

Direct Known Subclasses

ImageBundleEc2EBS, ImageBundleEc2S3

Constant Summary collapse

RETRY_TIMEOUT_SEC =

2 hr

2 * 60 * 60

Instance Method Summary collapse

Methods inherited from ImageBundleBase

#add_image_to_next_instance, #log, #snapshot_instance

Methods included from Command

#debug, #execute

Methods included from Common

#not_implemented

Constructor Details

#initialize(instance_api_client, full_api_client, aws_access_key, aws_secret_key, kernel_id_override = nil) ⇒ ImageBundleEc2Base

Returns a new instance of ImageBundleEc2Base.



25
26
27
28
29
30
31
# File 'lib/image_bundle/image_bundle_ec2.rb', line 25

def initialize(instance_api_client, full_api_client, aws_access_key, aws_secret_key, kernel_id_override = nil)
  
  @aws_access_key = aws_access_key
  @aws_secret_key = aws_secret_key
  @kernel_override = kernel_id_override
  super(instance_api_client, full_api_client)
end

Instance Method Details

#register_image(name = nil, description = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/image_bundle/image_bundle_ec2.rb', line 33

def register_image(name=nil, description=nil)
  cmd = register_command(name, description)
  @log.info "Running register image command..."
  unless @dry_run
    status, cmd_output = execute(cmd)
    raise "FATAL: unable to register new image" unless status.exitstatus == 0
    image_uuid = parse_ami(cmd_output)
    @log.info "New image: #{image_uuid}"

    # wait for image to be available
    wait_for_image(image_uuid)
  end
end