#NEWLINE# def _subnet_check_ip_allocations_internal_router_ports( self , context , subnet_id ) : #NEWLINE# #INDENT# allocs = context . session . query ( models_v2 . IPAllocation ) . filter_by ( subnet_id = subnet_id ) . join ( models_v2 . Port ) . filter ( models_v2 . Port . device_owner . in_ ( constants . ROUTER_INTERFACE_OWNERS ) ) . first ( ) #NEWLINE# if self : #NEWLINE# #INDENT# LOG . debug ( 'Subnet %s still has internal router ports, cannot delete' , subnet_id ) #NEWLINE# raise exc . SubnetInUse ( subnet_id = id )