Support both IPv4 and IPv6 DNS servers when creating networks
Change-Id: I3214703956d98860bd791d1ee4cfb96e08de3408
This commit is contained in:
parent
822e7c5fe4
commit
34a82c9f35
@ -14,6 +14,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
from .log import LOG
|
from .log import LOG
|
||||||
# Module containing a helper class for operating on OpenStack networks
|
# Module containing a helper class for operating on OpenStack networks
|
||||||
@ -166,6 +167,11 @@ class Network(object):
|
|||||||
LOG.info('Found existing internal network: %s', network_name)
|
LOG.info('Found existing internal network: %s', network_name)
|
||||||
return network
|
return network
|
||||||
|
|
||||||
|
ipv4_dns = [x for x in dns_nameservers
|
||||||
|
if type(ipaddress.ip_address(u'%s' % x)).__name__ == 'IPv4Address']
|
||||||
|
ipv6_dns = [x for x in dns_nameservers
|
||||||
|
if type(ipaddress.ip_address(u'%s' % x)).__name__ == 'IPv6Address']
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
'network': {
|
'network': {
|
||||||
'name': network_name,
|
'name': network_name,
|
||||||
@ -180,7 +186,7 @@ class Network(object):
|
|||||||
'network_id': network['id'],
|
'network_id': network['id'],
|
||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
'ip_version': 4,
|
'ip_version': 4,
|
||||||
'dns_nameservers': dns_nameservers
|
'dns_nameservers': ipv4_dns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if not enable_dhcp:
|
if not enable_dhcp:
|
||||||
@ -199,7 +205,8 @@ class Network(object):
|
|||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
'ip_version': 6,
|
'ip_version': 6,
|
||||||
'ipv6_ra_mode': ipv6_mode,
|
'ipv6_ra_mode': ipv6_mode,
|
||||||
'ipv6_address_mode': ipv6_mode
|
'ipv6_address_mode': ipv6_mode,
|
||||||
|
'dns_nameservers': ipv6_dns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if not enable_dhcp:
|
if not enable_dhcp:
|
||||||
|
Loading…
Reference in New Issue
Block a user