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).
- #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)
27 28 29 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 27 def initialize(input_params) super(input_params) end |
Instance Method Details
#check_input_parameters ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 31 def check_input_parameters() if @input_params[:security_group_name] == nil @input_params[:security_group_name] = "default" 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 end |
#load_initial_state ⇒ Object
57 58 59 |
# File 'lib/scripts/ec2/ami2_ebs_conversion.rb', line 57 def load_initial_state() Ami2EbsConversionState.load_state(@input_params) end |