'Creates network info list for instance.
called by allocate_for_instance and network_api
context needs to be elevated
:returns: network info list [(network,info),(network,info)...]
where network = dict containing pertinent data from a network db object
and info = dict containing pertinent networking data'

@messaging.expected_exceptions(exception.InstanceNotFound)
def get_instance_nw_info(self, context, instance_id, rxtx_factor, host, instance_uuid=None, **kwargs):

    if (not uuidutils.is_uuid_like(instance_id)):
        instance_id = instance_uuid
    instance_uuid = instance_id
    LOG.debug('Get    instance    network    info', instance_uuid=instance_uuid)
    try:
        fixed_ips = objects.FixedIPList.get_by_instance_uuid(context, instance_uuid)
    except exception.FixedIpNotFoundForInstance:
        fixed_ips = []
    LOG.debug('Found    %d    fixed    IPs    associated    to    the    instance    in    the    database.', len(fixed_ips), instance_uuid=instance_uuid)
    nw_info = network_model.NetworkInfo()
    vifs = collections.OrderedDict()
    for fixed_ip in fixed_ips:
        vif = fixed_ip.virtual_interface
        if (not vif):
            LOG.warning(_LW('No    VirtualInterface    for    FixedIP:    %s'), str(fixed_ip.address), instance_uuid=instance_uuid)
            continue
        if (not fixed_ip.network):
            LOG.warning(_LW('No    Network    for    FixedIP:    %s'), str(fixed_ip.address), instance_uuid=instance_uuid)
            continue
        if (vif.uuid in vifs):
            current = vifs[vif.uuid]
        else:
            current = {'id': vif.uuid, 'type': network_model.VIF_TYPE_BRIDGE, 'address': vif.address}
            vifs[vif.uuid] = current
            net_dict = self._get_network_dict(fixed_ip.network)
            network = network_model.Network(**net_dict)
            subnets = self._get_subnets_from_network(context, fixed_ip.network, host)
            network['subnets'] = subnets
            current['network'] = network
            try:
                current['rxtx_cap'] = (fixed_ip.network['rxtx_base'] * rxtx_factor)
            except (TypeError, KeyError):
                pass
            if (fixed_ip.network.cidr_v6 and vif.address):
                address = ipv6.to_global(fixed_ip.network.cidr_v6, vif.address, fixed_ip.network.project_id)
                model_ip = network_model.FixedIP(address=address)
                current['network']['subnets'][1]['ips'].append(model_ip)
        model_ip = network_model.FixedIP(address=str(fixed_ip.address))
        for ip in fixed_ip.floating_ips:
            floating_ip = network_model.IP(address=str(ip['address']), type='floating')
            model_ip.add_floating_ip(floating_ip)
        current['network']['subnets'][0]['ips'].append(model_ip)
    for vif in vifs.values():
        nw_info.append(network_model.VIF(**vif))
    LOG.debug('Built    network    info:    |%s|', nw_info, instance_uuid=instance_uuid)
    return nw_info
