

def validate_agent_router_combination(self, context, agent, router):
    "Validate if the router can be correctly assigned to the agent.\n\n        :raises: RouterL3AgentMismatch if attempting to assign DVR router\n          to legacy agent.\n        :raises: InvalidL3Agent if attempting to assign router to an\n          unsuitable agent (disabled, type != L3, incompatible configuration)\n        :raises: DVRL3CannotAssignToDvrAgent if attempting to assign a\n          router to an agent in 'dvr' mode.\n        "
    if (agent['agent_type'] != constants.AGENT_TYPE_L3):
        raise l3agentscheduler.InvalidL3Agent(id=agent['id'])
    agent_mode = self._get_agent_mode(self)
    if (agent_mode == n_const.L3_AGENT_MODE_DVR):
        raise l3agentscheduler.DVRL3CannotAssignToDvrAgent()
    if ((agent_mode == n_const.L3_AGENT_MODE_LEGACY) and router.get('distributed')):
        raise l3agentscheduler.RouterL3AgentMismatch(router_id=router['id'], agent_id=agent['id'])
    is_suitable_agent = (agentschedulers_db.services_available(agent['admin_state_up']) and self.get_l3_agent_candidates(context, router, [agent], ignore_admin_state=True))
    if (not is_suitable_agent):
        raise l3agentscheduler.InvalidL3Agent(id=agent['id'])

dataset/ETHPy150Open openstack/neutron/neutron/db/l3_agentschedulers_db.py L3AgentSchedulerDbMixin.validate_agent_router_combination/VarMisuse@52/233 `agent`->`self`