

def check_agent_router_scheduling_needed(self, context, agent, router):
    'Check if the router scheduling is needed.\n\n        :raises: RouterHostedByL3Agent if router is already assigned\n          to a different agent.\n        :returns: True if scheduling is needed, otherwise False\n        '
    router_id = router['id']
    agent_id = agent['id']
    query = context.session.query(RouterL3AgentBinding)
    bindings = query.filter_by(router_id=router_id).all()
    if (not bindings):
        return True
    for binding in bindings:
        if (binding.l3_agent_id == agent_id):
            return False
    if router.get('ha'):
        return True
    raise l3agentscheduler.RouterHostedByL3Agent(router_id=router_id, agent_id=bindings[0].l3_agent_id)

dataset/ETHPy150Open openstack/neutron/neutron/db/l3_agentschedulers_db.py L3AgentSchedulerDbMixin.check_agent_router_scheduling_needed/original