'Query routers and their gw ports for l3 agent.
Query routers with the router_ids. The gateway ports, if any,
will be queried too.
l3 agent has an option to deal with only one router id. In addition,
when we need to notify the agent the data about only one router
(when modification of router, its interfaces, gw_port and floatingips),
we will have router_ids.
@param router_ids: the list of router ids which we want to query.
if it is None, all of routers will be queried.
@return: a list of dicted routers with dicted gw_port populated if any'

def _get_sync_routers(self, context, router_ids=None, active=None):

    filters = ({'id': router_ids} if router_ids else {})
    if (active is not None):
        filters['admin_state_up'] = [active]
    router_dicts = model_query.get_collection(context, l3_models.Router, self._make_router_dict_with_gw_port, filters=filters)
    if (not router_dicts):
        return []
    gw_ports = dict(((r['gw_port']['id'], r['gw_port']) for r in router_dicts if r.get('gw_port')))
    return self._build_routers_list(context, router_dicts, gw_ports)
