def _internal_network_removed(self, ri, port, ex_gw_port):
itfc_deleted = False<EOL>driver = self.driver_manager.get_driver(ri.id)<EOL>vrf_name = driver._get_vrf_name(ri)<EOL>network_name = ex_gw_port['<STR_LIT>'].get('<STR_LIT>')<EOL>if self._router_ids_by_vrf_and_ext_net.get(<EOL>vrf_name, {}).get(network_name) and (<EOL>ri.router['<STR_LIT:id>'] in<EOL>self._router_ids_by_vrf_and_ext_net[vrf_name][network_name]):<EOL><INDENT>if len(ri.internal_ports) == <NUM_LIT:1> and port in ri.internal_ports:<EOL><INDENT>self._router_ids_by_vrf_and_ext_net[<EOL>vrf_name][network_name].remove(ri.router['<STR_LIT:id>'])<EOL>if not self._router_ids_by_vrf_and_ext_net[vrf_name].get(<EOL>network_name):<EOL><INDENT>LOG.debug("<STR_LIT>" % network_name)<EOL>itfc_deleted = True<EOL>del self._router_ids_by_vrf_and_ext_net[<EOL>vrf_name][network_name]<EOL>if not self._router_ids_by_vrf_and_ext_net.get(vrf_name):<EOL><INDENT>del self._router_ids_by_vrf_and_ext_net[vrf_name]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>driver.internal_network_removed(ri, port,<EOL>itfc_deleted=itfc_deleted)<EOL>if ri.snat_enabled and ex_gw_port:<EOL><INDENT>driver.disable_internal_network_NAT(ri, port, ex_gw_port,<EOL>itfc_deleted=itfc_deleted)<EOL><DEDENT>
Remove an internal router port

        Check to see if this is the last port to be removed for
        a given network scoped by a VRF (note: there can be
        different mappings between VRFs and networks -- 1-to-1,
        1-to-n, n-to-1, n-to-n -- depending on the configuration
        and workflow used). If it is the last port, set the flag
        indicating that the internal sub-interface for that netowrk
        on the ASR should be deleted