'Checks whether router\'s l3 agent can handle the given network
When external_network_bridge is set, each L3 agent can be associated
with at most one external network. If router\'s new external gateway
is on other network then the router needs to be rescheduled to the
proper l3 agent.
If external_network_bridge is not set then the agent
can support multiple external networks and rescheduling is not needed
:return: list of candidate agents if rescheduling needed,
None otherwise; raises exception if there is no eligible l3 agent
associated with target external network'

def _check_router_needs_rescheduling(self, context, router_id, gw_info):

    network_id = (gw_info.get('network_id') if gw_info else None)
    if (not network_id):
        return
    nets = self._core_plugin.get_networks(context, {external_net.EXTERNAL: [True]})
    if (len(nets) <= 1):
        return
    l3_plugin = directory.get_plugin(plugin_constants.L3)
    if ((not utils.is_extension_supported(l3_plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS)) or (l3_plugin.router_scheduler is None)):
        return
    if (not l3_plugin.router_supports_scheduling(context, router_id)):
        return
    cur_agents = l3_plugin.list_l3_agents_hosting_router(context, router_id)['agents']
    for agent in cur_agents:
        ext_net_id = agent['configurations'].get('gateway_external_network_id')
        ext_bridge = agent['configurations'].get('external_network_bridge', '')
        if ((ext_net_id == network_id) or ((not ext_net_id) and (not ext_bridge))):
            return
    active_agents = l3_plugin.get_l3_agents(context, active=True)
    router = {'id': router_id, 'external_gateway_info': {'network_id': network_id}}
    candidates = l3_plugin.get_l3_agent_candidates(context, router, active_agents)
    if (not candidates):
        msg = (_('No    eligible    l3    agent    associated    with    external    network    %s    found') % network_id)
        raise n_exc.BadRequest(resource='router', msg=msg)
    return candidates
