#NEWLINE# def undo( self , workflow_dict ) : #NEWLINE# #INDENT# LOG . info ( 'Running undo...' ) #NEWLINE# try : #NEWLINE# #INDENT# cs_credentials = get_credentials_for ( environment = workflow_dict [ 'target_environment' ] , credential_type = CredentialType . CLOUDSTACK ) #NEWLINE# cs_provider = CloudStackProvider ( credentials = cs_credentials ) #NEWLINE# for source_instance in workflow_dict [ 'source_instances' ] : #NEWLINE# #INDENT# source_instance . future_instance = None #NEWLINE# source_instance . save ( ) #NEWLINE# LOG . info ( 'Source instance updated' ) #NEWLINE# #UNINDENT# for target_instance in workflow_dict [ 'target_instances' ] : #NEWLINE# #INDENT# target_instance . delete ( ) #NEWLINE# LOG . info ( 'Target instance deleted' ) #NEWLINE# #UNINDENT# for source_host in workflow_dict [ 'source_hosts' ] : #NEWLINE# #INDENT# source_host . future_host = None #NEWLINE# source_host . save ( ) #NEWLINE# LOG . info ( 'Source host updated' ) #NEWLINE# #UNINDENT# for target_host in workflow_dict [ 'target_hosts' ] : #NEWLINE# #INDENT# host_attr = HostAttr . objects . get ( host = target_host ) #NEWLINE# LOG . info ( ( 'Destroying virtualmachine %s' % host_attr . vm_id ) ) #NEWLINE# cs_provider . destroy_virtual_machine ( project_id = cs_credentials . project , environment = workflow_dict [ 'target_environment' ] , vm_id = target_host . vm_id ) #NEWLINE# host_attr . delete ( ) #NEWLINE# LOG . info ( 'HostAttr deleted!' ) #NEWLINE# target_host . delete ( ) #NEWLINE# LOG . info ( 'Target host deleted' ) #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# traceback = full_stack ( ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'error_codes' ] . append ( DBAAS_0020 ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'traceback' ] . append ( traceback ) #NEWLINE# return False