Class: BundleParameters
- Inherits:
-
ParametersBase
- Object
- OptionParser
- ParametersBase
- BundleParameters
- Defined in:
- lib/ec2/amitools/bundleparameters.rb
Overview
The Bundle command line parameters.
Direct Known Subclasses
Constant Summary collapse
- SUPPORTED_ARCHITECTURES =
['i386', 'x86_64']
- USER_DESCRIPTION =
"The user's EC2 user ID (Note: AWS account number, NOT Access Key ID)."
- HELP_DESCRIPTION =
"Display this help message and exit."
- MANUAL_DESCRIPTION =
"Display the user manual and exit."
- DESTINATION_DESCRIPTION =
"The directory to create the bundle in. Defaults to '#{Bundling::DESTINATION}'."
- DEBUG_DESCRIPTION =
"Display debug messages."
- EC2_CERT_PATH_DESCRIPTION =
['The path to the EC2 X509 public key certificate bundled into the AMI.', "Defaults to '#{Bundling::EC2_X509_CERT}'."]
- ARCHITECTURE_DESCRIPTION =
"Specify target architecture. One of #{SUPPORTED_ARCHITECTURES.inspect}"
- BATCH_DESCRIPTION =
"Run in batch mode. No interactive prompts."
- PRODUCT_CODES_DESCRIPTION =
['Default product codes attached to the image at registration time.', 'Comma separated list of product codes.']
- SIZE_CHECKS_DESCRIPTION =
'If set, disables size checks on bundled artifacts.'
- VERSION_DESCRIPTION =
"Display the version and copyright notice and then exit."
- PROMPT_TIMEOUT =
30
Constants inherited from ParametersBase
ParametersBase::PASS_DESCRIPTION, ParametersBase::USER_ACCOUNT_DESCRIPTION, ParametersBase::USER_CERT_PATH_DESCRIPTION, ParametersBase::USER_PK_PATH_DESCRIPTION
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#batch_mode ⇒ Object
Returns the value of attribute batch_mode.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#ec2_cert_path ⇒ Object
Returns the value of attribute ec2_cert_path.
-
#manual ⇒ Object
Returns the value of attribute manual.
-
#product_codes ⇒ Object
Returns the value of attribute product_codes.
-
#show_help ⇒ Object
Returns the value of attribute show_help.
-
#size_checks ⇒ Object
Returns the value of attribute size_checks.
-
#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
Instance Method Summary collapse
-
#mandatory_params ⇒ Object
—————————————————————————-#.
-
#optional_params ⇒ Object
—————————————————————————-#.
-
#set_defaults ⇒ 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
#arch ⇒ Object
Returns the value of attribute arch.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def arch @arch end |
#batch_mode ⇒ Object
Returns the value of attribute batch_mode.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def batch_mode @batch_mode end |
#debug ⇒ Object
Returns the value of attribute debug.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def debug @debug end |
#destination ⇒ Object
Returns the value of attribute destination.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def destination @destination end |
#ec2_cert_path ⇒ Object
Returns the value of attribute ec2_cert_path.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def ec2_cert_path @ec2_cert_path end |
#manual ⇒ Object
Returns the value of attribute manual.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def manual @manual end |
#product_codes ⇒ Object
Returns the value of attribute product_codes.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def product_codes @product_codes end |
#show_help ⇒ Object
Returns the value of attribute show_help.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def show_help @show_help end |
#size_checks ⇒ Object
Returns the value of attribute size_checks.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def size_checks @size_checks end |
#user ⇒ Object
Returns the value of attribute user.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def user @user end |
#user_cert_path ⇒ Object
Returns the value of attribute user_cert_path.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def user_cert_path @user_cert_path end |
#user_pk_path ⇒ Object
Returns the value of attribute user_pk_path.
36 37 38 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 36 def user_pk_path @user_pk_path end |
Instance Method Details
#mandatory_params ⇒ Object
—————————————————————————-#
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 53 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('-u', '--user USER', String, USER_ACCOUNT_DESCRIPTION) do |user| # Remove hyphens from the Account ID as presented in AWS portal. @user = user.gsub("-", "") # Validate the account ID looks correct (users often provide us with their akid or secret key) unless (@user =~ /\d{12}/) raise InvalidValue.new('--user', @user, "the user ID should consist of 12 digits (optionally hyphenated); this should not be your Access Key ID") end end end |
#optional_params ⇒ Object
—————————————————————————-#
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 77 def optional_params() on('-d', '--destination PATH', String, DESTINATION_DESCRIPTION) do |path| assert_directory_exists(path, '--destination') @destination = path end on('--ec2cert PATH', String, *BundleParameters::EC2_CERT_PATH_DESCRIPTION) do |path| assert_file_exists(path, '--ec2cert') @ec2_cert_path = path end on('-r', '--arch ARCHITECTURE', String, ARCHITECTURE_DESCRIPTION) do |arch| @arch = arch end on('--productcodes PRODUCT_CODES', String, *PRODUCT_CODES_DESCRIPTION) do |pc| @product_codes = pc end on('--no-size-checks', SIZE_CHECKS_DESCRIPTION ) do |o| @size_checks = o end end |
#set_defaults ⇒ Object
—————————————————————————-#
113 114 115 116 117 118 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 113 def set_defaults() @destination ||= Bundling::DESTINATION @ec2_cert_path ||= Bundling::EC2_X509_CERT @exclude ||= [] @size_checks = true end |
#validate_params ⇒ Object
—————————————————————————-#
103 104 105 106 107 108 109 |
# File 'lib/ec2/amitools/bundleparameters.rb', line 103 def validate_params() unless @clone_only raise MissingMandatory.new('--cert') unless @user_cert_path raise MissingMandatory.new('--privatekey') unless @user_pk_path raise MissingMandatory.new('--user') unless @user end end |