'Test port create with multiple IPv4, IPv6 DHCP/SLAAC subnets.'

def _test_create_port_with_multiple_ipv4_and_ipv6_subnets(self, dns_name=''):

    res = self._create_network(fmt=self.fmt, name='net', admin_state_up=True)
    network = self.deserialize(self.fmt, res)
    sub_dicts = [{'gateway': '10.0.0.1', 'cidr': '10.0.0.0/24', 'ip_version': 4, 'ra_addr_mode': None}, {'gateway': '10.0.1.1', 'cidr': '10.0.1.0/24', 'ip_version': 4, 'ra_addr_mode': None}, {'gateway': 'fe80::1', 'cidr': 'fe80::/64', 'ip_version': 6, 'ra_addr_mode': constants.IPV6_SLAAC}, {'gateway': 'fe81::1', 'cidr': 'fe81::/64', 'ip_version': 6, 'ra_addr_mode': constants.IPV6_SLAAC}, {'gateway': 'fe82::1', 'cidr': 'fe82::/64', 'ip_version': 6, 'ra_addr_mode': constants.DHCPV6_STATEFUL}, {'gateway': 'fe83::1', 'cidr': 'fe83::/64', 'ip_version': 6, 'ra_addr_mode': constants.DHCPV6_STATEFUL}]
    subnets = {}
    for sub_dict in sub_dicts:
        subnet = self._make_subnet(self.fmt, network, gateway=sub_dict['gateway'], cidr=sub_dict['cidr'], ip_version=sub_dict['ip_version'], ipv6_ra_mode=sub_dict['ra_addr_mode'], ipv6_address_mode=sub_dict['ra_addr_mode'])
        subnets[subnet['subnet']['id']] = sub_dict
    res = self._create_port(self.fmt, net_id=network['network']['id'], dns_name=dns_name)
    if (res.status_code != 201):
        return res
    port = self.deserialize(self.fmt, res)
    self.assertEqual(4, len(port['port']['fixed_ips']))
    addr_mode_count = {None: 0, constants.DHCPV6_STATEFUL: 0, constants.IPV6_SLAAC: 0}
    for fixed_ip in port['port']['fixed_ips']:
        subnet_id = fixed_ip['subnet_id']
        if (subnet_id in subnets):
            addr_mode_count[subnets[subnet_id]['ra_addr_mode']] += 1
    self.assertEqual(1, addr_mode_count[None])
    self.assertEqual(1, addr_mode_count[constants.DHCPV6_STATEFUL])
    self.assertEqual(2, addr_mode_count[constants.IPV6_SLAAC])
    self._verify_dns_assigment(port['port'], exp_ips_ipv4=1, exp_ips_ipv6=3, ipv4_cidrs=[sub_dicts[0]['cidr'], sub_dicts[1]['cidr']], ipv6_cidrs=[sub_dicts[2]['cidr'], sub_dicts[3]['cidr'], sub_dicts[4]['cidr'], sub_dicts[5]['cidr']], dns_name=dns_name)
    return res
