#NEWLINE# def run( self , info = None , **kwargs ) : #NEWLINE# #INDENT# ( new_id , instance ) = info [ utils . INSTANCES_TYPE ] . items ( ) [ 0 ] #NEWLINE# old_id = instance [ 'old_id' ] #NEWLINE# dst_compute = self . dst_cloud . resources [ utils . COMPUTE_RESOURCE ] #NEWLINE# src_compute = self . src_cloud . resources [ utils . COMPUTE_RESOURCE ] #NEWLINE# dst_compute . change_status ( 'active' , instance_id = new_id ) #NEWLINE# dst_instance = dst_compute . get_instance ( new_id ) #NEWLINE# src_instance = src_compute . get_instance ( old_id ) #NEWLINE# if ( src_instance . status . lower ( ) not in [ 'active' , 'verify_resize' ] ) : #NEWLINE# #INDENT# LOG . debug ( "Skipping live migration of VM '%s', because it's inactive" , src_instance . name ) #NEWLINE# return #NEWLINE# #UNINDENT# src_host = instance_host ( src_instance ) #NEWLINE# dst_host = instance_host ( dst_instance ) #NEWLINE# src_runner = remote_runner . RemoteRunner ( src_host , CONF . src . ssh_user ) #NEWLINE# dst_runner = remote_runner . RemoteRunner ( dst_host , CONF . dst . ssh_user ) #NEWLINE# src_libvirt = libvirt . Libvirt ( src_runner ) #NEWLINE# dst_libvirt = libvirt . Libvirt ( dst_runner ) #NEWLINE# src_virsh_name = instance_libvirt_name ( src_instance ) #NEWLINE# dst_virsh_name = instance_libvirt_name ( dst_instance ) #NEWLINE# src_vm_xml = src_libvirt . get_xml ( src_virsh_name ) #NEWLINE# dst_vm_xml = dst_libvirt . get_xml ( dst_virsh_name ) #NEWLINE# src_vm_xml . disk_file = dst_vm_xml . disk_file #NEWLINE# src_vm_xml . serial_file = dst_vm_xml . serial_file #NEWLINE# src_vm_xml . console_file = dst_vm_xml . console_file #NEWLINE# src_vm_xml . interfaces = dst_vm_xml . interfaces #NEWLINE# dst_backing_file = dst_libvirt . get_backing_file ( new_id ) #NEWLINE# src_backing_file = src_libvirt . get_backing_file ( old_id ) #NEWLINE# migration_backing_file = os . path . join ( libvirt . nova_instances_path , '_base' , 'migration_disk_{}' . format ( old_id ) ) #NEWLINE# timeout = CONF . migrate . boot_timeout #NEWLINE# dst_compute . wait_for_status ( new_id , dst_compute . get_status , 'active' , timeout = timeout ) #NEWLINE# with files . RemoteTempFile ( src_runner , 'migrate-{}' . format ( old_id ) , src_vm_xml . dump ( ) ) as migration_file , files . RemoteSymlink ( src_runner , src_backing_file , migration_backing_file ) , files . RemoteSymlink ( dst_runner , dst_backing_file , migration_backing_file ) , ubuntu . StopNovaCompute ( dst_runner ) , libvirt . QemuBackingFileMover ( src_libvirt . runner , migration_backing_file , old_id ) : #NEWLINE# #INDENT# destroyer = libvirt . DestNovaInstanceDestroyer ( dst_libvirt , dst_compute , dst_virsh_name , dst_instance . id ) #NEWLINE# try : #NEWLINE# #INDENT# destroyer . do ( ) #NEWLINE# src_libvirt . live_migrate ( src_virsh_name , dst_host , migration_file . filename ) #NEWLINE# #UNINDENT# except remote_runner . RemoteExecutionError : #NEWLINE# #INDENT# destroyer . undo ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# dst_libvirt . move_backing_file ( dst_backing_file , new_id )