'Returns all the networks/subnets/ports in system.'

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

    host = kwargs.get('host')
    LOG.debug('get_active_networks_info    from    %s', host)
    networks = self._get_active_networks(context, **kwargs)
    plugin = directory.get_plugin()
    filters = {'network_id': [network['id'] for network in networks]}
    ports = plugin.get_ports(context, filters=filters)
    filters['enable_dhcp'] = [True]
    subnets = sorted(plugin.get_subnets(context, filters=filters), key=operator.itemgetter('id'))
    seg_plug = directory.get_plugin(segment_ext.SegmentPluginBase.get_plugin_type())
    seg_subnets = [subnet for subnet in subnets if subnet.get('segment_id')]
    nonlocal_subnets = []
    if (seg_plug and seg_subnets):
        host_segment_ids = seg_plug.get_segments_by_hosts(context, [host])
        seg_subnet_ids = {subnet['id'] for subnet in seg_subnets if (subnet['segment_id'] in host_segment_ids)}
        routed_net_ids = {seg_subnet['network_id'] for seg_subnet in seg_subnets}
        nonlocal_subnets = [subnet for subnet in seg_subnets if (subnet['id'] not in seg_subnet_ids)]
        subnets = [subnet for subnet in subnets if ((subnet['network_id'] not in routed_net_ids) or (subnet['id'] in seg_subnet_ids))]
    grouped_subnets = self._group_by_network_id(subnets)
    grouped_nonlocal_subnets = self._group_by_network_id(nonlocal_subnets)
    grouped_ports = self._group_by_network_id(ports)
    for network in networks:
        network['subnets'] = grouped_subnets.get(network['id'], [])
        network['non_local_subnets'] = grouped_nonlocal_subnets.get(network['id'], [])
        network['ports'] = grouped_ports.get(network['id'], [])
    return networks
