'For an auto-address subnet, add addrs for ports on the net.'

def add_auto_addrs_on_network_ports(self, context, subnet, ipam_subnet):

    if (subnet['id'] != ipam_subnet.subnet_manager.neutron_id):
        raise RuntimeError(("Subnet    manager    doesn't    match    subnet.    %s    !=    %s" % (subnet['id'], ipam_subnet.subnet_manager.neutron_id)))
    with context.session.begin(subtransactions=True):
        network_id = subnet['network_id']
        port_qry = context.session.query(models_v2.Port)
        ports = port_qry.filter(and_((models_v2.Port.network_id == network_id), (~ models_v2.Port.device_owner.in_(constants.ROUTER_INTERFACE_OWNERS_SNAT))))
        updated_ports = []
        ipam_driver = driver.Pool.get_instance(None, context)
        factory = ipam_driver.get_address_request_factory()
        for port in ports:
            ip = {'subnet_id': subnet['id'], 'subnet_cidr': subnet['cidr'], 'eui64_address': True, 'mac': port['mac_address']}
            ip_request = factory.get_request(context, port, ip)
            LOG.debug('Requesting    with    IP    request:    %s    port:    %s    ip:    %s    for    subnet    %s    and    ipam_subnet    %s', ip_request, port, ip, subnet, ipam_subnet)
            try:
                ip_address = ipam_subnet.allocate(ip_request)
                allocated = port_obj.IPAllocation(context, network_id=network_id, port_id=port['id'], ip_address=ip_address, subnet_id=subnet['id'])
                with db_api.context_manager.writer.using(context):
                    allocated.create()
                updated_ports.append(port['id'])
            except db_exc.DBReferenceError:
                LOG.debug('Port    %s    was    deleted    while    updating    it    with    an    IPv6    auto-address.    Ignoring.', port['id'])
                LOG.debug('Reverting    IP    allocation    for    %s', ip_address)
                try:
                    ipam_subnet.deallocate(ip_address)
                except Exception:
                    LOG.debug('Reverting    IP    allocation    failed    for    %s', ip_address)
            except ipam_exc.IpAddressAlreadyAllocated:
                LOG.debug('Port    %s    got    IPv6    auto-address    in    a    concurrent    create    or    update    port    request.    Ignoring.', port['id'])
        return updated_ports
