Class: Ami2EbsConversion
- Defined in:
- lib/scripts/ec2/ami2_ebs_conversion.rb
Overview
Creates a bootable EBS storage from an existing AMI.
Defined Under Namespace
Classes: Ami2EbsConversionState, AmiStarted, CopyDone, Done, FileSystemCreated, FileSystemMounted, InitialState, SnapshotCreated, SnapshotRegistered, StorageAttached, StorageCreated, VolumeDeleted, VolumeDetached, VolumeUnmounted
Instance Method Summary collapse
- #check_input_parameters ⇒ Object
-
#initialize(input_params) ⇒ Ami2EbsConversion
constructor
Input parameters * aws_access_key => the Amazon AWS Access Key (see Your Account -> Security Credentials) * aws_secret_key => the Amazon AWS Secret Key * ami_id => the ID of the AMI to be converted * security_group_name => name of the security group to start * ssh_username => name of the ssh-user (default = root) * ssh_key_data => Key information for the security group that starts the AMI [if not set, use ssh_key_files] * ssh_key_files => Key information for the security group that starts the AMI * remote_command_handler => object that allows to connect via ssh and execute commands (optional) * ec2_api_handler => object that allows to access the EC2 API (optional) * ec2_api_server => server to connect to (option, default is us-east-1.ec2.amazonaws.com) * name => the name of the AMI to be created * description => description on AMI to be created (optional) * temp_device_name => [default /dev/sdj] device name used to attach the temporary storage; change this only if there’s already a volume attacged as /dev/sdj (optional, default is /dev/sdj) * root_device_name“=> [default /dev/sda1] device name used for the root device (optional) * connect_trials => number of trials during ssh connect to machine * connect_interval => seconds between two ssh connect trials.
- #load_initial_state ⇒ Object
Methods inherited from Ec2Script
#get_execution_result, #post_message, #register_progress_message_listener, #register_state_change_listener, #start_script
Constructor Details
#initialize(input_params) ⇒ Ami2EbsConversion
Input parameters
-
aws_access_key => the Amazon AWS Access Key (see Your Account -> Security Credentials)
-
aws_secret_key => the Amazon AWS Secret Key
-
ami_id => the ID of the AMI to be converted
-
security_group_name => name of the security group to start
-
ssh_username => name of the ssh-user (default = root)
-
ssh_key_data => Key information for the security group that starts the AMI [if not set, use ssh_key_files]
-
ssh_key_files => Key information for the security group that starts the AMI
-
remote_command_handler => object that allows to connect via ssh and execute commands (optional)
-
ec2_api_handler => object that allows to access the EC2 API (optional)
-
ec2_api_server => server to connect to (option, default is us-east-1.ec2.amazonaws.com)
-
name => the name of the AMI to be created
-
description => description on AMI to be created (optional)
-
temp_device_name => [default /dev/sdj] device name used to attach the temporary storage; change this only if there’s already a volume attacged as /dev/sdj (optional, default is /dev/sdj)
-
root_device_name“=> [default /dev/sda1] device name used for the root device (optional)
-
connect_trials => number of trials during ssh connect to machine
-
connect_interval => seconds between two ssh connect trials
29 30 31 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 29 def initialize(input_params) super(input_params) end |
Instance Method Details
#check_input_parameters ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 33 def check_input_parameters() if @input_params[:security_group_name] == nil @input_params[:security_group_name] = "default" end if @input_params[:ami_id] == nil && !(@input_params[:ami_id] =~ /^ami-.*$/) raise Exception.new("Invalid AMI ID specified: #{@input_params[:ami_id]}") end ec2_helper = Ec2Helper.new(@input_params[:ec2_api_handler]) if !ec2_helper.check_open_port(@input_params[:security_group_name], 22) raise Exception.new("Port 22 must be opened for security group #{@input_params[:security_group_name]} to connect via SSH") end if @input_params[:name] == nil @input_params[:name] = "Boot EBS (for AMI #{@input_params[:ami_id]}) at #{Time.now.strftime('%d/%m/%Y %H.%M.%S')}" else end if @input_params[:description] == nil @input_params[:description] = @input_params[:name] end if @input_params[:temp_device_name] == nil @input_params[:temp_device_name] = "/dev/sdj" end if @input_params[:root_device_name] == nil @input_params[:root_device_name] = "/dev/sda1" end if @input_params[:ssh_username] == nil @input_params[:ssh_username] = "root" end if @input_params[:connect_trials] == nil @input_params[:connect_trials] = 6 end if @input_params[:connect_interval] == nil @input_params[:connect_interval] = 20 end end |
#load_initial_state ⇒ Object
68 69 70 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 68 def load_initial_state() Ami2EbsConversionState.load_state(@input_params) end |