Class: MigrateBundleParameters
- Inherits:
-
ParametersBase
- Object
- OptionParser
- ParametersBase
- MigrateBundleParameters
- Defined in:
- lib/ec2/amitools/migratebundleparameters.rb
Overview
——————————————————————————#
Constant Summary collapse
- MANIFEST_DESCRIPTION =
"The name the manifest file."
- DIRECTORY_DESCRIPTION =
["The directory containing the bundled AMI parts to upload.", "Defaults to the directory containing the manifest."]
- USER_CERT_PATH_DESCRIPTION =
"The path to the user's PEM encoded RSA public key certificate file."
- USER_PK_PATH_DESCRIPTION =
"The path to the user's PEM encoded RSA private key file."
- EC2_CERT_PATH_DESCRIPTION =
['The path to the EC2 X509 public key certificate bundled into the AMI.', "Defaults to '#{Bundling::EC2_X509_CERT}'."]
- KERNEL_DESCRIPTION =
"Kernel id to bundle into the AMI."
- RAMDISK_DESCRIPTION =
"Ramdisk id to bundle into the AMI."
- DEST_BUCKET_DESCRIPTION =
"The bucket to copy bundle to. Created if nonexistent."
- BUCKET_DESCRIPTION =
"The bucket containing the AMI to be migrated."
- USER_DESCRIPTION =
"The user's AWS access key ID."
- PASS_DESCRIPTION =
"The user's AWS secret access key."
- ACL_DESCRIPTION =
["The access control list policy [\"public-read\" | \"aws-exec-read\"].", "Defaults to \"aws-exec-read\"."]
- URL_DESCRIPTION =
"The S3 service URL. Defaults to https://s3.amazonaws.com."
- RETRY_DESCRIPTION =
"Automatically retry failed uploads. Use with caution."
- LOCATION_DESCRIPTION =
"The location of the bucket to upload to [#{AwsRegion.regions.join(',')}]."
- NO_MAPPING_DESCRIPTION =
"Do not perform automatic mappings."
- REGION_DESCRIPTION =
"Region to look up in the mapping file."
Constants inherited from ParametersBase
ParametersBase::BATCH_DESCRIPTION, ParametersBase::DEBUG_DESCRIPTION, ParametersBase::HELP_DESCRIPTION, ParametersBase::MANUAL_DESCRIPTION, ParametersBase::USER_ACCOUNT_DESCRIPTION, ParametersBase::VERSION_DESCRIPTION
Instance Attribute Summary collapse
-
#acl ⇒ Object
Returns the value of attribute acl.
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#dest_bucket ⇒ Object
Returns the value of attribute dest_bucket.
-
#dest_keyprefix ⇒ Object
Returns the value of attribute dest_keyprefix.
-
#ec2_cert_path ⇒ Object
Returns the value of attribute ec2_cert_path.
-
#kernel_id ⇒ Object
Returns the value of attribute kernel_id.
-
#keyprefix ⇒ Object
Returns the value of attribute keyprefix.
-
#location ⇒ Object
Returns the value of attribute location.
-
#manifest_name ⇒ Object
Returns the value of attribute manifest_name.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#ramdisk_id ⇒ Object
Returns the value of attribute ramdisk_id.
-
#region ⇒ Object
Returns the value of attribute region.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#s3_url ⇒ Object
Returns the value of attribute s3_url.
-
#use_mapping ⇒ Object
Returns the value of attribute use_mapping.
-
#user ⇒ Object
Returns the value of attribute user.
-
#user_cert_path ⇒ Object
Returns the value of attribute user_cert_path.
-
#user_pk_path ⇒ Object
Returns the value of attribute user_pk_path.
Attributes inherited from ParametersBase
#batch_mode, #debug, #manual, #show_help, #version
Instance Method Summary collapse
- #help ⇒ Object
- #mandatory_params ⇒ Object
- #optional_params ⇒ Object
- #set_defaults ⇒ Object
- #split_container(container) ⇒ Object
- #validate_params ⇒ Object
Methods inherited from ParametersBase
#assert_directory_exists, #assert_exists, #assert_file_executable, #assert_file_exists, #assert_glob_expands, #assert_good_key, #assert_option_in, #common_params, #early_exit?, #initialize, #interactive?, #version_copyright_string
Constructor Details
This class inherits a constructor from ParametersBase
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def acl @acl end |
#bucket ⇒ Object
Returns the value of attribute bucket.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def bucket @bucket end |
#dest_bucket ⇒ Object
Returns the value of attribute dest_bucket.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def dest_bucket @dest_bucket end |
#dest_keyprefix ⇒ Object
Returns the value of attribute dest_keyprefix.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def dest_keyprefix @dest_keyprefix end |
#ec2_cert_path ⇒ Object
Returns the value of attribute ec2_cert_path.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def ec2_cert_path @ec2_cert_path end |
#kernel_id ⇒ Object
Returns the value of attribute kernel_id.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def kernel_id @kernel_id end |
#keyprefix ⇒ Object
Returns the value of attribute keyprefix.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def keyprefix @keyprefix end |
#location ⇒ Object
Returns the value of attribute location.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def location @location end |
#manifest_name ⇒ Object
Returns the value of attribute manifest_name.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def manifest_name @manifest_name end |
#pass ⇒ Object
Returns the value of attribute pass.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def pass @pass end |
#ramdisk_id ⇒ Object
Returns the value of attribute ramdisk_id.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def ramdisk_id @ramdisk_id end |
#region ⇒ Object
Returns the value of attribute region.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def region @region end |
#retry ⇒ Object
Returns the value of attribute retry.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def retry @retry end |
#s3_url ⇒ Object
Returns the value of attribute s3_url.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def s3_url @s3_url end |
#use_mapping ⇒ Object
Returns the value of attribute use_mapping.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def use_mapping @use_mapping end |
#user ⇒ Object
Returns the value of attribute user.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def user @user end |
#user_cert_path ⇒ Object
Returns the value of attribute user_cert_path.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def user_cert_path @user_cert_path end |
#user_pk_path ⇒ Object
Returns the value of attribute user_pk_path.
41 42 43 |
# File 'lib/ec2/amitools/migratebundleparameters.rb', line 41 def user_pk_path @user_pk_path end |
Instance Method Details
#help ⇒ Object
166 167 168 169 170 171 172 |
# 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 ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# 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 ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# 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 ⇒ Object
159 160 161 162 163 164 |
# 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) ⇒ Object
60 61 62 63 64 65 66 |
# 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 ⇒ Object
149 150 151 152 153 154 155 156 157 |
# 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 |