def _fetch_router_info(self, router_ids=None, device_ids=None,<EOL>all_routers=False):
try:<EOL><INDENT>if all_routers:<EOL><INDENT>LOG.debug('<STR_LIT>')<EOL>router_ids = self.plugin_rpc.get_router_ids(self.context)<EOL>routers = self._fetch_router_chunk_data(router_ids)<EOL><DEDENT>elif router_ids:<EOL><INDENT>routers = self._fetch_router_chunk_data(router_ids)<EOL><DEDENT>elif device_ids:<EOL><INDENT>return self.plugin_rpc.get_routers(self.context,<EOL>hd_ids=device_ids)<EOL><DEDENT><DEDENT>except oslo_messaging.MessagingTimeout:<EOL><INDENT>if self.sync_routers_chunk_size > SYNC_ROUTERS_MIN_CHUNK_SIZE:<EOL><INDENT>self.sync_routers_chunk_size = max(<EOL>int(round(self.sync_routers_chunk_size / <NUM_LIT:2>)),<EOL>SYNC_ROUTERS_MIN_CHUNK_SIZE)<EOL>LOG.warning('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>self.sync_routers_chunk_size)<EOL><DEDENT>else:<EOL><INDENT>LOG.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>self.sync_routers_chunk_size)<EOL><DEDENT>raise<EOL><DEDENT>except oslo_messaging.MessagingException:<EOL><INDENT>LOG.exception("<STR_LIT>")<EOL>self.fullsync = True<EOL>raise n_exc.AbortSyncRouters()<EOL><DEDENT>LOG.debug("<STR_LIT>")<EOL>if (self.sync_routers_chunk_size <<EOL>cfg.CONF.cfg_agent.max_device_sync_batch_size):<EOL><INDENT>self.sync_routers_chunk_size = min(<EOL>self.sync_routers_chunk_size + SYNC_ROUTERS_MIN_CHUNK_SIZE,<EOL>cfg.CONF.cfg_agent.max_device_sync_batch_size)<EOL><DEDENT>return routers<EOL>
Fetch router dict from the routing plugin.

        :param router_ids: List of router_ids of routers to fetch
        :param device_ids: List of device_ids whose routers to fetch
        :param all_routers:  If True fetch all the routers for this agent.
        :return: List of router dicts of format:
                 [ {router_dict1}, {router_dict2},.....]