<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extend_hosting_port_info(self, context, port_db, hosting_device, hosting_info):
 """Get the segmenetation ID and interface This extends the hosting info attribute with the segmentation ID and physical interface used on the external router to connect to the ACI fabric. The segmentation ID should have been set already by the call to allocate_hosting_port, but if it's not present, use the value from the port resource. """

        if hosting_info.get('segmentation_id') is None:
            LOG.debug('No segmentation ID in hosting_info -- assigning')
            hosting_info['segmentation_id'] = (
                port_db.hosting_info.get('segmentation_id'))
        is_external = (port_db.device_owner == DEVICE_OWNER_ROUTER_GW)
        hosting_info['physical_interface'] = self._get_interface_info(
            hosting_device['id'], port_db.network_id, is_external)
        ext_dict, net = self._get_external_network_dict(context, port_db)
        if is_external and ext_dict:
            hosting_info['network_name'] = ext_dict['network_name']
            hosting_info['cidr_exposed'] = ext_dict['cidr_exposed']
            hosting_info['gateway_ip'] = ext_dict['gateway_ip']
            details = self.get_vrf_context(context,
                                           port_db['device_id'], port_db)
            router_id = port_db.device_id
            router = self.l3_plugin.get_router(context, router_id)
            # skip routers not created by the user -- they will have
            # empty-string tenant IDs
            if router.get(ROUTER_ROLE_ATTR):
                return
            hosting_info['vrf_id'] = details['vrf_id']
            if ext_dict.get('global_config'):
                hosting_info['global_config'] = (
                    ext_dict['global_config'])
            self._add_snat_info(context, router, net, hosting_info)
        else:
            if ext_dict.get('interface_config'):
                hosting_info['interface_config'] = ext_dict['interface_config']