class MigrateBundleParameters
Constants
- ACL_DESCRIPTION
- BUCKET_DESCRIPTION
- DEST_BUCKET_DESCRIPTION
- DIRECTORY_DESCRIPTION
- EC2_CERT_PATH_DESCRIPTION
- KERNEL_DESCRIPTION
- LOCATION_DESCRIPTION
- MANIFEST_DESCRIPTION
- NO_MAPPING_DESCRIPTION
- PASS_DESCRIPTION
- RAMDISK_DESCRIPTION
- REGION_DESCRIPTION
- RETRY_DESCRIPTION
- URL_DESCRIPTION
- USER_CERT_PATH_DESCRIPTION
- USER_DESCRIPTION
- USER_PK_PATH_DESCRIPTION
Attributes
acl[RW]
bucket[RW]
dest_bucket[RW]
dest_keyprefix[RW]
ec2_cert_path[RW]
kernel_id[RW]
keyprefix[RW]
location[RW]
manifest_name[RW]
pass[RW]
ramdisk_id[RW]
region[RW]
retry[RW]
s3_url[RW]
use_mapping[RW]
user[RW]
user_cert_path[RW]
user_pk_path[RW]
Public Instance Methods
help()
click to toggle source
Calls superclass method
# File lib/ec2/amitools/migratebundleparameters.rb, line 166 def help() s = "*** This tool is deprecated. ***\n" s += "Please consider using ec2-migrate-image from the EC2 API tools.\n" s += "You can download the EC2 API tools here:\n" s += "http://aws.amazon.com/developertools/351\n" s += super() end
mandatory_params()
click to toggle source
# File lib/ec2/amitools/migratebundleparameters.rb, line 68 def mandatory_params() on('-c', '--cert PATH', String, USER_CERT_PATH_DESCRIPTION) do |path| assert_file_exists(path, '--cert') @user_cert_path = path end on('-k', '--privatekey PATH', String, USER_PK_PATH_DESCRIPTION) do |path| assert_file_exists(path, '--privatekey') @user_pk_path = path end on('-m', '--manifest NAME', String, MANIFEST_DESCRIPTION) do |manifest| raise InvalidValue.new("--manifest", manifest) unless manifest =~ /\.manifest\.xml$/ assert_good_key(manifest, '--manifest') @manifest_name = manifest end on('-b', '--bucket BUCKET', String, BUCKET_DESCRIPTION) do |container| @container = container @bucket, @keyprefix = split_container(@container) end on('-d', '--destination-bucket BUCKET', String, DEST_BUCKET_DESCRIPTION) do |dest_container| @dest_container = dest_container @dest_bucket, @dest_keyprefix = split_container(@dest_container) end on('-a', '--access-key USER', String, USER_DESCRIPTION) do |user| @user = user end on('-s', '--secret-key PASSWORD', String, PASS_DESCRIPTION) do |pass| @pass = pass end end
optional_params()
click to toggle source
# File lib/ec2/amitools/migratebundleparameters.rb, line 104 def optional_params() on('--ec2cert PATH', String, *EC2_CERT_PATH_DESCRIPTION) do |path| assert_file_exists(path, '--ec2cert') @ec2_cert_path = path end on('--acl ACL', String, *ACL_DESCRIPTION) do |acl| raise InvalidValue.new('--acl', acl) unless ['public-read', 'aws-exec-read'].include?(acl) @acl = acl end on('--url URL', String, URL_DESCRIPTION) do |url| @s3_url = url end on('--retry', RETRY_DESCRIPTION) do @retry = true end on('--location LOCATION', LOCATION_DESCRIPTION) do |location| assert_option_in(location, AwsRegion.s3_locations, '--location') @location = case location when "eu-west-1" then "EU" when "US" then :unconstrained else location end end on('--kernel KERNEL_ID', String, KERNEL_DESCRIPTION) do |kernel_id| @kernel_id = kernel_id end on('--ramdisk RAMDISK_ID', String, RAMDISK_DESCRIPTION) do |ramdisk_id| @ramdisk_id = ramdisk_id end on('--no-mapping', String, NO_MAPPING_DESCRIPTION) do @use_mapping = false end on('--region REGION', String, REGION_DESCRIPTION) do |region| @region = region end end
set_defaults()
click to toggle source
# File lib/ec2/amitools/migratebundleparameters.rb, line 159 def set_defaults() @acl ||= 'aws-exec-read' @s3_url ||= 'https://s3.amazonaws.com' @ec2_cert_path ||= Bundling::EC2_X509_CERT @use_mapping = true if @use_mapping.nil? # False is different. end
split_container(container)
click to toggle source
# File lib/ec2/amitools/migratebundleparameters.rb, line 60 def split_container(container) splitbits = container.sub(%r{^/*},'').sub(%r{/*$},'').split("/") bucket = splitbits.shift keyprefix = splitbits.join("/") keyprefix += "/" unless keyprefix.empty? [bucket, keyprefix] end
validate_params()
click to toggle source
# File lib/ec2/amitools/migratebundleparameters.rb, line 149 def validate_params() raise MissingMandatory.new('--manifest') unless @manifest_name raise MissingMandatory.new('--cert') unless @user_cert_path raise MissingMandatory.new('--privatekey') unless @user_pk_path raise MissingMandatory.new('--bucket') unless @container raise MissingMandatory.new('--destination-bucket') unless @dest_container raise MissingMandatory.new('--access-key') unless @user raise MissingMandatory.new('--secret-key') unless @pass end