Class: ImageBundler

Inherits:
BundleTool show all
Defined in:
lib/ec2/amitools/bundleimage.rb

Constant Summary

Constants inherited from AMITool

AMITool::BACKOFF_PERIOD, AMITool::MAX_TRIES, AMITool::PROMPT_TIMEOUT

Instance Method Summary collapse

Methods inherited from BundleTool

#get_parameters, #notify, #user_override

Methods inherited from AMITool

#get_parameters, #handle_early_exit_parameters, #interactive?, #interactive_prompt, #retry_s3, #run, #warn_confirm

Instance Method Details

#bundle_image(p) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ec2/amitools/bundleimage.rb', line 35

def bundle_image(p)
  if p.size_checks
    file_size = File.size(p.image_path)
    if file_size <= 0
      raise "the specified image #{p.image_path} is zero sized"
    elsif file_size > MAX_SIZE
      raise "the specified image #{p.image_path} is too large"
    end
  else
    $stderr.puts 'Warning: disabling size-checks can result in unbootable image'
  end
  
  optional_args = {
    :kernel_id => p.kernel_id,
    :ramdisk_id => p.ramdisk_id,
    :product_codes => p.product_codes,
    :ancestor_ami_ids => p.ancestor_ami_ids,
    :block_device_mapping => p.block_device_mapping,
  }
  $stdout.puts 'Bundling image file...'
  
  Bundle.bundle_image(File::expand_path(p.image_path),
                      p.user,
                      p.arch,
                      Bundle::ImageType::MACHINE,
                      p.destination,
                      p.user_pk_path,
                      p.user_cert_path,
                      p.ec2_cert_path,
                      p.prefix,
                      optional_args,
                      @debug,
                      false)
  
  $stdout.puts( "#{BUNDLE_IMAGE_NAME} complete." )
end

#get_manualObject

——————————————————————————# Overrides ——————————————————————————#



76
77
78
# File 'lib/ec2/amitools/bundleimage.rb', line 76

def get_manual()
  BUNDLE_IMAGE_MANUAL
end

#get_nameObject



80
81
82
# File 'lib/ec2/amitools/bundleimage.rb', line 80

def get_name()
  BUNDLE_IMAGE_NAME
end

#main(p) ⇒ Object



84
85
86
# File 'lib/ec2/amitools/bundleimage.rb', line 84

def main(p)
  bundle_image(p)
end