def _process_router(self, ri):
try:<EOL><INDENT>ex_gw_port = ri.router.get('<STR_LIT>')<EOL>ri.ha_info = ri.router.get('<STR_LIT>', None)<EOL>gateway_set = ex_gw_port and not ri.ex_gw_port<EOL>gateway_cleared = not ex_gw_port and ri.ex_gw_port<EOL>internal_ports = ri.router.get(bc.constants.INTERFACE_KEY, [])<EOL>if gateway_set:<EOL><INDENT>self._add_rid_to_vrf_list(ri)<EOL><DEDENT>new_ports, old_ports, change_details = (<EOL>self._get_internal_port_changes(ri, internal_ports))<EOL>list_port_ids_up = []<EOL>non_global_router_roles = [None,<EOL>c_constants.ROUTER_ROLE_HA_REDUNDANCY]<EOL>if ri.router[ROUTER_ROLE_ATTR] in non_global_router_roles:<EOL><INDENT>self._process_new_ports(ri, new_ports, ex_gw_port,<EOL>list_port_ids_up, change_details)<EOL>self._process_old_ports(ri, old_ports, ex_gw_port,<EOL>change_details)<EOL><DEDENT>else:<EOL><INDENT>self._process_new_ports_global(ri, new_ports, ex_gw_port,<EOL>list_port_ids_up)<EOL>self._process_old_ports_global(ri, old_ports, ex_gw_port)<EOL><DEDENT>if gateway_set:<EOL><INDENT>self._process_gateway_set(ri, ex_gw_port,<EOL>list_port_ids_up)<EOL><DEDENT>elif gateway_cleared:<EOL><INDENT>self._process_gateway_cleared(ri, ri.ex_gw_port)<EOL><DEDENT>self._send_update_port_statuses(list_port_ids_up,<EOL>bc.constants.PORT_STATUS_ACTIVE)<EOL>if ex_gw_port:<EOL><INDENT>self._process_router_floating_ips(ri, ex_gw_port)<EOL><DEDENT>global_router_roles = [c_constants.ROUTER_ROLE_GLOBAL,<EOL>c_constants.ROUTER_ROLE_LOGICAL_GLOBAL]<EOL>if ri.router[ROUTER_ROLE_ATTR] not in global_router_roles:<EOL><INDENT>self._enable_disable_ports(ri, ex_gw_port, internal_ports)<EOL>if gateway_cleared:<EOL><INDENT>self._remove_rid_from_vrf_list(ri)<EOL><DEDENT><DEDENT>ri.ex_gw_port = ex_gw_port<EOL>self._routes_updated(ri)<EOL><DEDENT>except cfg_exceptions.HAParamsMissingException as e:<EOL><INDENT>self._update_updated_routers_cache([ri.router_id])<EOL>LOG.warning(e)<EOL><DEDENT>except cfg_exceptions.DriverException as e:<EOL><INDENT>with excutils.save_and_reraise_exception():<EOL><INDENT>self._update_updated_routers_cache([ri.router_id])<EOL>LOG.error(e)<EOL><DEDENT><DEDENT>
Process a router, apply latest configuration and update router_info.

        Get the router dict from  RouterInfo and proceed to detect changes
        from the last known state. When new ports or deleted ports are
        detected, `internal_network_added()` or `internal_networks_removed()`
        are called accordingly. Similarly changes in ex_gw_port causes
         `external_gateway_added()` or `external_gateway_removed()` calls.
        Next, floating_ips and routes are processed. Also, latest state is
        stored in ri.internal_ports and ri.ex_gw_port for future comparisons.

        :param ri : RouterInfo object of the router being processed.
        :return:None
        :raises: networking_cisco.plugins.cisco.cfg_agent.cfg_exceptions.
        DriverException if the configuration operation fails.