Class: ImageOptimize::ImageBundleEc2S3

Inherits:
ImageBundleEc2Base show all
Defined in:
lib/image_bundle/image_bundle_ec2_s3.rb

Overview

Handles the snapshoting and registration of EBS based images

Constant Summary collapse

BUNDLE_DIR =
"/mnt/ephemeral/bundle"

Constants inherited from ImageBundleEc2Base

ImageOptimize::ImageBundleEc2Base::RETRY_TIMEOUT_SEC

Instance Method Summary collapse

Methods inherited from ImageBundleEc2Base

#register_image

Methods inherited from ImageBundleBase

#add_image_to_next_instance, #log, #register_image

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, aws_account_number, x509_key_file, x509_cert_file, s3_bucket, bundle_dir = nil, no_filter = nil, kernel_id = nil) ⇒ ImageBundleEc2S3

x509_key_file : [String] Absolute path to file holding AWS x.509 private key file x509_cert_file : [String] Absolute path to file holding AWS x.509 certificate file s3_bucket : [String] place to store image in S3



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/image_bundle/image_bundle_ec2_s3.rb', line 31

def initialize(instance_api_client, full_api_client, aws_access_key, aws_secret_key, , x509_key_file, x509_cert_file,  s3_bucket, bundle_dir=nil, no_filter=nil, kernel_id = nil)
  super(instance_api_client, full_api_client, aws_access_key, aws_secret_key, kernel_id)
  @aws_account_number = 
  raise "no aws account number specified." unless @aws_account_number
  @key_file = x509_key_file
  raise "no path to x.509 private key file specified." unless @key_file
  @cert_file = x509_cert_file
  raise "no path to x.509 certificate file specified." unless @cert_file

  @bucket = s3_bucket

  # Where to place temporary image bundle before upload
  @bundle_dir = bundle_dir
  @bundle_dir ||= BUNDLE_DIR

  # --no-filter
  @no_filter = true if no_filter
end

Instance Method Details

#register_command(name, description) ⇒ Object

Turn the VM “snapshot” into an launchable image



58
59
60
61
62
# File 'lib/image_bundle/image_bundle_ec2_s3.rb', line 58

def register_command(name, description)
  #ec2-register my-s3-bucket/image_bundles/name/image.manifest.xml -n name -O your_access_key_id -W your_secret_access_key
  cmd = "ec2-register #{@bucket}/image_bundles/#{name}/image.manifest.xml -n #{name} -O #{@aws_access_key} -W #{@aws_secret_key} --region #{region} --architecture x86_64 --description '#{description}' #{common_options}"
  cmd
end

#snapshot_instance(name, description) ⇒ Object

Captures a “snapshot” of the current VM configuration



51
52
53
54
55
# File 'lib/image_bundle/image_bundle_ec2_s3.rb', line 51

def snapshot_instance(name, description)
  bundle_image(name)
  upload_bundle(name)
  cleanup_bundle
end