class MigrateManifestParameters

Constants

DIRECTORY_DESCRIPTION
EC2_CERT_PATH_DESCRIPTION
KERNEL_DESCRIPTION
MANIFEST_DESCRIPTION
NO_MAPPING_DESCRIPTION
PASS_DESCRIPTION
RAMDISK_DESCRIPTION
REGION_DESCRIPTION
USER_DESCRIPTION

Attributes

ec2_cert_path[RW]
kernel_id[RW]
manifest_path[RW]
pass[RW]
ramdisk_id[RW]
region[RW]
use_mapping[RW]
user[RW]
user_cert_path[RW]
user_pk_path[RW]

Public Instance Methods

mandatory_params() click to toggle source
# File lib/ec2/amitools/migratemanifestparameters.rb, line 45
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 PATH', String, MANIFEST_DESCRIPTION) do |manifest|
    assert_file_exists(manifest, '--manifest')
    @manifest_path = manifest
  end
end
optional_params() click to toggle source
# File lib/ec2/amitools/migratemanifestparameters.rb, line 64
def optional_params()
  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
  
  on('--ec2cert PATH', String, *EC2_CERT_PATH_DESCRIPTION) do |path|
    assert_file_exists(path, '--ec2cert')
    @ec2_cert_path = path
  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/migratemanifestparameters.rb, line 111
def set_defaults()
  @ec2_cert_path ||= case
    when (@region=="us-gov-west-1") then Bundling::EC2_X509_GOV_CERT
    when (@region=="cn-north-1") then Bundling::EC2_X509_CN_NORTH_1_CERT
    else Bundling::EC2_X509_CERT
  end
end
validate_params() click to toggle source
# File lib/ec2/amitools/migratemanifestparameters.rb, line 97
def validate_params()
  raise MissingMandatory.new('--manifest') unless @manifest_path
  raise MissingMandatory.new('--cert') unless @user_cert_path
  raise MissingMandatory.new('--privatekey') unless @user_pk_path
  @use_mapping = true if @use_mapping.nil? # False is different.
  if @use_mapping
    raise ParameterExceptions::Error.new('If using automatic mapping, --region must be provided.') unless @region
    raise ParameterExceptions::Error.new('If using automatic mapping, --access-key must be provided.') unless @user
    raise ParameterExceptions::Error.new('If using automatic mapping, --secret-key must be provided.') unless @pass
  end
end