#NEWLINE# def deallocate_for_instance( self , context , **kwargs ) : #NEWLINE# #INDENT# 'Handles deallocating various network resources for an instance.\n\n        rpc.called by network_api\n        kwargs can contain fixed_ips to circumvent another db lookup\n        ' #NEWLINE# instance_id = kwargs . pop ( 'instance_id' ) #NEWLINE# try : #NEWLINE# #INDENT# fixed_ips = ( kwargs . get ( 'fixed_ips' ) or self . db . fixed_ip_get_by_instance ( context , instance_id ) ) #NEWLINE# #UNINDENT# except exception . FixedIpNotFoundForInstance : #NEWLINE# #INDENT# fixed_ips = [ ] #NEWLINE# #UNINDENT# LOG . debug ( _ ( 'network deallocation for instance |%s|' ) , instance_id , context = context ) #NEWLINE# for fixed_ip in fixed_ips : #NEWLINE# #INDENT# self . deallocate_fixed_ip ( context , fixed_ip [ 'address' ] , ** kwargs ) #NEWLINE# #UNINDENT# self . db . virtual_interface_delete_by_instance ( context , instance_id )