class BundleParameters

The Bundle command line parameters.

The Bundle command line parameters.

Constants

ARCHITECTURE_DESCRIPTION
BATCH_DESCRIPTION
DEBUG_DESCRIPTION
DESTINATION_DESCRIPTION
EC2_CERT_PATH_DESCRIPTION
HELP_DESCRIPTION
MANUAL_DESCRIPTION
PRODUCT_CODES_DESCRIPTION
PROMPT_TIMEOUT
SIZE_CHECKS_DESCRIPTION
SUPPORTED_ARCHITECTURES
USER_DESCRIPTION
VERSION_DESCRIPTION

Attributes

arch[RW]
batch_mode[RW]
debug[RW]
destination[RW]
ec2_cert_path[RW]
manual[RW]
product_codes[RW]
show_help[RW]
size_checks[RW]
user[RW]
user_cert_path[RW]
user_pk_path[RW]

Public Instance Methods

mandatory_params() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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