'Allocate IP addresses for the port. IPAM version.
If port[\'fixed_ips\'] is set to \'ATTR_NOT_SPECIFIED\', allocate IP
addresses for the port. If port[\'fixed_ips\'] contains an IP address or
a subnet_id then allocate an IP address accordingly.'

def _allocate_ips_for_port(self, context, port):

    p = port['port']
    fixed_configured = (p['fixed_ips'] is not constants.ATTR_NOT_SPECIFIED)
    subnets = self._ipam_get_subnets(context, network_id=p['network_id'], host=p.get(portbindings.HOST_ID), service_type=p.get('device_owner'), fixed_configured=fixed_configured)
    (v4, v6_stateful, v6_stateless) = self._classify_subnets(context, subnets)
    if fixed_configured:
        ips = self._test_fixed_ips_for_port(context, p['network_id'], p['fixed_ips'], p['device_owner'], subnets)
    else:
        ips = []
        version_subnets = [v4, v6_stateful]
        for subnets in version_subnets:
            if subnets:
                ips.append([{'subnet_id': s['id']} for s in subnets])
    ips.extend(self._get_auto_address_ips(v6_stateless, p))
    ipam_driver = driver.Pool.get_instance(None, context)
    return self._ipam_allocate_ips(context, ipam_driver, p, ips)
