Use IPv[46]_BITS instead of IPV[46]_MAX_PREFIXLEN

Replace references to IPV[46]_MAX_PREFIXLEN with IPv[46]_BITS from
neutron-lib. Replace several integer literals used to represent IP
address sizes with these constants too.

Remove IPV4_MAX_PREFIXLEN and IPV6_MAX_PREFIXLEN from neutron constants
as they are no longer referenced:
    http://codesearch.openstack.org/?q=IPV[46]_MAX_PREFIXLEN

Change-Id: I03e1405e71f08db9ac6e759258625139c28ecc89
changes/94/313794/2
Dustin Lundquist 7 years ago
parent 96a195c064
commit ae613a0157
  1. 3
      neutron/common/constants.py
  2. 2
      neutron/objects/common_types.py
  3. 7
      neutron/services/externaldns/drivers/designate/driver.py
  4. 6
      neutron/tests/tempest/api/test_network_ip_availability.py
  5. 11
      neutron/tests/tools.py
  6. 7
      neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py

@ -131,9 +131,6 @@ VALID_ETHERTYPES = (lib_constants.IPv4, lib_constants.IPv6)
IP_ALLOWED_VERSIONS = [lib_constants.IP_VERSION_4, lib_constants.IP_VERSION_6]
IPV4_MAX_PREFIXLEN = 32
IPV6_MAX_PREFIXLEN = 128
# Some components communicate using private address ranges, define
# them all here. These address ranges should not cause any issues
# even if they overlap since they are used in disjoint namespaces,

@ -54,7 +54,7 @@ class IPNetworkPrefixLen(RangeConstrainedInteger):
"""IP network (CIDR) prefix length custom Enum"""
def __init__(self, **kwargs):
super(IPNetworkPrefixLen, self).__init__(
start=0, end=constants.IPV6_MAX_PREFIXLEN,
start=0, end=n_const.IPv6_BITS,
**kwargs)

@ -20,6 +20,7 @@ from designateclient.v2 import client as d_client
from keystoneclient.auth.identity.generic import password
from keystoneclient.auth import token_endpoint
from keystoneclient import session
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log
@ -175,8 +176,10 @@ class Designate(driver.ExternalDNSService):
def _get_bytes_or_nybles_to_skip(self, in_addr_name):
if 'in-addr.arpa' in in_addr_name:
return int((32 - CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return int((128 - CONF.designate.ipv6_ptr_zone_prefix_size) / 4)
return int((constants.IPv4_BITS -
CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return int((constants.IPv6_BITS -
CONF.designate.ipv6_ptr_zone_prefix_size) / 4)
def delete_record_set(self, context, dns_domain, dns_name, records):
designate, designate_admin = get_clients(context)

@ -99,9 +99,11 @@ class NetworksIpAvailabilityTest(base.BaseAdminNetworkTest):
def calc_total_ips(prefix, ip_version):
# will calculate total ips after removing reserved.
if ip_version == lib_constants.IP_VERSION_4:
total_ips = 2 ** (32 - prefix) - DEFAULT_IP4_RESERVED
total_ips = 2 ** (lib_constants.IPv4_BITS
- prefix) - DEFAULT_IP4_RESERVED
elif ip_version == lib_constants.IP_VERSION_6:
total_ips = 2 ** (128 - prefix) - DEFAULT_IP6_RESERVED
total_ips = 2 ** (lib_constants.IPv6_BITS
- prefix) - DEFAULT_IP6_RESERVED
return total_ips

@ -25,12 +25,13 @@ import warnings
import fixtures
import mock
import netaddr
from neutron_lib import constants
import six
import unittest2
import neutron
from neutron.api.v2 import attributes
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import ipv6_utils
@ -233,14 +234,14 @@ def get_random_integer(range_begin=0, range_end=1000):
def get_random_prefixlen(version=4):
maxlen = constants.IPV4_MAX_PREFIXLEN
maxlen = constants.IPv4_BITS
if version == 6:
maxlen = constants.IPV6_MAX_PREFIXLEN
maxlen = constants.IPv6_BITS
return random.randint(0, maxlen)
def get_random_ip_version():
return random.choice(constants.IP_ALLOWED_VERSIONS)
return random.choice(n_const.IP_ALLOWED_VERSIONS)
def get_random_cidr(version=4):
@ -302,4 +303,4 @@ def reset_random_seed():
def get_random_ipv6_mode():
return random.choice(constants.IPV6_MODES)
return random.choice(n_const.IPV6_MODES)

@ -15,6 +15,7 @@
import mock
import netaddr
from neutron_lib import constants
from neutron import context
from neutron.db import dns_db
@ -235,8 +236,10 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
def _get_bytes_or_nybles_to_skip(self, in_addr_name):
if 'in-addr.arpa' in in_addr_name:
return ((
32 - config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return (128 - config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
constants.IPv4_BITS -
config.cfg.CONF.designate.ipv4_ptr_zone_prefix_size) / 8)
return (constants.IPv6_BITS -
config.cfg.CONF.designate.ipv6_ptr_zone_prefix_size) / 4
def test_create_port(self, *mocks):
config.cfg.CONF.set_override('dns_domain', DNSDOMAIN)

Loading…
Cancel
Save