'Return l3 agent with the least number of routers.'

@classmethod
def get_l3_agent_with_min_routers(cls, context, agent_ids):

    with context.session.begin(subtransactions=True):
        query = context.session.query(agent_model.Agent, func.count(rb_model.RouterL3AgentBinding.router_id).label('count')).outerjoin(rb_model.RouterL3AgentBinding).group_by(agent_model.Agent.id, rb_model.RouterL3AgentBinding.l3_agent_id).order_by('count')
        res = query.filter(agent_model.Agent.id.in_(agent_ids)).first()
    agent_obj = cls._load_object(context, res[0])
    return agent_obj
