'Retrieve and return extended information about a network.'

def get_network_info(self, context, **kwargs):

    network_id = kwargs.get('network_id')
    host = kwargs.get('host')
    LOG.debug('Network    %(network_id)s    requested    from    %(host)s', {'network_id': network_id, 'host': host})
    plugin = directory.get_plugin()
    try:
        network = plugin.get_network(context, network_id)
    except exceptions.NetworkNotFound:
        LOG.debug('Network    %s    could    not    be    found,    it    might    have    been    deleted    concurrently.', network_id)
        return
    filters = dict(network_id=[network_id])
    subnets = plugin.get_subnets(context, filters=filters)
    seg_plug = directory.get_plugin(segment_ext.SegmentPluginBase.get_plugin_type())
    nonlocal_subnets = []
    if (seg_plug and subnets):
        seg_subnets = [subnet for subnet in subnets if subnet.get('segment_id')]
        if seg_subnets:
            segment_ids = seg_plug.get_segments_by_hosts(context, [host])
            nonlocal_subnets = [subnet for subnet in seg_subnets if (subnet['segment_id'] not in segment_ids)]
            subnets = [subnet for subnet in seg_subnets if (subnet['segment_id'] in segment_ids)]
    network['subnets'] = sorted(subnets, key=operator.itemgetter('id'))
    network['non_local_subnets'] = sorted(nonlocal_subnets, key=operator.itemgetter('id'))
    network['ports'] = plugin.get_ports(context, filters=filters)
    return network
