Class: CopyMsWindowsAmi::TargetVolumeCreatedState
- Inherits:
-
CopyMsWindowsAmiState
- Object
- ScriptExecutionState
- CopyMsWindowsAmiState
- CopyMsWindowsAmi::TargetVolumeCreatedState
- Defined in:
- lib/scripts/ec2/copy_mswindows_ami.rb
Overview
Snapshot Operation done. Now this snapshot must be registered as AMI Steps:
- launch same AMI as the one we want to copy and stop it (after it has boot up): use helper_ami_id
- detach the volume of this instance and attach the new volume
- start the instance to see if everything is good, then stop it
- create an AMI from this instance
Instance Attribute Summary
Attributes inherited from ScriptExecutionState
Instance Method Summary collapse
Methods inherited from CopyMsWindowsAmiState
load_state, #local_region, #remote_region
Methods inherited from ScriptExecutionState
#done?, #end_state, #failed?, #get_superclass_name, #initialize, #register_state_change_listener, #start_state_machine, #to_s
Methods included from StateTransitionHelper
#attach_volume, #connect, #copy_distribution, #create_fs, #create_image_from_instance, #create_labeled_fs, #create_security_group_with_rules, #create_snapshot, #create_volume, #create_volume_from_snapshot, #delete_security_group, #delete_snapshot, #delete_volume, #describe_instance, #detach_volume, #determine_file, #disable_ssh_tty, #disconnect, #ec2_handler, #ec2_handler=, #enable_ssh_tty, #get_aws_kernel_image_aki, #get_aws_region_from_endpoint, #get_partition_count, #get_partition_fs_type, #get_partition_fs_type_and_label, #get_partition_label, #get_partition_table, #get_root_device_name, #get_root_partition_fs_type, #get_root_partition_fs_type_and_label, #get_root_partition_label, #get_root_volume_id, #launch_instance, #local_decompress_and_dump_file_to_device, #local_dump_and_compress_device_to_file, #local_dump_device_to_file, #local_dump_file_to_device, #mount_fs, #mount_fs_old, #register_snapshot, #remote_copy, #remote_copy_old, #remote_handler, #remote_handler=, #retrieve_instances, #retrieve_security_groups, #set_partition_table, #shut_down_instance, #snapshot_accessible, #start_instance, #stop_instance, #unmount_fs, #upload_file, #zip_volume
Methods included from VCloudTransitionHelper
Constructor Details
This class inherits a constructor from ScriptExecutionState
Instance Method Details
#enter ⇒ Object
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/scripts/ec2/copy_mswindows_ami.rb', line 496 def enter() ("Launching Helper AMI '#{@context[:helper_ami_id]}' for attaching migrated volume...") remote_region() #XXX: launch instance in the right AZ result = launch_instance(@context[:helper_ami_id], @context[:target_key_name], @context[:target_security_group], nil, nil, @context[:target_availability_zone]) @context[:helper_instance_id] = result.first @context[:helper_dns_name] = result[1] @context[:helper_availability_zone] = result[2] @context[:helper_root_device_name] = result[6] ("Creating NEW AMI using instance #{@context[:helper_instance_id]}...") #XXX: # - wait for it to be running, and then stop it # - wait for it to be stopped, and then start it with the new volume stop_instance(@context[:helper_instance_id]) root_volume_id = get_root_volume_id(@context[:helper_instance_id]) detach_volume(root_volume_id, @context[:helper_instance_id]) attach_volume(@context[:target_volume_id], @context[:helper_instance_id], @context[:helper_root_device_name], Ec2Script::CS_AWS_TIMEOUT) start_instance(@context[:helper_instance_id]) #XXX: return running instance for now @context[:result][:instance_id] = result.first #XXX: stop this instance stop_instance(@context[:helper_instance_id]) #XXX: register as AMI new_ami_id = create_image_from_instance(@context[:helper_instance_id], @context[:name], @context[:description]) ("New AMI created with ID: #{new_ami_id}") @context[:result][:image_id] = new_ami_id AmiRegisteredState.new(@context) end |