'Return bindings. In case if dead agents were detected update router
states on this agent.'

def _get_bindings_and_update_router_state_for_dead_agents(self, context, router_id):

    with context.session.begin(subtransactions=True):
        bindings = self.get_ha_router_port_bindings(context, [router_id])
        dead_agents = []
        active = [binding for binding in bindings if (binding.state == n_const.HA_ROUTER_STATE_ACTIVE)]
        if (len(active) > 1):
            dead_agents = [binding.agent for binding in active if (not (binding.agent.is_active and binding.agent.admin_state_up))]
            for dead_agent in dead_agents:
                self.update_routers_states(context, {router_id: n_const.HA_ROUTER_STATE_STANDBY}, dead_agent.host)
    if dead_agents:
        return self.get_ha_router_port_bindings(context, [router_id])
    return bindings
