#NEWLINE# def _enforce_device_owner_not_router_intf_or_device_id( self , context , device_owner , device_id , tenant_id ) : #NEWLINE# #INDENT# 'Prevent tenants from replacing the device id of router ports with\n        a router uuid belonging to another tenant.\n        ' #NEWLINE# if ( device_owner not in constants . ROUTER_INTERFACE_OWNERS ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not context . is_admin ) : #NEWLINE# #INDENT# if device_id : #NEWLINE# #INDENT# if hasattr ( self , 'get_router' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ctx_admin = context . elevated ( ) #NEWLINE# router = self . get_router ( ctx_admin , tenant_id ) #NEWLINE# #UNINDENT# except l3 . RouterNotFound : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# l3plugin = manager . NeutronManager . get_service_plugins ( ) . get ( service_constants . L3_ROUTER_NAT ) #NEWLINE# if l3plugin : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ctx_admin = context . elevated ( ) #NEWLINE# router = l3plugin . get_router ( ctx_admin , device_id ) #NEWLINE# #UNINDENT# except l3 . RouterNotFound : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise n_exc . DeviceIDNotOwnedByTenant ( device_id = device_id ) #NEWLINE# #UNINDENT# #UNINDENT# if ( tenant_id != router [ 'tenant_id' ] ) : #NEWLINE# #INDENT# raise n_exc . DeviceIDNotOwnedByTenant ( device_id = device_id )