Use constant IP_VERSION_4/6 in unit tests
Change-Id: I54bec2c06940b0b1362fecacef7860361d081601changes/84/533284/8
parent
60463d65c4
commit
12bb26fd0e
|
@ -56,7 +56,8 @@ fake_subnet1 = dhcp.DictModel(dict(id='bbbbbbbb-bbbb-bbbb-bbbbbbbbbbbb',
|
|||
cidr='172.9.9.0/24', enable_dhcp=True, name='',
|
||||
tenant_id=FAKE_TENANT_ID,
|
||||
gateway_ip='172.9.9.1', host_routes=[],
|
||||
dns_nameservers=[], ip_version=4,
|
||||
dns_nameservers=[],
|
||||
ip_version=const.IP_VERSION_4,
|
||||
ipv6_ra_mode=None, ipv6_address_mode=None,
|
||||
allocation_pools=fake_subnet1_allocation_pools))
|
||||
|
||||
|
@ -66,26 +67,29 @@ fake_subnet2 = dhcp.DictModel(dict(id='dddddddd-dddd-dddd-dddddddddddd',
|
|||
network_id=FAKE_NETWORK_UUID,
|
||||
cidr='172.9.8.0/24', enable_dhcp=False, name='',
|
||||
tenant_id=FAKE_TENANT_ID, gateway_ip='172.9.8.1',
|
||||
host_routes=[], dns_nameservers=[], ip_version=4,
|
||||
host_routes=[], dns_nameservers=[],
|
||||
ip_version=const.IP_VERSION_4,
|
||||
allocation_pools=fake_subnet2_allocation_pools))
|
||||
|
||||
fake_subnet3 = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
|
||||
network_id=FAKE_NETWORK_UUID,
|
||||
cidr='192.168.1.1/24', enable_dhcp=True,
|
||||
ip_version=4))
|
||||
ip_version=const.IP_VERSION_4))
|
||||
|
||||
fake_ipv6_subnet = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
|
||||
network_id=FAKE_NETWORK_UUID,
|
||||
cidr='2001:0db8::0/64', enable_dhcp=True,
|
||||
tenant_id=FAKE_TENANT_ID,
|
||||
gateway_ip='2001:0db8::1', ip_version=6,
|
||||
gateway_ip='2001:0db8::1',
|
||||
ip_version=const.IP_VERSION_6,
|
||||
ipv6_ra_mode='slaac', ipv6_address_mode=None))
|
||||
|
||||
fake_meta_subnet = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
|
||||
network_id=FAKE_NETWORK_UUID,
|
||||
cidr='169.254.169.252/30',
|
||||
gateway_ip='169.254.169.253',
|
||||
enable_dhcp=True, ip_version=4))
|
||||
enable_dhcp=True,
|
||||
ip_version=const.IP_VERSION_4))
|
||||
|
||||
fake_fixed_ip1 = dhcp.DictModel(dict(id='', subnet_id=fake_subnet1.id,
|
||||
ip_address='172.9.9.9'))
|
||||
|
@ -946,7 +950,7 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
|
|||
def test_subnet_create_restarts_with_dhcp_disabled(self):
|
||||
payload = dict(subnet=dhcp.DictModel(
|
||||
dict(network_id=fake_network.id, enable_dhcp=False,
|
||||
cidr='99.99.99.0/24', ip_version=4)))
|
||||
cidr='99.99.99.0/24', ip_version=const.IP_VERSION_4)))
|
||||
self.cache.get_network_by_id.return_value = fake_network
|
||||
new_net = copy.deepcopy(fake_network)
|
||||
new_net.subnets.append(payload['subnet'])
|
||||
|
@ -1389,7 +1393,7 @@ class FakePort2(object):
|
|||
class FakeV4Subnet(object):
|
||||
def __init__(self):
|
||||
self.id = 'dddddddd-dddd-dddd-dddd-dddddddddddd'
|
||||
self.ip_version = 4
|
||||
self.ip_version = const.IP_VERSION_4
|
||||
self.cidr = '192.168.0.0/24'
|
||||
self.gateway_ip = '192.168.0.1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -1398,7 +1402,7 @@ class FakeV4Subnet(object):
|
|||
class FakeV6Subnet(object):
|
||||
def __init__(self):
|
||||
self.id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
||||
self.ip_version = 6
|
||||
self.ip_version = const.IP_VERSION_6
|
||||
self.cidr = '2001:db8:0:1::/64'
|
||||
self.gateway_ip = '2001:db8:0:1::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -1419,7 +1423,7 @@ class FakeV6SubnetOutsideGateway(FakeV6Subnet):
|
|||
class FakeV4SubnetNoGateway(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 4
|
||||
self.ip_version = const.IP_VERSION_4
|
||||
self.cidr = '192.168.1.0/24'
|
||||
self.gateway_ip = None
|
||||
self.enable_dhcp = True
|
||||
|
@ -1428,7 +1432,7 @@ class FakeV4SubnetNoGateway(object):
|
|||
class FakeV6SubnetNoGateway(object):
|
||||
def __init__(self):
|
||||
self.id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
||||
self.ip_version = 6
|
||||
self.ip_version = const.IP_VERSION_6
|
||||
self.cidr = '2001:db8:1:0::/64'
|
||||
self.gateway_ip = None
|
||||
self.enable_dhcp = True
|
||||
|
|
|
@ -990,9 +990,9 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
|
||||
@mock.patch.object(dvr_router_base.LOG, 'error')
|
||||
def test_get_snat_port_for_internal_port_ipv6_same_port(self, log_error):
|
||||
router = l3_test_common.prepare_router_data(ip_version=4,
|
||||
enable_snat=True,
|
||||
num_internal_ports=1)
|
||||
router = l3_test_common.prepare_router_data(
|
||||
ip_version=lib_constants.IP_VERSION_4, enable_snat=True,
|
||||
num_internal_ports=1)
|
||||
ri = dvr_router.DvrEdgeRouter(mock.sentinel.agent,
|
||||
HOSTNAME,
|
||||
router['id'],
|
||||
|
@ -1000,8 +1000,9 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
**self.ri_kwargs)
|
||||
|
||||
# Add two additional IPv6 prefixes on the same interface
|
||||
l3_test_common.router_append_interface(router, count=2, ip_version=6,
|
||||
same_port=True)
|
||||
l3_test_common.router_append_interface(
|
||||
router, count=2, ip_version=lib_constants.IP_VERSION_6,
|
||||
same_port=True)
|
||||
internal_ports = ri.router.get(lib_constants.INTERFACE_KEY, [])
|
||||
with mock.patch.object(ri, 'get_snat_interfaces') as get_interfaces:
|
||||
get_interfaces.return_value = internal_ports
|
||||
|
@ -1613,8 +1614,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
|
||||
def _test_process_ipv6_only_or_dual_stack_gw(self, dual_stack=False):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
router = l3_test_common.prepare_router_data(ip_version=6,
|
||||
dual_stack=dual_stack)
|
||||
router = l3_test_common.prepare_router_data(
|
||||
ip_version=lib_constants.IP_VERSION_6, dual_stack=dual_stack)
|
||||
# Get NAT rules without the gw_port
|
||||
gw_port = router['gw_port']
|
||||
router['gw_port'] = None
|
||||
|
@ -1668,9 +1669,9 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
ri.process()
|
||||
orig_nat_rules = ri.iptables_manager.ipv4['nat'].rules[:]
|
||||
# Add an IPv6 interface and reprocess
|
||||
l3_test_common.router_append_interface(router, count=1,
|
||||
ip_version=6, ra_mode=ra_mode,
|
||||
addr_mode=addr_mode)
|
||||
l3_test_common.router_append_interface(
|
||||
router, count=1, ip_version=lib_constants.IP_VERSION_6,
|
||||
ra_mode=ra_mode, addr_mode=addr_mode)
|
||||
# Reassign the router object to RouterInfo
|
||||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
# IPv4 NAT rules should not be changed by adding an IPv6 interface
|
||||
|
@ -1703,7 +1704,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
l3_test_common.router_append_subnet(
|
||||
router,
|
||||
count=len(ipv6_subnet_modes),
|
||||
ip_version=6,
|
||||
ip_version=lib_constants.IP_VERSION_6,
|
||||
ipv6_subnet_modes=ipv6_subnet_modes,
|
||||
dns_nameservers=dns_nameservers,
|
||||
network_mtu=network_mtu)
|
||||
|
@ -1775,7 +1776,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
# Add the first subnet on a new interface
|
||||
l3_test_common.router_append_subnet(
|
||||
router, count=1,
|
||||
ip_version=6, ipv6_subnet_modes=[
|
||||
ip_version=lib_constants.IP_VERSION_6, ipv6_subnet_modes=[
|
||||
{'ra_mode': lib_constants.IPV6_SLAAC,
|
||||
'address_mode': lib_constants.IPV6_SLAAC}])
|
||||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
|
@ -1793,7 +1794,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
interface_id = router[lib_constants.INTERFACE_KEY][1]['id']
|
||||
l3_test_common.router_append_subnet(
|
||||
router, count=1,
|
||||
ip_version=6,
|
||||
ip_version=lib_constants.IP_VERSION_6,
|
||||
ipv6_subnet_modes=[
|
||||
{'ra_mode': lib_constants.IPV6_SLAAC,
|
||||
'address_mode': lib_constants.IPV6_SLAAC}],
|
||||
|
@ -1816,8 +1817,10 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
# Process with NAT
|
||||
ri.process()
|
||||
# Add an IPv4 and IPv6 interface and reprocess
|
||||
l3_test_common.router_append_interface(router, count=1, ip_version=4)
|
||||
l3_test_common.router_append_interface(router, count=1, ip_version=6)
|
||||
l3_test_common.router_append_interface(
|
||||
router, count=1, ip_version=lib_constants.IP_VERSION_4)
|
||||
l3_test_common.router_append_interface(
|
||||
router, count=1, ip_version=lib_constants.IP_VERSION_6)
|
||||
# Reassign the router object to RouterInfo
|
||||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
self._assert_ri_process_enabled(ri)
|
||||
|
@ -1844,7 +1847,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
ri.external_gateway_added = mock.Mock()
|
||||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
# Add an IPv6 interface and reprocess
|
||||
l3_test_common.router_append_interface(router, count=1, ip_version=6)
|
||||
l3_test_common.router_append_interface(
|
||||
router, count=1, ip_version=lib_constants.IP_VERSION_6)
|
||||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
self._assert_ri_process_enabled(ri)
|
||||
# Reset the calls so we can check for disable radvd
|
||||
|
@ -1863,7 +1867,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
self._process_router_instance_for_agent(agent, ri, router)
|
||||
# Add an IPv6 interface with two subnets and reprocess
|
||||
l3_test_common.router_append_subnet(
|
||||
router, count=2, ip_version=6,
|
||||
router, count=2, ip_version=lib_constants.IP_VERSION_6,
|
||||
ipv6_subnet_modes=([{'ra_mode': lib_constants.IPV6_SLAAC,
|
||||
'address_mode': lib_constants.IPV6_SLAAC}] *
|
||||
2))
|
||||
|
@ -2795,7 +2799,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
@mock.patch('os.geteuid', return_value='490')
|
||||
@mock.patch('pwd.getpwuid', return_value=FakeUser('neutron'))
|
||||
def test_spawn_radvd(self, geteuid, getpwuid):
|
||||
router = l3_test_common.prepare_router_data(ip_version=6)
|
||||
router = l3_test_common.prepare_router_data(
|
||||
ip_version=lib_constants.IP_VERSION_6)
|
||||
|
||||
conffile = '/fake/radvd.conf'
|
||||
pidfile = '/fake/radvd.pid'
|
||||
|
|
|
@ -53,7 +53,7 @@ class FakeDNSAssignment(object):
|
|||
|
||||
class DhcpOpt(object):
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(ip_version=4)
|
||||
self.__dict__.update(ip_version=constants.IP_VERSION_4)
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -188,10 +188,10 @@ class FakePort6(object):
|
|||
self.extra_dhcp_opts = [
|
||||
DhcpOpt(opt_name=edo_ext.DHCP_OPT_CLIENT_ID,
|
||||
opt_value='test6',
|
||||
ip_version=4),
|
||||
ip_version=constants.IP_VERSION_4),
|
||||
DhcpOpt(opt_name='dns-server',
|
||||
opt_value='123.123.123.45',
|
||||
ip_version=4)]
|
||||
ip_version=constants.IP_VERSION_4)]
|
||||
|
||||
|
||||
class FakeV6Port(object):
|
||||
|
@ -224,7 +224,7 @@ class FakeV6PortExtraOpt(object):
|
|||
self.extra_dhcp_opts = [
|
||||
DhcpOpt(opt_name='dns-server',
|
||||
opt_value='ffea:3ba5:a17a:4ba3::100',
|
||||
ip_version=6)]
|
||||
ip_version=constants.IP_VERSION_6)]
|
||||
|
||||
|
||||
class FakeDualPortWithV6ExtraOpt(object):
|
||||
|
@ -245,7 +245,7 @@ class FakeDualPortWithV6ExtraOpt(object):
|
|||
self.extra_dhcp_opts = [
|
||||
DhcpOpt(opt_name='dns-server',
|
||||
opt_value='ffea:3ba5:a17a:4ba3::100',
|
||||
ip_version=6)]
|
||||
ip_version=constants.IP_VERSION_6)]
|
||||
|
||||
|
||||
class FakeDualPort(object):
|
||||
|
@ -391,7 +391,7 @@ class FakeV6HostRoute(object):
|
|||
class FakeV4Subnet(Dictable):
|
||||
def __init__(self):
|
||||
self.id = 'dddddddd-dddd-dddd-dddd-dddddddddddd'
|
||||
self.ip_version = 4
|
||||
self.ip_version = constants.IP_VERSION_4
|
||||
self.cidr = '192.168.0.0/24'
|
||||
self.gateway_ip = '192.168.0.1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -522,7 +522,7 @@ class FakeV4MultipleAgentsWithDnsProvided(FakeNetworkBase):
|
|||
class FakeV6Subnet(object):
|
||||
def __init__(self):
|
||||
self.id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'fdca:3ba5:a17a:4ba3::/64'
|
||||
self.gateway_ip = 'fdca:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -535,7 +535,7 @@ class FakeV6Subnet(object):
|
|||
class FakeV4SubnetNoDHCP(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 4
|
||||
self.ip_version = constants.IP_VERSION_4
|
||||
self.cidr = '192.168.1.0/24'
|
||||
self.gateway_ip = '192.168.1.1'
|
||||
self.enable_dhcp = False
|
||||
|
@ -546,7 +546,7 @@ class FakeV4SubnetNoDHCP(object):
|
|||
class FakeV6SubnetDHCPStateful(Dictable):
|
||||
def __init__(self):
|
||||
self.id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'fdca:3ba5:a17a:4ba3::/64'
|
||||
self.gateway_ip = 'fdca:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -559,7 +559,7 @@ class FakeV6SubnetDHCPStateful(Dictable):
|
|||
class FakeV6SubnetSlaac(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'ffda:3ba5:a17a:4ba3::/64'
|
||||
self.gateway_ip = 'ffda:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -571,7 +571,7 @@ class FakeV6SubnetSlaac(object):
|
|||
class FakeV6SubnetStateless(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'ffea:3ba5:a17a:4ba3::/64'
|
||||
self.gateway_ip = 'ffea:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -584,7 +584,7 @@ class FakeV6SubnetStateless(object):
|
|||
class FakeV6SubnetStatelessNoDnsProvided(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'ffea:3ba5:a17a:4ba3::/64'
|
||||
self.gateway_ip = 'ffea:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -597,7 +597,7 @@ class FakeV6SubnetStatelessNoDnsProvided(object):
|
|||
class FakeV6SubnetStatelessBadPrefixLength(object):
|
||||
def __init__(self):
|
||||
self.id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = 'ffeb:3ba5:a17a:4ba3::/56'
|
||||
self.gateway_ip = 'ffeb:3ba5:a17a:4ba3::1'
|
||||
self.enable_dhcp = True
|
||||
|
@ -909,9 +909,9 @@ class FakeV6NetworkPxePort(FakeNetworkBase):
|
|||
self.namespace = 'qdhcp-ns'
|
||||
self.ports[0].extra_dhcp_opts = [
|
||||
DhcpOpt(opt_name='tftp-server', opt_value='2001:192:168::1',
|
||||
ip_version=6),
|
||||
ip_version=constants.IP_VERSION_6),
|
||||
DhcpOpt(opt_name='bootfile-name', opt_value='pxelinux.0',
|
||||
ip_version=6)]
|
||||
ip_version=constants.IP_VERSION_6)]
|
||||
|
||||
|
||||
class FakeV6NetworkPxePortWrongOptVersion(FakeNetworkBase):
|
||||
|
@ -922,9 +922,9 @@ class FakeV6NetworkPxePortWrongOptVersion(FakeNetworkBase):
|
|||
self.namespace = 'qdhcp-ns'
|
||||
self.ports[0].extra_dhcp_opts = [
|
||||
DhcpOpt(opt_name='tftp-server', opt_value='192.168.0.7',
|
||||
ip_version=4),
|
||||
ip_version=constants.IP_VERSION_4),
|
||||
DhcpOpt(opt_name='bootfile-name', opt_value='pxelinux.0',
|
||||
ip_version=6)]
|
||||
ip_version=constants.IP_VERSION_6)]
|
||||
|
||||
|
||||
class FakeDualStackNetworkSingleDHCP(FakeNetworkBase):
|
||||
|
@ -1257,9 +1257,9 @@ class TestDnsmasq(TestBase):
|
|||
prefix6 = '--dhcp-range=set:tag%d,%s,%s,%s%s'
|
||||
possible_leases = 0
|
||||
for i, s in enumerate(network.subnets):
|
||||
if (s.ip_version != 6 or
|
||||
if (s.ip_version != constants.IP_VERSION_6 or
|
||||
s.ipv6_address_mode == constants.DHCPV6_STATEFUL):
|
||||
if s.ip_version == 4:
|
||||
if s.ip_version == constants.IP_VERSION_4:
|
||||
expected.extend([prefix % (
|
||||
i, s.cidr.split('/')[0],
|
||||
netaddr.IPNetwork(s.cidr).netmask, lease_duration,
|
||||
|
|
|
@ -42,7 +42,7 @@ class FakeSubnet(object):
|
|||
class FakeAllocation(object):
|
||||
subnet = FakeSubnet()
|
||||
ip_address = '192.168.1.2'
|
||||
ip_version = 4
|
||||
ip_version = constants.IP_VERSION_4
|
||||
|
||||
|
||||
class FakePort(object):
|
||||
|
@ -177,9 +177,9 @@ class TestABCDriver(TestBase):
|
|||
self.ip_dev.assert_has_calls(expected_calls)
|
||||
|
||||
def test_init_router_port_ext_gw_with_dual_stack(self):
|
||||
old_addrs = [dict(ip_version=4, scope='global',
|
||||
old_addrs = [dict(ip_version=constants.IP_VERSION_4, scope='global',
|
||||
dynamic=False, cidr='172.16.77.240/24'),
|
||||
dict(ip_version=6, scope='global',
|
||||
dict(ip_version=constants.IP_VERSION_6, scope='global',
|
||||
dynamic=False, cidr='2001:db8:a::123/64')]
|
||||
self.ip_dev().addr.list = mock.Mock(return_value=old_addrs)
|
||||
self.ip_dev().route.list_onlink_routes.return_value = []
|
||||
|
@ -359,7 +359,8 @@ class TestABCDriver(TestBase):
|
|||
self.assertEqual(addresses, llas)
|
||||
self.ip_dev.assert_has_calls(
|
||||
[mock.call(device_name, namespace=ns),
|
||||
mock.call().addr.list(scope='link', ip_version=6)])
|
||||
mock.call().addr.list(
|
||||
scope='link', ip_version=constants.IP_VERSION_6)])
|
||||
|
||||
def test_set_mtu_logs_once(self):
|
||||
bc = BaseChild(self.conf)
|
||||
|
|
|
@ -18,6 +18,7 @@ import socket
|
|||
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
import pyroute2
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
|
@ -969,7 +970,7 @@ class TestIpRouteCommand(TestIPCmdBase):
|
|||
self.parent.name = 'eth0'
|
||||
self.command = 'route'
|
||||
self.route_cmd = ip_lib.IpRouteCommand(self.parent)
|
||||
self.ip_version = 4
|
||||
self.ip_version = constants.IP_VERSION_4
|
||||
self.table = 14
|
||||
self.metric = 100
|
||||
self.cidr = '192.168.45.100/24'
|
||||
|
@ -1159,7 +1160,7 @@ class TestIpRouteCommand(TestIPCmdBase):
|
|||
class TestIPv6IpRouteCommand(TestIpRouteCommand):
|
||||
def setUp(self):
|
||||
super(TestIPv6IpRouteCommand, self).setUp()
|
||||
self.ip_version = 6
|
||||
self.ip_version = constants.IP_VERSION_6
|
||||
self.cidr = '2001:db8::/64'
|
||||
self.ip = '2001:db8::100'
|
||||
self.gateway = '2001:db8::1'
|
||||
|
|
|
@ -538,7 +538,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase):
|
|||
fake_gateway = FAKE_IP[const.IPv6]
|
||||
with self.network() as n,\
|
||||
self.subnet(n, gateway_ip=fake_gateway,
|
||||
cidr=fake_prefix, ip_version=6
|
||||
cidr=fake_prefix, ip_version=const.IP_VERSION_6
|
||||
) as subnet_v6,\
|
||||
self.security_group() as sg1:
|
||||
sg1_id = sg1['security_group']['id']
|
||||
|
@ -651,7 +651,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase):
|
|||
fake_gateway = FAKE_IP[const.IPv6]
|
||||
with self.network() as n,\
|
||||
self.subnet(n, gateway_ip=fake_gateway,
|
||||
cidr=fake_prefix, ip_version=6
|
||||
cidr=fake_prefix, ip_version=const.IP_VERSION_6
|
||||
) as subnet_v6,\
|
||||
self.security_group() as sg1:
|
||||
sg1_id = sg1['security_group']['id']
|
||||
|
@ -709,7 +709,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase):
|
|||
fake_gateway = FAKE_IP[const.IPv6]
|
||||
with self.network() as n,\
|
||||
self.subnet(n, gateway_ip=fake_gateway,
|
||||
cidr=fake_prefix, ip_version=6
|
||||
cidr=fake_prefix, ip_version=const.IP_VERSION_6
|
||||
) as subnet_v6,\
|
||||
self.security_group() as sg1,\
|
||||
self.security_group() as sg2:
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestL3RpcCallback(testlib_api.SqlTestCase):
|
|||
subnet = {'subnet': {'network_id': self.network['id'],
|
||||
'tenant_id': 'tenant_id',
|
||||
'cidr': None,
|
||||
'ip_version': 6,
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'use_default_subnetpool': True,
|
||||
'name': 'ipv6_pd',
|
||||
'enable_dhcp': True,
|
||||
|
|
|
@ -67,7 +67,7 @@ class TestIsAutoAddressSubnet(base.BaseTestCase):
|
|||
self.subnet = {
|
||||
'cidr': '2001:200::/64',
|
||||
'gateway_ip': '2001:200::1',
|
||||
'ip_version': 6,
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'ipv6_address_mode': None,
|
||||
'ipv6_ra_mode': None
|
||||
}
|
||||
|
|
|
@ -270,11 +270,11 @@ class TestCidrIsHost(base.BaseTestCase):
|
|||
class TestIpVersionFromInt(base.BaseTestCase):
|
||||
def test_ip_version_from_int_ipv4(self):
|
||||
self.assertEqual(constants.IPv4,
|
||||
utils.ip_version_from_int(4))
|
||||
utils.ip_version_from_int(constants.IP_VERSION_4))
|
||||
|
||||
def test_ip_version_from_int_ipv6(self):
|
||||
self.assertEqual(constants.IPv6,
|
||||
utils.ip_version_from_int(6))
|
||||
utils.ip_version_from_int(constants.IP_VERSION_6))
|
||||
|
||||
def test_ip_version_from_int_illegal_int(self):
|
||||
self.assertRaises(ValueError,
|
||||
|
|
|
@ -334,7 +334,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
def _create_subnet(self, fmt, net_id, cidr,
|
||||
expected_res_status=None, **kwargs):
|
||||
data = {'subnet': {'network_id': net_id,
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': self._tenant_id}}
|
||||
if cidr:
|
||||
data['subnet']['cidr'] = cidr
|
||||
|
@ -363,7 +363,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
return subnet_res
|
||||
|
||||
def _create_subnet_bulk(self, fmt, number, net_id, name,
|
||||
ip_version=4, **kwargs):
|
||||
ip_version=constants.IP_VERSION_4, **kwargs):
|
||||
base_data = {'subnet': {'network_id': net_id,
|
||||
'ip_version': ip_version,
|
||||
'tenant_id': self._tenant_id}}
|
||||
|
@ -462,9 +462,9 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
return self.deserialize(fmt, res)
|
||||
|
||||
def _make_subnet(self, fmt, network, gateway, cidr, subnetpool_id=None,
|
||||
allocation_pools=None, ip_version=4, enable_dhcp=True,
|
||||
dns_nameservers=None, host_routes=None, shared=None,
|
||||
ipv6_ra_mode=None, ipv6_address_mode=None,
|
||||
allocation_pools=None, ip_version=constants.IP_VERSION_4,
|
||||
enable_dhcp=True, dns_nameservers=None, host_routes=None,
|
||||
shared=None, ipv6_ra_mode=None, ipv6_address_mode=None,
|
||||
tenant_id=None, set_context=False, segment_id=None):
|
||||
res = self._create_subnet(fmt,
|
||||
net_id=network['network']['id'],
|
||||
|
@ -500,7 +500,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
cfg.CONF.set_override('ipv6_pd_enabled', True)
|
||||
return (self._make_subnet(self.fmt, network, gateway=gateway,
|
||||
subnetpool_id=subnetpool_id,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=ra_addr_mode,
|
||||
ipv6_address_mode=ra_addr_mode))
|
||||
|
||||
|
@ -629,7 +629,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
subnetpool_id=None,
|
||||
segment_id=None,
|
||||
fmt=None,
|
||||
ip_version=4,
|
||||
ip_version=constants.IP_VERSION_4,
|
||||
allocation_pools=None,
|
||||
enable_dhcp=True,
|
||||
dns_nameservers=None,
|
||||
|
@ -1459,7 +1459,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
with self.subnet(network=n,
|
||||
gateway_ip='fe80::1',
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC) as subnet:
|
||||
self.assertTrue(
|
||||
ipv6_utils.is_auto_address_subnet(subnet['subnet']))
|
||||
|
@ -1729,7 +1729,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
def test_update_port_invalid_fixed_ip_address_v6_slaac(self):
|
||||
with self.subnet(
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC,
|
||||
gateway_ip=constants.ATTR_NOT_SPECIFIED) as subnet:
|
||||
with self.port(subnet=subnet) as port:
|
||||
|
@ -1857,7 +1857,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
admin_state_up=True)
|
||||
network2 = self.deserialize(self.fmt, res)
|
||||
subnet2 = self._make_subnet(self.fmt, network2, "1.1.1.1",
|
||||
"1.1.1.0/24", ip_version=4)
|
||||
"1.1.1.0/24",
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
net_id = port['port']['network_id']
|
||||
# Request a IP from specific subnet
|
||||
kwargs = {"fixed_ips": [{'subnet_id':
|
||||
|
@ -1875,7 +1876,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
tenant_id=tenant_id,
|
||||
net_id=net_id,
|
||||
cidr='10.0.0.225/28',
|
||||
ip_version=4,
|
||||
ip_version=constants.IP_VERSION_4,
|
||||
gateway_ip=constants.ATTR_NOT_SPECIFIED)
|
||||
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
|
||||
|
||||
|
@ -1889,7 +1890,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
tenant_id=tenant_id,
|
||||
net_id=net_id,
|
||||
cidr='2607:f0d0:1002:51::/124',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
gateway_ip=constants.ATTR_NOT_SPECIFIED)
|
||||
subnet2 = self.deserialize(self.fmt, res)
|
||||
kwargs = {"fixed_ips":
|
||||
|
@ -1997,7 +1998,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
admin_state_up=True)
|
||||
network2 = self.deserialize(self.fmt, res)
|
||||
self._make_subnet(self.fmt, network2, "1.1.1.1",
|
||||
"1.1.1.0/24", ip_version=4)
|
||||
"1.1.1.0/24", ip_version=constants.IP_VERSION_4)
|
||||
res = self._create_port(self.fmt, net_id=network2['network']['id'])
|
||||
port = self.deserialize(self.fmt, res)
|
||||
|
||||
|
@ -2011,7 +2012,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
def test_requested_invalid_fixed_ip_address_v6_slaac(self):
|
||||
with self.subnet(gateway_ip='fe80::1',
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC) as subnet:
|
||||
kwargs = {"fixed_ips": [{'subnet_id': subnet['subnet']['id'],
|
||||
'ip_address': '2607:f0d0:1002:51::5'}]}
|
||||
|
@ -2023,7 +2024,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
def test_requested_fixed_ip_address_v6_slaac_router_iface(self):
|
||||
with self.subnet(gateway_ip='fe80::1',
|
||||
cidr='fe80::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC) as subnet:
|
||||
kwargs = {"fixed_ips": [{'subnet_id': subnet['subnet']['id'],
|
||||
'ip_address': 'fe80::1'}]}
|
||||
|
@ -2039,7 +2040,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
def test_requested_subnet_id_v6_slaac(self):
|
||||
with self.subnet(gateway_ip='fe80::1',
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC) as subnet:
|
||||
with self.port(subnet,
|
||||
fixed_ips=[{'subnet_id':
|
||||
|
@ -2057,7 +2058,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
self.subnet(
|
||||
network,
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
gateway_ip='fe80::1',
|
||||
ipv6_address_mode=constants.IPV6_SLAAC) as subnet2:
|
||||
with self.port(
|
||||
|
@ -2086,7 +2087,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
with self.subnet(network) as subnet_v4,\
|
||||
self.subnet(network,
|
||||
cidr='2607:f0d0:1002:51::/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
gateway_ip='fe80::1',
|
||||
ipv6_address_mode=constants.IPV6_SLAAC):
|
||||
subnet_ip_net = netaddr.IPNetwork(subnet_v4['subnet']['cidr'])
|
||||
|
@ -2152,17 +2153,21 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
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},
|
||||
'ip_version': constants.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},
|
||||
'ip_version': constants.IP_VERSION_4, 'ra_addr_mode': None},
|
||||
{'gateway': 'fe80::1', 'cidr': 'fe80::/64',
|
||||
'ip_version': 6, 'ra_addr_mode': constants.IPV6_SLAAC},
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'ra_addr_mode': constants.IPV6_SLAAC},
|
||||
{'gateway': 'fe81::1', 'cidr': 'fe81::/64',
|
||||
'ip_version': 6, 'ra_addr_mode': constants.IPV6_SLAAC},
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'ra_addr_mode': constants.IPV6_SLAAC},
|
||||
{'gateway': 'fe82::1', 'cidr': 'fe82::/64',
|
||||
'ip_version': 6, 'ra_addr_mode': constants.DHCPV6_STATEFUL},
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'ra_addr_mode': constants.DHCPV6_STATEFUL},
|
||||
{'gateway': 'fe83::1', 'cidr': 'fe83::/64',
|
||||
'ip_version': 6, 'ra_addr_mode': constants.DHCPV6_STATEFUL}]
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'ra_addr_mode': constants.DHCPV6_STATEFUL}]
|
||||
subnets = {}
|
||||
for sub_dict in sub_dicts:
|
||||
subnet = self._make_subnet(
|
||||
|
@ -2212,7 +2217,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
network = self.deserialize(self.fmt, res)
|
||||
# Create a port using an IPv4 subnet and an IPv6 SLAAC subnet
|
||||
self._make_subnet(self.fmt, network, gateway='10.0.0.1',
|
||||
cidr='10.0.0.0/24', ip_version=4)
|
||||
cidr='10.0.0.0/24',
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
subnet_v6 = self._make_v6_subnet(network, constants.IPV6_SLAAC)
|
||||
res = self._create_port(self.fmt, net_id=network['network']['id'])
|
||||
port = self.deserialize(self.fmt, res)
|
||||
|
@ -2236,7 +2242,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
network = self.deserialize(self.fmt, res)
|
||||
# Create a port using an IPv4 subnet and an IPv6 SLAAC subnet
|
||||
subnet_v4 = self._make_subnet(self.fmt, network, gateway='10.0.0.1',
|
||||
cidr='10.0.0.0/24', ip_version=4)
|
||||
cidr='10.0.0.0/24',
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
subnet_v6 = self._make_v6_subnet(network, constants.IPV6_SLAAC)
|
||||
res = self._create_port(self.fmt, net_id=network['network']['id'])
|
||||
port = self.deserialize(self.fmt, res)
|
||||
|
@ -2274,7 +2281,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
network = self.deserialize(self.fmt, res)
|
||||
# Create a port using an IPv4 subnet and an IPv6 SLAAC subnet
|
||||
subnet_v4 = self._make_subnet(self.fmt, network, gateway='10.0.0.1',
|
||||
cidr='10.0.0.0/24', ip_version=4)
|
||||
cidr='10.0.0.0/24',
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
subnet_v6 = self._make_v6_subnet(network, constants.IPV6_SLAAC)
|
||||
res = self._create_port(self.fmt, net_id=network['network']['id'])
|
||||
port = self.deserialize(self.fmt, res)
|
||||
|
@ -2301,12 +2309,12 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
v6_subnet_1 = self._make_subnet(self.fmt, network,
|
||||
gateway='2001:100::1',
|
||||
cidr='2001:100::0/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.IPV6_SLAAC)
|
||||
v6_subnet_2 = self._make_subnet(self.fmt, network,
|
||||
gateway='2001:200::1',
|
||||
cidr='2001:200::0/64',
|
||||
ip_version=6,
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.IPV6_SLAAC)
|
||||
port = self._make_port(self.fmt, network['network']['id'])
|
||||
port_mac = port['port']['mac_address']
|
||||
|
@ -3112,7 +3120,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
def _test_create_subnet(self, network=None, expected=None, **kwargs):
|
||||
keys = kwargs.copy()
|
||||
keys.setdefault('cidr', '10.0.0.0/24')
|
||||
keys.setdefault('ip_version', 4)
|
||||
keys.setdefault('ip_version', constants.IP_VERSION_4)
|
||||
keys.setdefault('enable_dhcp', True)
|
||||
with self.subnet(network=network, **keys) as subnet:
|
||||
# verify the response has each key with the correct value
|
||||
|
@ -3128,7 +3136,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
cidr = '10.0.0.0/24'
|
||||
subnet = self._test_create_subnet(gateway_ip=gateway_ip,
|
||||
cidr=cidr)
|
||||
self.assertEqual(4, subnet['subnet']['ip_version'])
|
||||
self.assertEqual(constants.IP_VERSION_4,
|
||||
subnet['subnet']['ip_version'])
|
||||
self.assertIn('name', subnet['subnet'])
|
||||
|
||||
def test_create_subnet_with_network_different_tenant(self):
|
||||
|
@ -3138,7 +3147,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
is_admin=False)
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'gateway_ip': '10.0.2.1'}}
|
||||
req = self.new_create_request('subnets', data,
|
||||
self.fmt, context=ctx)
|
||||
|
@ -3189,7 +3198,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': '10.0.2.1'}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -3208,7 +3217,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
min_prefixlen='25',
|
||||
is_default=True):
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.0.0/24', 'ip_version': '4',
|
||||
'cidr': '10.0.0.0/24',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': tenant_id}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
|
@ -3227,7 +3237,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
min_prefixlen='25',
|
||||
is_default=True):
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': tenant_id}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
|
@ -3247,7 +3257,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
tenant_id = network['network']['tenant_id']
|
||||
cfg.CONF.set_override('ipv6_pd_enabled', False)
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'ip_version': '6',
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'tenant_id': tenant_id}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
|
@ -3257,7 +3267,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': constants.IPv4_ANY,
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': '0.0.0.1'}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -3268,7 +3278,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': 'fe80::',
|
||||
'ip_version': '6',
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': 'fe80::1'}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -3279,7 +3289,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '2014::/65',
|
||||
'ip_version': '6',
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': 'fe80::1',
|
||||
'ipv6_address_mode': 'slaac'}}
|
||||
|
@ -3392,7 +3402,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
admin_state_up=True)
|
||||
network = self.deserialize(self.fmt, res)
|
||||
subnet = self._make_subnet(self.fmt, network, gateway_ip,
|
||||
cidr, ip_version=4)
|
||||
cidr, ip_version=constants.IP_VERSION_4)
|
||||
req = self.new_delete_request('subnets', subnet['subnet']['id'])
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPNoContent.code, res.status_int)
|
||||
|
@ -3405,7 +3415,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
admin_state_up=True)
|
||||
network = self.deserialize(self.fmt, res)
|
||||
subnet = self._make_subnet(self.fmt, network, gateway_ip,
|
||||
cidr, ip_version=4)
|
||||
cidr, ip_version=constants.IP_VERSION_4)
|
||||
self._create_port(self.fmt,
|
||||
network['network']['id'],
|
||||
device_owner=constants.DEVICE_OWNER_DHCP)
|
||||
|
@ -3418,9 +3428,11 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
admin_state_up=True)
|
||||
network = self.deserialize(self.fmt, res)
|
||||
subnet1 = self._make_subnet(self.fmt, network, '10.0.0.1',
|
||||
'10.0.0.0/24', ip_version=4)
|
||||
'10.0.0.0/24',
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
subnet2 = self._make_subnet(self.fmt, network, '10.0.1.1',
|
||||
'10.0.1.0/24', ip_version=4)
|
||||
'10.0.1.0/24',
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
res = self._create_port(self.fmt,
|
||||
network['network']['id'],
|
||||
device_owner=constants.DEVICE_OWNER_DHCP,
|
||||
|
@ -3478,7 +3490,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
admin_state_up=True)
|
||||
network = self.deserialize(self.fmt, res)
|
||||
subnet = self._make_subnet(self.fmt, network, gateway='fe80::1',
|
||||
cidr='fe80::/64', ip_version=6,
|
||||
cidr='fe80::/64',
|
||||
ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.IPV6_SLAAC,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC)
|
||||
kwargs = {}
|
||||
|
@ -3544,7 +3557,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
admin_state_up=True)
|
||||
network = self.deserialize(self.fmt, res)
|
||||
subnet = self._make_subnet(self.fmt, network, gateway_ip, cidr,
|
||||
ip_version=4)
|
||||
ip_version=constants.IP_VERSION_4)
|
||||
req = self.new_delete_request('networks', network['network']['id'])
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPNoContent.code, res.status_int)
|
||||
|
@ -3558,7 +3571,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
network['network']['id'],
|
||||
'10.0.2.0/24',
|
||||
webob.exc.HTTPNotFound.code,
|
||||
ip_version=4,
|
||||
ip_version=constants.IP_VERSION_4,
|
||||
tenant_id='bad_tenant_id',
|
||||
gateway_ip='10.0.2.1',
|
||||
device_owner='fake_owner',
|
||||
|
@ -3570,7 +3583,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
network['network']['id'],
|
||||
'10.0.2.0/24',
|
||||
webob.exc.HTTPCreated.code,
|
||||
ip_version=4,
|
||||
ip_version=constants.IP_VERSION_4,
|
||||
tenant_id='bad_tenant_id',
|
||||
gateway_ip='10.0.2.1',
|
||||
device_owner='fake_owner',
|
||||
|
@ -3647,7 +3660,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
# Check invalid UUID
|
||||
data = {'subnet': {'network_id': None,
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': '10.0.2.1'}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -3659,7 +3672,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
# Check invalid boolean
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'enable_dhcp': None,
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'gateway_ip': '10.0.2.1'}}
|
||||
|
@ -3685,7 +3698,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
for pool in allocation_pools:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': tenant_id,
|
||||
'gateway_ip': '10.0.2.1',
|
||||
'allocation_pools': pool}}
|
||||
|
@ -3704,7 +3717,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
for nameservers in nameserver_pools:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': tenant_id,
|
||||
'gateway_ip': '10.0.2.1',
|
||||
'dns_nameservers': nameservers}}
|
||||
|
@ -3726,7 +3739,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
for hostroutes in hostroute_pools:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': '4',
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': tenant_id,
|
||||
'gateway_ip': '10.0.2.1',
|
||||
'host_routes': hostroutes}}
|
||||
|
@ -3779,7 +3792,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'cidr': cidr,
|
||||
'allocation_pools': allocation_pools}
|
||||
self._test_create_subnet(expected=expected, gateway_ip=gateway,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.DHCPV6_STATEFUL,
|
||||
ipv6_address_mode=constants.DHCPV6_STATEFUL)
|
||||
# Gateway is first IP in IPv6 DHCPv6 stateful subnet
|
||||
|
@ -3790,14 +3803,14 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'cidr': cidr,
|
||||
'allocation_pools': allocation_pools}
|
||||
self._test_create_subnet(expected=expected, gateway_ip=gateway,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.DHCPV6_STATEFUL,
|
||||
ipv6_address_mode=constants.DHCPV6_STATEFUL)
|
||||
# If gateway_ip is not specified, allocate first IP from the subnet
|
||||
expected = {'gateway_ip': gateway,
|
||||
'cidr': cidr}
|
||||
self._test_create_subnet(expected=expected,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.IPV6_SLAAC,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC)
|
||||
|
||||
|
@ -3812,7 +3825,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'cidr': cidr,
|
||||
'allocation_pools': allocation_pools}
|
||||
self._test_create_subnet(expected=expected, gateway_ip=gateway,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.DHCPV6_STATELESS,
|
||||
ipv6_address_mode=constants.DHCPV6_STATELESS)
|
||||
# Gateway is first IP in IPv6 DHCPv6 Stateless subnet
|
||||
|
@ -3823,14 +3836,14 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
'cidr': cidr,
|
||||
'allocation_pools': allocation_pools}
|
||||
self._test_create_subnet(expected=expected, gateway_ip=gateway,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.DHCPV6_STATELESS,
|
||||
ipv6_address_mode=constants.DHCPV6_STATELESS)
|
||||
# If gateway_ip is not specified, allocate first IP from the subnet
|
||||
expected = {'gateway_ip': gateway,
|
||||
'cidr': cidr}
|
||||
self._test_create_subnet(expected=expected,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
ipv6_ra_mode=constants.IPV6_SLAAC,
|
||||
ipv6_address_mode=constants.IPV6_SLAAC)
|
||||
|
||||
|
@ -3901,7 +3914,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
net_id = network['network']['id']
|
||||
data = {'subnet': {'network_id': net_id,
|
||||
'cidr': '10.0.0.0/24',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'gateway_ip': '10.0.0.1',
|
||||
'tenant_id': network['network']['tenant_id'],
|
||||
'allocation_pools': [{'start': '10.0.0.100',
|
||||
|
@ -3941,7 +3954,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
allocation_pools = [{'start': 'fe80::2',
|
||||
'end': 'fe80::ffff:fffa:ffff'}]
|
||||
self._test_create_subnet(gateway_ip=gateway_ip,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
allocation_pools=allocation_pools)
|
||||
|
||||
@testtools.skipIf(tools.is_bsd(), 'bug/1484837')
|
||||
|
@ -3951,7 +3964,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
allocation_pools = [{'start': '::2',
|
||||
'end': '::ffff:ffff:ffff:fffe'}]
|
||||
self._test_create_subnet(gateway_ip=gateway_ip,
|
||||
cidr=cidr, ip_version=6,
|
||||
cidr=cidr, ip_version=constants.IP_VERSION_6,
|
||||
allocation_pools=allocation_pools)
|
||||
|
||||
def test_create_subnet_with_large_allocation_pool(self):
|
||||
|
@ -4059,7 +4072,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': 6,
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
|
@ -4069,7 +4082,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': 'fe80::0/80',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
|
@ -4079,7 +4092,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'gateway_ip': 'fe80::1',
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -4090,7 +4103,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': 'fe80::0/80',
|
||||
'ip_version': 6,
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'gateway_ip': '192.168.0.1',
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -4101,7 +4114,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': 'fe80::0/80',
|
||||
'ip_version': 6,
|
||||
'ip_version': constants.IP_VERSION_6,
|
||||
'dns_nameservers': ['192.168.0.1'],
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -4114,7 +4127,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'host_routes': host_routes,
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -4127,7 +4140,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.2.0/24',
|
||||
'ip_version': 4,
|
||||
'ip_version': constants.IP_VERSION_4,
|
||||
'host_routes': host_routes,
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
|
@ -4138,7 +4151,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
expect_success=True, **modes):
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
new_subnet = {'ip_version': 6,
|
||||
new_subnet = {'ip_version': constants.IP_VERSION_6,
|
||||
'cidr': 'fe80::/64',
|
||||
'enable_dhcp': True,
|
||||
'ipv6_address_mode': None,
|
||||
|
@ -4155,7 +4168,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
expect_success=True, **modes):
|
||||
plugin = directory.get_plugin()
|
||||
ctx = context.get_admin_context()
|
||||
new_subnet = {'ip_version': 6,
|
||||
new_subnet = {'ip_version': constants.IP_VERSION_6,
|
||||
'cidr': constants.PROVISIONAL_IPV6_PD_PREFIX,
|
||||
'enable_dhcp': True,
|
||||
'ipv6_address_mode': None,
|
||||
|