Class: DownloadSnapshot
- Defined in:
- lib/scripts/ec2/download_snapshot.rb
Overview
Script to download a specific snapshot as ZIP
-
create a specific instance (with Apache Server),
-
create a volume based on the snapshot
-
attach the volume
-
create a XSF-file-system
-
freeze the file-system
-
zip the file-system and copy it to the apache folder
-
wait 5 minutes (now the zip-file can be downloaded)
-
alternatively: copy it to S3 and make it downloadable
-
alternatively: copy it to an FTP server
-
Defined Under Namespace
Classes: DownloadSnapshotState, DownloadStoppedState, FileSystemsReady, InitialState, InstanceLaunchedState, VolumeZippedAndDownloadableState, VolumesAttached, VolumesCreated
Constant Summary
Constants inherited from Ec2Script
Ec2Script::CS_AWS_TIMEOUT, Ec2Script::CS_SEC_GRP_DESC, Ec2Script::CS_SEC_GRP_NAME
Instance Method Summary collapse
- #check_input_parameters ⇒ Object
-
#initialize(input_params) ⇒ DownloadSnapshot
constructor
context information needed * the EC2 credentials (see #Ec2Script) * ami_id: the ID of the AMI to be started to perform the operations and to run the web-server for download * security_group_name => name of the security group used to start the AMI (should open ports for SSH and HTTP) * key_name => Name of the key to be used to access the instance providing the download * 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 * snapshot_id => The ID of the snapshot to be downloaded * wait_time (optional, default = 300) => time in sec during which the zipped snapshot is downloadable * zip_file_dest (optional, default = ‘/var/www/html’) => path of directory where the zipped volume is copied to * zip_file_name (option, default = ‘download’) => name of the zip-file to download.
-
#load_initial_state ⇒ Object
Load the initial state for the script.
Methods inherited from Ec2Script
#get_execution_result, #post_message, #register_progress_message_listener, #register_state_change_listener, #start_script
Constructor Details
#initialize(input_params) ⇒ DownloadSnapshot
context information needed
-
the EC2 credentials (see #Ec2Script)
-
ami_id: the ID of the AMI to be started to perform the operations and to run the web-server for download
-
security_group_name => name of the security group used to start the AMI (should open ports for SSH and HTTP)
-
key_name => Name of the key to be used to access the instance providing the download
-
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
-
snapshot_id => The ID of the snapshot to be downloaded
-
wait_time (optional, default = 300) => time in sec during which the zipped snapshot is downloadable
-
zip_file_dest (optional, default = ‘/var/www/html’) => path of directory where the zipped volume is copied to
-
zip_file_name (option, default = ‘download’) => name of the zip-file to download
33 34 35 |
# File 'lib/scripts/ec2/download_snapshot.rb', line 33 def initialize(input_params) super(input_params) end |
Instance Method Details
#check_input_parameters ⇒ Object
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/scripts/ec2/download_snapshot.rb', line 37 def check_input_parameters() ("Checking 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 @input_params[:security_group_name] == nil @input_params[:security_group_name] = "default" end # AWS Security Group if !ec2_helper.check_open_port(@input_params[:security_group_name], 22) ("'#{@input_params[:security_group_name]}' Security Group not opened port 22 for connect via SSH") @input_params[:security_group_name] = nil end if @input_params[:security_group_name] != nil && !ec2_helper.check_open_port(@input_params[:security_group_name], 80) ("'#{@input_params[:security_group_name]}' Security Group not opened port 80 for download via HTTP") @input_params[:security_group_name] = nil end # AWS KeyPair if @input_params[:key_name] == nil || @input_params[:key_name].empty?() raise Exception.new("No KeyPair name specified") else begin ec2_helper.check_keypair(@input_params[:key_name]) rescue Exception => e ("'#{@input_params[:key_name]}' Key pair not found") raise Exception.new("#{e.to_s}") end end # Device, Directory and file name if @input_params[:source_device] == nil @input_params[:source_device] = "/dev/sdj" end if @input_params[:dest_device] == nil @input_params[:dest_device] = "/dev/sdk" end if @input_params[:zip_file_dest] == nil @input_params[:zip_file_dest] = "/var/www/html" end if @input_params[:zip_file_name] == nil @input_params[:zip_file_name] = "download" end if @input_params[:wait_time] == nil @input_params[:wait_time] = 300 end # SSH Parameters if @input_params[:ssh_username] == nil @input_params[:ssh_username] = "root" end if @input_params[:ssh_keydata] == nil raise Exception.new("No Private Key for source region") else ("Checking SSH key for source region...") check_ssh_key(@input_params[:ssh_keydata]) end end |
#load_initial_state ⇒ Object
Load the initial state for the script. Abstract method to be implemented by extending classes.
96 97 98 |
# File 'lib/scripts/ec2/download_snapshot.rb', line 96 def load_initial_state() DownloadSnapshotState.load_state(@input_params) end |