Use constant IP_VERSION_4/6 in functional tests
Change-Id: I62b5a37508838a42b03a39de02660b8cafc08c41
This commit is contained in:
parent
12bb26fd0e
commit
46913a69fd
|
@ -53,22 +53,26 @@ def get_ha_interface(ip='169.254.192.1', mac='12:34:56:78:2b:5d'):
|
||||||
'priority': 1}
|
'priority': 1}
|
||||||
|
|
||||||
|
|
||||||
def prepare_router_data(ip_version=4, enable_snat=None, num_internal_ports=1,
|
def prepare_router_data(ip_version=lib_constants.IP_VERSION_4,
|
||||||
|
enable_snat=None, num_internal_ports=1,
|
||||||
enable_floating_ip=False, enable_ha=False,
|
enable_floating_ip=False, enable_ha=False,
|
||||||
extra_routes=False, dual_stack=False,
|
extra_routes=False, dual_stack=False, enable_gw=True,
|
||||||
enable_gw=True, v6_ext_gw_with_sub=True, **kwargs):
|
v6_ext_gw_with_sub=True, **kwargs):
|
||||||
fixed_ips = []
|
fixed_ips = []
|
||||||
subnets = []
|
subnets = []
|
||||||
gateway_mac = kwargs.get('gateway_mac', 'ca:fe:de:ad:be:ee')
|
gateway_mac = kwargs.get('gateway_mac', 'ca:fe:de:ad:be:ee')
|
||||||
extra_subnets = []
|
extra_subnets = []
|
||||||
for loop_version in (4, 6):
|
for loop_version in (lib_constants.IP_VERSION_4,
|
||||||
if loop_version == 4 and (ip_version == 4 or dual_stack):
|
lib_constants.IP_VERSION_6):
|
||||||
|
if (loop_version == lib_constants.IP_VERSION_4 and
|
||||||
|
(ip_version == lib_constants.IP_VERSION_4 or dual_stack)):
|
||||||
ip_address = kwargs.get('ip_address', '19.4.4.4')
|
ip_address = kwargs.get('ip_address', '19.4.4.4')
|
||||||
prefixlen = 24
|
prefixlen = 24
|
||||||
subnet_cidr = kwargs.get('subnet_cidr', '19.4.4.0/24')
|
subnet_cidr = kwargs.get('subnet_cidr', '19.4.4.0/24')
|
||||||
gateway_ip = kwargs.get('gateway_ip', '19.4.4.1')
|
gateway_ip = kwargs.get('gateway_ip', '19.4.4.1')
|
||||||
_extra_subnet = {'cidr': '9.4.5.0/24'}
|
_extra_subnet = {'cidr': '9.4.5.0/24'}
|
||||||
elif (loop_version == 6 and (ip_version == 6 or dual_stack) and
|
elif (loop_version == lib_constants.IP_VERSION_6 and
|
||||||
|
(ip_version == lib_constants.IP_VERSION_6 or dual_stack) and
|
||||||
v6_ext_gw_with_sub):
|
v6_ext_gw_with_sub):
|
||||||
ip_address = kwargs.get('ip_address', 'fd00::4')
|
ip_address = kwargs.get('ip_address', 'fd00::4')
|
||||||
prefixlen = 64
|
prefixlen = 64
|
||||||
|
@ -137,8 +141,10 @@ def get_subnet_id(port):
|
||||||
return port['fixed_ips'][0]['subnet_id']
|
return port['fixed_ips'][0]['subnet_id']
|
||||||
|
|
||||||
|
|
||||||
def router_append_interface(router, count=1, ip_version=4, ra_mode=None,
|
def router_append_interface(router, count=1,
|
||||||
addr_mode=None, dual_stack=False, same_port=False):
|
ip_version=lib_constants.IP_VERSION_4,
|
||||||
|
ra_mode=None, addr_mode=None, dual_stack=False,
|
||||||
|
same_port=False):
|
||||||
interfaces = router[lib_constants.INTERFACE_KEY]
|
interfaces = router[lib_constants.INTERFACE_KEY]
|
||||||
current = sum(
|
current = sum(
|
||||||
[netaddr.IPNetwork(subnet['cidr']).version == ip_version
|
[netaddr.IPNetwork(subnet['cidr']).version == ip_version
|
||||||
|
@ -148,7 +154,7 @@ def router_append_interface(router, count=1, ip_version=4, ra_mode=None,
|
||||||
# If same_port=True, create ip_version number of subnets on a single port
|
# If same_port=True, create ip_version number of subnets on a single port
|
||||||
# Else create just an ip_version subnet on each port
|
# Else create just an ip_version subnet on each port
|
||||||
if dual_stack:
|
if dual_stack:
|
||||||
ip_versions = [4, 6]
|
ip_versions = [lib_constants.IP_VERSION_4, lib_constants.IP_VERSION_6]
|
||||||
elif same_port:
|
elif same_port:
|
||||||
ip_versions = [ip_version] * count
|
ip_versions = [ip_version] * count
|
||||||
count = 1
|
count = 1
|
||||||
|
@ -161,12 +167,14 @@ def router_append_interface(router, count=1, ip_version=4, ra_mode=None,
|
||||||
fixed_ips = []
|
fixed_ips = []
|
||||||
subnets = []
|
subnets = []
|
||||||
for loop_version in ip_versions:
|
for loop_version in ip_versions:
|
||||||
if loop_version == 4 and (ip_version == 4 or dual_stack):
|
if (loop_version == lib_constants.IP_VERSION_4 and
|
||||||
|
(ip_version == lib_constants.IP_VERSION_4 or dual_stack)):
|
||||||
ip_pool = '35.4.%i.4'
|
ip_pool = '35.4.%i.4'
|
||||||
cidr_pool = '35.4.%i.0/24'
|
cidr_pool = '35.4.%i.0/24'
|
||||||
prefixlen = 24
|
prefixlen = 24
|
||||||
gw_pool = '35.4.%i.1'
|
gw_pool = '35.4.%i.1'
|
||||||
elif loop_version == 6 and (ip_version == 6 or dual_stack):
|
elif (loop_version == lib_constants.IP_VERSION_6 and
|
||||||
|
(ip_version == lib_constants.IP_VERSION_6 or dual_stack)):
|
||||||
ip_pool = 'fd01:%x:1::6'
|
ip_pool = 'fd01:%x:1::6'
|
||||||
cidr_pool = 'fd01:%x:1::/64'
|
cidr_pool = 'fd01:%x:1::/64'
|
||||||
prefixlen = 64
|
prefixlen = 64
|
||||||
|
@ -196,10 +204,11 @@ def router_append_interface(router, count=1, ip_version=4, ra_mode=None,
|
||||||
mac_address.value += 1
|
mac_address.value += 1
|
||||||
|
|
||||||
|
|
||||||
def router_append_subnet(router, count=1, ip_version=4,
|
def router_append_subnet(router, count=1,
|
||||||
|
ip_version=lib_constants.IP_VERSION_4,
|
||||||
ipv6_subnet_modes=None, interface_id=None,
|
ipv6_subnet_modes=None, interface_id=None,
|
||||||
dns_nameservers=None, network_mtu=0):
|
dns_nameservers=None, network_mtu=0):
|
||||||
if ip_version == 6:
|
if ip_version == lib_constants.IP_VERSION_6:
|
||||||
subnet_mode_none = {'ra_mode': None, 'address_mode': None}
|
subnet_mode_none = {'ra_mode': None, 'address_mode': None}
|
||||||
if not ipv6_subnet_modes:
|
if not ipv6_subnet_modes:
|
||||||
ipv6_subnet_modes = [subnet_mode_none] * count
|
ipv6_subnet_modes = [subnet_mode_none] * count
|
||||||
|
@ -208,12 +217,12 @@ def router_append_subnet(router, count=1, ip_version=4,
|
||||||
moves.range(len(ipv6_subnet_modes),
|
moves.range(len(ipv6_subnet_modes),
|
||||||
count)])
|
count)])
|
||||||
|
|
||||||
if ip_version == 4:
|
if ip_version == lib_constants.IP_VERSION_4:
|
||||||
ip_pool = '35.4.%i.4'
|
ip_pool = '35.4.%i.4'
|
||||||
cidr_pool = '35.4.%i.0/24'
|
cidr_pool = '35.4.%i.0/24'
|
||||||
prefixlen = 24
|
prefixlen = 24
|
||||||
gw_pool = '35.4.%i.1'
|
gw_pool = '35.4.%i.1'
|
||||||
elif ip_version == 6:
|
elif ip_version == lib_constants.IP_VERSION_6:
|
||||||
ip_pool = 'fd01:%x::6'
|
ip_pool = 'fd01:%x::6'
|
||||||
cidr_pool = 'fd01:%x::/64'
|
cidr_pool = 'fd01:%x::/64'
|
||||||
prefixlen = 64
|
prefixlen = 64
|
||||||
|
|
|
@ -388,7 +388,7 @@ class Pinger(object):
|
||||||
if self.proc and self.proc.is_running:
|
if self.proc and self.proc.is_running:
|
||||||
raise RuntimeError("This pinger has already a running process")
|
raise RuntimeError("This pinger has already a running process")
|
||||||
ip_version = common_utils.get_ip_version(self.address)
|
ip_version = common_utils.get_ip_version(self.address)
|
||||||
ping_exec = 'ping' if ip_version == 4 else 'ping6'
|
ping_exec = 'ping' if ip_version == n_const.IP_VERSION_4 else 'ping6'
|
||||||
cmd = [ping_exec, self.address, '-W', str(self.timeout)]
|
cmd = [ping_exec, self.address, '-W', str(self.timeout)]
|
||||||
if self.count:
|
if self.count:
|
||||||
cmd.extend(['-c', str(self.count)])
|
cmd.extend(['-c', str(self.count)])
|
||||||
|
@ -416,8 +416,8 @@ class NetcatTester(object):
|
||||||
UDP = n_const.PROTO_NAME_UDP
|
UDP = n_const.PROTO_NAME_UDP
|
||||||
SCTP = n_const.PROTO_NAME_SCTP
|
SCTP = n_const.PROTO_NAME_SCTP
|
||||||
VERSION_TO_ALL_ADDRESS = {
|
VERSION_TO_ALL_ADDRESS = {
|
||||||
4: '0.0.0.0',
|
n_const.IP_VERSION_4: '0.0.0.0',
|
||||||
6: '::',
|
n_const.IP_VERSION_6: '::',
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, client_namespace, server_namespace, address,
|
def __init__(self, client_namespace, server_namespace, address,
|
||||||
|
|
|
@ -103,12 +103,14 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
def _get_agent_ovs_integration_bridge(self, agent):
|
def _get_agent_ovs_integration_bridge(self, agent):
|
||||||
return get_ovs_bridge(agent.conf.ovs_integration_bridge)
|
return get_ovs_bridge(agent.conf.ovs_integration_bridge)
|
||||||
|
|
||||||
def generate_router_info(self, enable_ha, ip_version=4, extra_routes=True,
|
def generate_router_info(self, enable_ha,
|
||||||
|
ip_version=constants.IP_VERSION_4,
|
||||||
|
extra_routes=True,
|
||||||
enable_fip=True, enable_snat=True,
|
enable_fip=True, enable_snat=True,
|
||||||
num_internal_ports=1,
|
num_internal_ports=1,
|
||||||
dual_stack=False, v6_ext_gw_with_sub=True,
|
dual_stack=False, v6_ext_gw_with_sub=True,
|
||||||
qos_policy_id=None):
|
qos_policy_id=None):
|
||||||
if ip_version == 6 and not dual_stack:
|
if ip_version == constants.IP_VERSION_6 and not dual_stack:
|
||||||
enable_snat = False
|
enable_snat = False
|
||||||
enable_fip = False
|
enable_fip = False
|
||||||
extra_routes = False
|
extra_routes = False
|
||||||
|
@ -239,7 +241,7 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
'net.ipv6.conf.%s.forwarding' % external_device_name])
|
'net.ipv6.conf.%s.forwarding' % external_device_name])
|
||||||
self.assertEqual(int(enabled), int(fwd_state))
|
self.assertEqual(int(enabled), int(fwd_state))
|
||||||
|
|
||||||
def _router_lifecycle(self, enable_ha, ip_version=4,
|
def _router_lifecycle(self, enable_ha, ip_version=constants.IP_VERSION_4,
|
||||||
dual_stack=False, v6_ext_gw_with_sub=True,
|
dual_stack=False, v6_ext_gw_with_sub=True,
|
||||||
router_info=None):
|
router_info=None):
|
||||||
router_info = router_info or self.generate_router_info(
|
router_info = router_info or self.generate_router_info(
|
||||||
|
@ -253,9 +255,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
slaac_mode = {'ra_mode': slaac, 'address_mode': slaac}
|
slaac_mode = {'ra_mode': slaac, 'address_mode': slaac}
|
||||||
subnet_modes = [slaac_mode] * 2
|
subnet_modes = [slaac_mode] * 2
|
||||||
self._add_internal_interface_by_subnet(router.router,
|
self._add_internal_interface_by_subnet(router.router,
|
||||||
count=2,
|
count=2, ip_version=constants.IP_VERSION_6,
|
||||||
ip_version=6,
|
ipv6_subnet_modes=subnet_modes)
|
||||||
ipv6_subnet_modes=subnet_modes)
|
|
||||||
router.process()
|
router.process()
|
||||||
|
|
||||||
if enable_ha:
|
if enable_ha:
|
||||||
|
@ -282,7 +283,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
lambda: self._metadata_proxy_exists(self.agent.conf, router))
|
lambda: self._metadata_proxy_exists(self.agent.conf, router))
|
||||||
self._assert_internal_devices(router)
|
self._assert_internal_devices(router)
|
||||||
self._assert_external_device(router)
|
self._assert_external_device(router)
|
||||||
if not (enable_ha and (ip_version == 6 or dual_stack)):
|
if not (enable_ha and
|
||||||
|
(ip_version == constants.IP_VERSION_6 or dual_stack)):
|
||||||
# Note(SridharG): enable the assert_gateway for IPv6 once
|
# Note(SridharG): enable the assert_gateway for IPv6 once
|
||||||
# keepalived on Ubuntu14.04 (i.e., check-neutron-dsvm-functional
|
# keepalived on Ubuntu14.04 (i.e., check-neutron-dsvm-functional
|
||||||
# platform) is updated to 1.2.10 (or above).
|
# platform) is updated to 1.2.10 (or above).
|
||||||
|
@ -293,7 +295,10 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
self._assert_floating_ip_chains(router)
|
self._assert_floating_ip_chains(router)
|
||||||
self._assert_iptables_rules_converged(router)
|
self._assert_iptables_rules_converged(router)
|
||||||
self._assert_extra_routes(router)
|
self._assert_extra_routes(router)
|
||||||
ip_versions = [4, 6] if (ip_version == 6 or dual_stack) else [4]
|
if (ip_version == constants.IP_VERSION_6 or dual_stack):
|
||||||
|
ip_versions = [constants.IP_VERSION_4, constants.IP_VERSION_6]
|
||||||
|
else:
|
||||||
|
ip_versions = [constants.IP_VERSION_4]
|
||||||
self._assert_onlink_subnet_routes(router, ip_versions)
|
self._assert_onlink_subnet_routes(router, ip_versions)
|
||||||
self._assert_metadata_chains(router)
|
self._assert_metadata_chains(router)
|
||||||
|
|
||||||
|
@ -359,7 +364,7 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||||
router.router[constants.FLOATINGIP_KEY].append(fip)
|
router.router[constants.FLOATINGIP_KEY].append(fip)
|
||||||
|
|
||||||
def _add_internal_interface_by_subnet(self, router, count=1,
|
def _add_internal_interface_by_subnet(self, router, count=1,
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
ipv6_subnet_modes=None,
|
ipv6_subnet_modes=None,
|
||||||
interface_id=None):
|
interface_id=None):
|
||||||
return l3_test_common.router_append_subnet(router, count,
|
return l3_test_common.router_append_subnet(router, count,
|
||||||
|
|
|
@ -406,7 +406,9 @@ class TestDvrRouter(framework.L3AgentTestFramework):
|
||||||
self._validate_fips_for_external_network(router2, fip2_ns)
|
self._validate_fips_for_external_network(router2, fip2_ns)
|
||||||
|
|
||||||
def _dvr_router_lifecycle(self, enable_ha=False, enable_snat=False,
|
def _dvr_router_lifecycle(self, enable_ha=False, enable_snat=False,
|
||||||
custom_mtu=2000, ip_version=4, dual_stack=False):
|
custom_mtu=2000,
|
||||||
|
ip_version=lib_constants.IP_VERSION_4,
|
||||||
|
dual_stack=False):
|
||||||
'''Test dvr router lifecycle
|
'''Test dvr router lifecycle
|
||||||
|
|
||||||
:param enable_ha: sets the ha value for the router.
|
:param enable_ha: sets the ha value for the router.
|
||||||
|
@ -484,7 +486,11 @@ class TestDvrRouter(framework.L3AgentTestFramework):
|
||||||
self._assert_metadata_chains(router)
|
self._assert_metadata_chains(router)
|
||||||
self._assert_rfp_fpr_mtu(router, custom_mtu)
|
self._assert_rfp_fpr_mtu(router, custom_mtu)
|
||||||
if enable_snat:
|
if enable_snat:
|
||||||
ip_versions = [4, 6] if (ip_version == 6 or dual_stack) else [4]
|
if (ip_version == lib_constants.IP_VERSION_6 or dual_stack):
|
||||||
|
ip_versions = [lib_constants.IP_VERSION_4,
|
||||||
|
lib_constants.IP_VERSION_6]
|
||||||
|
else:
|
||||||
|
ip_versions = [lib_constants.IP_VERSION_4]
|
||||||
snat_ns_name = dvr_snat_ns.SnatNamespace.get_snat_ns_name(
|
snat_ns_name = dvr_snat_ns.SnatNamespace.get_snat_ns_name(
|
||||||
router.router_id)
|
router.router_id)
|
||||||
self._assert_onlink_subnet_routes(
|
self._assert_onlink_subnet_routes(
|
||||||
|
|
|
@ -84,12 +84,14 @@ class L3HATestCase(framework.L3AgentTestFramework):
|
||||||
self._test_conntrack_disassociate_fip(ha=True)
|
self._test_conntrack_disassociate_fip(ha=True)
|
||||||
|
|
||||||
def test_ipv6_ha_router_lifecycle(self):
|
def test_ipv6_ha_router_lifecycle(self):
|
||||||
self._router_lifecycle(enable_ha=True, ip_version=6)
|
self._router_lifecycle(enable_ha=True,
|
||||||
|
ip_version=constants.IP_VERSION_6)
|
||||||
|
|
||||||
def test_ipv6_ha_router_lifecycle_with_no_gw_subnet(self):
|
def test_ipv6_ha_router_lifecycle_with_no_gw_subnet(self):
|
||||||
self.agent.conf.set_override('ipv6_gateway',
|
self.agent.conf.set_override('ipv6_gateway',
|
||||||
'fe80::f816:3eff:fe2e:1')
|
'fe80::f816:3eff:fe2e:1')
|
||||||
self._router_lifecycle(enable_ha=True, ip_version=6,
|
self._router_lifecycle(enable_ha=True,
|
||||||
|
ip_version=constants.IP_VERSION_6,
|
||||||
v6_ext_gw_with_sub=False)
|
v6_ext_gw_with_sub=False)
|
||||||
|
|
||||||
def test_ipv6_ha_router_lifecycle_with_no_gw_subnet_for_router_advts(self):
|
def test_ipv6_ha_router_lifecycle_with_no_gw_subnet_for_router_advts(self):
|
||||||
|
@ -209,7 +211,8 @@ class L3HATestCase(framework.L3AgentTestFramework):
|
||||||
router1.get_ha_device_name()))
|
router1.get_ha_device_name()))
|
||||||
|
|
||||||
def test_ha_router_ipv6_radvd_status(self):
|
def test_ha_router_ipv6_radvd_status(self):
|
||||||
router_info = self.generate_router_info(ip_version=6, enable_ha=True)
|
router_info = self.generate_router_info(
|
||||||
|
ip_version=constants.IP_VERSION_6, enable_ha=True)
|
||||||
router1 = self.manage_router(self.agent, router_info)
|
router1 = self.manage_router(self.agent, router_info)
|
||||||
common_utils.wait_until_true(lambda: router1.ha_state == 'master')
|
common_utils.wait_until_true(lambda: router1.ha_state == 'master')
|
||||||
common_utils.wait_until_true(lambda: router1.radvd.enabled)
|
common_utils.wait_until_true(lambda: router1.radvd.enabled)
|
||||||
|
@ -235,7 +238,8 @@ class L3HATestCase(framework.L3AgentTestFramework):
|
||||||
_check_lla_status(router1, False)
|
_check_lla_status(router1, False)
|
||||||
|
|
||||||
def test_ha_router_process_ipv6_subnets_to_existing_port(self):
|
def test_ha_router_process_ipv6_subnets_to_existing_port(self):
|
||||||
router_info = self.generate_router_info(enable_ha=True, ip_version=6)
|
router_info = self.generate_router_info(enable_ha=True,
|
||||||
|
ip_version=constants.IP_VERSION_6)
|
||||||
router = self.manage_router(self.agent, router_info)
|
router = self.manage_router(self.agent, router_info)
|
||||||
|
|
||||||
def verify_ip_in_keepalived_config(router, iface):
|
def verify_ip_in_keepalived_config(router, iface):
|
||||||
|
@ -250,7 +254,8 @@ class L3HATestCase(framework.L3AgentTestFramework):
|
||||||
|
|
||||||
# Add a second IPv6 subnet to the router internal interface.
|
# Add a second IPv6 subnet to the router internal interface.
|
||||||
self._add_internal_interface_by_subnet(router.router, count=1,
|
self._add_internal_interface_by_subnet(router.router, count=1,
|
||||||
ip_version=6, ipv6_subnet_modes=[slaac_mode],
|
ip_version=constants.IP_VERSION_6,
|
||||||
|
ipv6_subnet_modes=[slaac_mode],
|
||||||
interface_id=interface_id)
|
interface_id=interface_id)
|
||||||
router.process()
|
router.process()
|
||||||
common_utils.wait_until_true(lambda: router.ha_state == 'master')
|
common_utils.wait_until_true(lambda: router.ha_state == 'master')
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from neutron_lib import constants
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from neutron.agent.linux import dhcp
|
from neutron.agent.linux import dhcp
|
||||||
|
@ -53,7 +54,8 @@ class TestDhcp(functional_base.BaseSudoTestCase):
|
||||||
'ipv6_address_mode': None,
|
'ipv6_address_mode': None,
|
||||||
'ipv6_ra_mode': None,
|
'ipv6_ra_mode': None,
|
||||||
'cidr': '10.0.0.0/24',
|
'cidr': '10.0.0.0/24',
|
||||||
'ip_version': 4,
|
'ip_version':
|
||||||
|
constants.IP_VERSION_4,
|
||||||
'gateway_ip': '10.0.0.1'})]}
|
'gateway_ip': '10.0.0.1'})]}
|
||||||
dhcp_port = {
|
dhcp_port = {
|
||||||
'id': 'foo_port_id',
|
'id': 'foo_port_id',
|
||||||
|
|
|
@ -84,7 +84,8 @@ class DHCPAgentOVSTestFramework(base.BaseSudoTestCase):
|
||||||
|
|
||||||
self.conf.set_override('check_child_processes_interval', 1, 'AGENT')
|
self.conf.set_override('check_child_processes_interval', 1, 'AGENT')
|
||||||
|
|
||||||
def network_dict_for_dhcp(self, dhcp_enabled=True, ip_version=4,
|
def network_dict_for_dhcp(self, dhcp_enabled=True,
|
||||||
|
ip_version=lib_const.IP_VERSION_4,
|
||||||
prefix_override=None):
|
prefix_override=None):
|
||||||
net_id = uuidutils.generate_uuid()
|
net_id = uuidutils.generate_uuid()
|
||||||
subnet_dict = self.create_subnet_dict(
|
subnet_dict = self.create_subnet_dict(
|
||||||
|
@ -99,7 +100,8 @@ class DHCPAgentOVSTestFramework(base.BaseSudoTestCase):
|
||||||
net_id, [subnet_dict], [port_dict])
|
net_id, [subnet_dict], [port_dict])
|
||||||
return net_dict
|
return net_dict
|
||||||
|
|
||||||
def create_subnet_dict(self, net_id, dhcp_enabled=True, ip_version=4,
|
def create_subnet_dict(self, net_id, dhcp_enabled=True,
|
||||||
|
ip_version=lib_const.IP_VERSION_4,
|
||||||
prefix_override=None):
|
prefix_override=None):
|
||||||
cidr = self._IP_ADDRS[ip_version]['cidr']
|
cidr = self._IP_ADDRS[ip_version]['cidr']
|
||||||
if prefix_override is not None:
|
if prefix_override is not None:
|
||||||
|
@ -116,12 +118,12 @@ class DHCPAgentOVSTestFramework(base.BaseSudoTestCase):
|
||||||
"host_routes": [],
|
"host_routes": [],
|
||||||
"ipv6_ra_mode": None,
|
"ipv6_ra_mode": None,
|
||||||
"ipv6_address_mode": None})
|
"ipv6_address_mode": None})
|
||||||
if ip_version == 6:
|
if ip_version == lib_const.IP_VERSION_6:
|
||||||
sn_dict['ipv6_address_mode'] = lib_const.DHCPV6_STATEFUL
|
sn_dict['ipv6_address_mode'] = lib_const.DHCPV6_STATEFUL
|
||||||
return sn_dict
|
return sn_dict
|
||||||
|
|
||||||
def create_port_dict(self, network_id, subnet_id, mac_address,
|
def create_port_dict(self, network_id, subnet_id, mac_address,
|
||||||
ip_version=4, ip_address=None):
|
ip_version=lib_const.IP_VERSION_4, ip_address=None):
|
||||||
ip_address = (self._IP_ADDRS[ip_version]['addr']
|
ip_address = (self._IP_ADDRS[ip_version]['addr']
|
||||||
if not ip_address else ip_address)
|
if not ip_address else ip_address)
|
||||||
port_dict = dhcp.DictModel({
|
port_dict = dhcp.DictModel({
|
||||||
|
@ -198,7 +200,7 @@ class DHCPAgentOVSTestFramework(base.BaseSudoTestCase):
|
||||||
|
|
||||||
def _ip_list_for_vif(self, vif_name, namespace):
|
def _ip_list_for_vif(self, vif_name, namespace):
|
||||||
ip_device = ip_lib.IPDevice(vif_name, namespace)
|
ip_device = ip_lib.IPDevice(vif_name, namespace)
|
||||||
return ip_device.addr.list(ip_version=4)
|
return ip_device.addr.list(ip_version=lib_const.IP_VERSION_4)
|
||||||
|
|
||||||
def _get_network_port_for_allocation_test(self):
|
def _get_network_port_for_allocation_test(self):
|
||||||
network = self.network_dict_for_dhcp()
|
network = self.network_dict_for_dhcp()
|
||||||
|
@ -342,7 +344,7 @@ class DHCPAgentOVSTestCase(DHCPAgentOVSTestFramework):
|
||||||
exception=RuntimeError("Stale metadata proxy didn't get killed"))
|
exception=RuntimeError("Stale metadata proxy didn't get killed"))
|
||||||
|
|
||||||
def _test_metadata_proxy_spawn_kill_with_subnet_create_delete(self):
|
def _test_metadata_proxy_spawn_kill_with_subnet_create_delete(self):
|
||||||
network = self.network_dict_for_dhcp(ip_version=6)
|
network = self.network_dict_for_dhcp(ip_version=lib_const.IP_VERSION_6)
|
||||||
self.configure_dhcp_for_network(network=network)
|
self.configure_dhcp_for_network(network=network)
|
||||||
pm = self._get_metadata_proxy_process(network)
|
pm = self._get_metadata_proxy_process(network)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from neutron_lib import constants
|
||||||
from oslo_db.sqlalchemy import utils as db_utils
|
from oslo_db.sqlalchemy import utils as db_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
|
@ -39,7 +40,8 @@ class MigrationToPluggableIpamMixin(object):
|
||||||
allocations = db_utils.get_table(engine, 'ipallocations')
|
allocations = db_utils.get_table(engine, 'ipallocations')
|
||||||
|
|
||||||
for cidr in data:
|
for cidr in data:
|
||||||
ip_version = 6 if ':' in cidr else 4
|
ip_version = (constants.IP_VERSION_6 if ':' in cidr else
|
||||||
|
constants.IP_VERSION_4)
|
||||||
# Save generated id in incoming dict to simplify validations
|
# Save generated id in incoming dict to simplify validations
|
||||||
network_id = uuidutils.generate_uuid()
|
network_id = uuidutils.generate_uuid()
|
||||||
network_dict = dict(
|
network_dict = dict(
|
||||||
|
|
|
@ -89,7 +89,7 @@ class IpamTestCase(testlib_api.SqlTestCase):
|
||||||
'id': self.subnet_id,
|
'id': self.subnet_id,
|
||||||
'name': 'test_sub',
|
'name': 'test_sub',
|
||||||
'network_id': self.network_id,
|
'network_id': self.network_id,
|
||||||
'ip_version': 4,
|
'ip_version': constants.IP_VERSION_4,
|
||||||
'cidr': '10.10.10.0/29',
|
'cidr': '10.10.10.0/29',
|
||||||
'enable_dhcp': False,
|
'enable_dhcp': False,
|
||||||
'gateway_ip': '10.10.10.1',
|
'gateway_ip': '10.10.10.1',
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron_lib.api import extensions as api_extensions
|
from neutron_lib.api import extensions as api_extensions
|
||||||
|
from neutron_lib import constants
|
||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import base
|
from neutron.api.v2 import base
|
||||||
|
@ -86,7 +87,7 @@ def create_subnet(context, plugin, network_id):
|
||||||
{'tenant_id': 'tenid',
|
{'tenant_id': 'tenid',
|
||||||
'network_id': network_id,
|
'network_id': network_id,
|
||||||
'name': 'pecansub',
|
'name': 'pecansub',
|
||||||
'ip_version': 4,
|
'ip_version': constants.IP_VERSION_4,
|
||||||
'cidr': '10.20.30.0/24',
|
'cidr': '10.20.30.0/24',
|
||||||
'gateway_ip': '10.20.30.1',
|
'gateway_ip': '10.20.30.1',
|
||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
|
|
|
@ -605,7 +605,7 @@ class TestDHCPSchedulerWithNetworkAccessibility(
|
||||||
admin_context,
|
admin_context,
|
||||||
{'subnet':
|
{'subnet':
|
||||||
{'name': 'name',
|
{'name': 'name',
|
||||||
'ip_version': 4,
|
'ip_version': constants.IP_VERSION_4,
|
||||||
'network_id': net['id'],
|
'network_id': net['id'],
|
||||||
'cidr': '10.0.0.0/24',
|
'cidr': '10.0.0.0/24',
|
||||||
'gateway_ip': constants.ATTR_NOT_SPECIFIED,
|
'gateway_ip': constants.ATTR_NOT_SPECIFIED,
|
||||||
|
|
|
@ -585,7 +585,7 @@ class L3DVRSchedulerBaseTest(L3SchedulerBaseTest):
|
||||||
'id': sub_id,
|
'id': sub_id,
|
||||||
'name': name,
|
'name': name,
|
||||||
'network_id': network_id,
|
'network_id': network_id,
|
||||||
'ip_version': 4,
|
'ip_version': constants.IP_VERSION_4,
|
||||||
'cidr': cidr,
|
'cidr': cidr,
|
||||||
'enable_dhcp': False,
|
'enable_dhcp': False,
|
||||||
'gateway_ip': gw_ip,
|
'gateway_ip': gw_ip,
|
||||||
|
|
|
@ -302,10 +302,10 @@ class L3DvrHATestCase(test_l3_dvr_router_plugin.L3DvrTestCase):
|
||||||
ext_net = self._make_network(self.fmt, 'ext_net', True, **kwargs)
|
ext_net = self._make_network(self.fmt, 'ext_net', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '2001:db8::1', '2001:db8::/64',
|
self.fmt, ext_net, '2001:db8::1', '2001:db8::/64',
|
||||||
ip_version=6, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_6, enable_dhcp=True)
|
||||||
return ext_net
|
return ext_net
|
||||||
|
|
||||||
def _set_external_gateway(self, router, ext_net):
|
def _set_external_gateway(self, router, ext_net):
|
||||||
|
|
|
@ -611,10 +611,10 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '2001:db8::1', '2001:db8::/64',
|
self.fmt, ext_net, '2001:db8::1', '2001:db8::/64',
|
||||||
ip_version=6, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_6, enable_dhcp=True)
|
||||||
router1 = self._create_router()
|
router1 = self._create_router()
|
||||||
self.l3_plugin._update_router_gw_info(
|
self.l3_plugin._update_router_gw_info(
|
||||||
self.context, router1['id'],
|
self.context, router1['id'],
|
||||||
|
@ -625,12 +625,12 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1 = self._make_network(self.fmt, 'net1', True)
|
private_net1 = self._make_network(self.fmt, 'net1', True)
|
||||||
private_ipv6_subnet1 = self._make_subnet(self.fmt,
|
private_ipv6_subnet1 = self._make_subnet(self.fmt,
|
||||||
private_net1, 'fd00::1',
|
private_net1, 'fd00::1',
|
||||||
cidr='fd00::1/64', ip_version=6,
|
cidr='fd00::1/64', ip_version=constants.IP_VERSION_6,
|
||||||
ipv6_ra_mode='slaac',
|
ipv6_ra_mode='slaac',
|
||||||
ipv6_address_mode='slaac')
|
ipv6_address_mode='slaac')
|
||||||
private_ipv6_subnet2 = self._make_subnet(self.fmt,
|
private_ipv6_subnet2 = self._make_subnet(self.fmt,
|
||||||
private_net1, 'fd01::1',
|
private_net1, 'fd01::1',
|
||||||
cidr='fd01::1/64', ip_version=6,
|
cidr='fd01::1/64', ip_version=constants.IP_VERSION_6,
|
||||||
ipv6_ra_mode='slaac',
|
ipv6_ra_mode='slaac',
|
||||||
ipv6_address_mode='slaac')
|
ipv6_address_mode='slaac')
|
||||||
# Add the first IPv6 subnet to the router
|
# Add the first IPv6 subnet to the router
|
||||||
|
@ -682,7 +682,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -696,7 +696,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
allocation_pools=test_allocation_pools,
|
allocation_pools=test_allocation_pools,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
vrrp_port = self._make_port(
|
vrrp_port = self._make_port(
|
||||||
|
@ -789,7 +789,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
# Schedule the router to the dvr_snat node
|
# Schedule the router to the dvr_snat node
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
|
@ -804,7 +804,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_subnet1,
|
subnet=private_subnet1,
|
||||||
|
@ -870,7 +870,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -884,7 +884,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_subnet1,
|
subnet=private_subnet1,
|
||||||
|
@ -945,7 +945,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -959,7 +959,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
with self.port(
|
with self.port(
|
||||||
subnet=private_subnet1,
|
subnet=private_subnet1,
|
||||||
|
@ -1027,7 +1027,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -1041,7 +1041,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
allocation_pools=test_allocation_pools,
|
allocation_pools=test_allocation_pools,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
vrrp_port = self._make_port(
|
vrrp_port = self._make_port(
|
||||||
|
@ -1157,7 +1157,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -1170,7 +1170,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
self.l3_plugin.add_router_interface(
|
self.l3_plugin.add_router_interface(
|
||||||
self.context, router['id'],
|
self.context, router['id'],
|
||||||
|
@ -1197,7 +1197,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||||
self._make_subnet(
|
self._make_subnet(
|
||||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||||
ip_version=4, enable_dhcp=True)
|
ip_version=constants.IP_VERSION_4, enable_dhcp=True)
|
||||||
self.l3_plugin.schedule_router(self.context,
|
self.l3_plugin.schedule_router(self.context,
|
||||||
router['id'],
|
router['id'],
|
||||||
candidates=[self.l3_agent])
|
candidates=[self.l3_agent])
|
||||||
|
@ -1210,7 +1210,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||||
private_net1,
|
private_net1,
|
||||||
'10.1.0.1',
|
'10.1.0.1',
|
||||||
cidr='10.1.0.0/24',
|
cidr='10.1.0.0/24',
|
||||||
ip_version=4,
|
ip_version=constants.IP_VERSION_4,
|
||||||
allocation_pools=test_allocation_pools,
|
allocation_pools=test_allocation_pools,
|
||||||
enable_dhcp=True)
|
enable_dhcp=True)
|
||||||
vrrp_port = self._make_port(
|
vrrp_port = self._make_port(
|
||||||
|
|
Loading…
Reference in New Issue