#NEWLINE# def network_delete_event( self , network_info ) : #NEWLINE# #INDENT# 'Process network delete event.' #NEWLINE# net_id = network_info [ 'network_id' ] #NEWLINE# if ( net_id not in self . network ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'network_delete_event: net_id %s does not exist.' ) , net_id ) #NEWLINE# return #NEWLINE# #UNINDENT# segid = self . network [ net_id ] . get ( 'segmentation_id' ) #NEWLINE# tenant_id = self . network [ net_id ] . get ( 'tenant_id' ) #NEWLINE# tenant_name = self . get_project_name ( tenant_id ) #NEWLINE# net = utils . Dict2Obj ( self . network [ net_id ] ) #NEWLINE# if ( not tenant_name ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Project %(tenant_id)s does not exist.' ) , { #NEWLINE# #INDENT# 'tenant_id' : tenant_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . update_network_db ( net . id , constants . DELETE_FAIL ) #NEWLINE# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . dcnm_client . delete_network ( tenant_name , net ) #NEWLINE# self . segmentation_pool . add ( segid ) #NEWLINE# self . delete_network_db ( net_id ) #NEWLINE# del self . network [ net_id ] #NEWLINE# snets = [ k for k in self . subnet if ( self . subnet [ k ] . get ( 'network_id' ) == net_id ) ] #NEWLINE# [ self . subnet . pop ( s ) for s in snets ] #NEWLINE# #UNINDENT# except dexc . DfaClientRequestFailed : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Failed to create network %(net)s.' ) , { #NEWLINE# #INDENT# 'net' : net . name , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . update_network_db ( net_id , constants . DELETE_FAIL ) #NEWLINE# #UNINDENT# instances = self . get_vms ( ) #NEWLINE# instances_related = [ vm for k in instances if ( k . network_id == net_id ) ] #NEWLINE# for vm in instances_related : #NEWLINE# #INDENT# LOG . debug ( 'deleting vm %s because network is deleted' , vm . name ) #NEWLINE# self . delete_vm_function ( vm . port_id , vm )