#NEWLINE# def run( self , rollback_vars = None , **kwargs ) : #NEWLINE# #INDENT# LOG . debug ( 'restoring vms from snapshot' ) #NEWLINE# snapshot_from_namespace = kwargs . get ( self . namespace_variable ) #NEWLINE# compute = self . get_compute_resource ( ) #NEWLINE# position = self . cloud . position #NEWLINE# vm_id_targets = ( ( 'src_id' , 'dst_id' ) if ( position == 'src' ) else ( 'dst_id' , 'src_id' ) ) #NEWLINE# vms_succeeded = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if rollback_vars : #NEWLINE# #INDENT# vms = rollback_vars . get ( 'vms' , [ ] ) #NEWLINE# vms_succeeded = { pair_vms [ vm_id_targets [ 0 ] ] : pair_vms [ vm_id_targets [ 1 ] ] for pair_vms in vms } #NEWLINE# #UNINDENT# for vm in self . get_list_of_vms ( ) : #NEWLINE# #INDENT# if ( vm . id in vms_succeeded ) : #NEWLINE# #INDENT# LOG . debug ( 'Successfully copied instances' ) #NEWLINE# if ( position == 'src' ) : #NEWLINE# #INDENT# LOG . debug ( 'SRC ID %s' , vm . id ) #NEWLINE# LOG . debug ( 'DST ID %s' , vms_succeeded [ vm . id ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . debug ( 'SRC ID %s' , vms_succeeded [ vm . id ] ) #NEWLINE# LOG . debug ( 'DST ID %s' , vm . id ) #NEWLINE# #UNINDENT# continue #NEWLINE# #UNINDENT# if ( vm . id not in snapshot_from_namespace ) : #NEWLINE# #INDENT# if ( position == 'dst' ) : #NEWLINE# #INDENT# LOG . debug ( 'VM %s will be deleted on %s' , vm . id , position ) #NEWLINE# compute . delete_vm_by_id ( vm . id ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( vm . status != snapshot_from_namespace . get ( vm . id ) ) : #NEWLINE# #INDENT# LOG . debug ( 'Status of %s is changed from %s to %s on %s' , vm . id , vm . status , snapshot_from_namespace . get ( vm . id ) , position ) #NEWLINE# compute . change_status ( snapshot_from_namespace . get ( vm . id ) , instance_id = vm . id ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# }