Remove netaddr module requirement

This patch removes the 'netaddr' module from the Designate requirements list.
It replaces the use of netaddr in Designate with the python standard library 'ipaddress' module.

Change-Id: I2fb1549e1d6cbccf58c03810c7d74c8c378682d5
This commit is contained in:
Michael Johnson 2022-08-02 21:52:40 +00:00
parent 9876b7b935
commit 968e3d348d
5 changed files with 14 additions and 10 deletions

View File

@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import ipaddress
import logging
import sys
@ -22,7 +23,6 @@ import dns.exception
from dns.ipv4 import inet_aton
from keystoneauth1.identity import generic
from keystoneauth1 import session as keystone_session
import netaddr
from designateclient import shell
from designateclient.v2 import client
@ -72,8 +72,9 @@ def fix_bad_recordsets(bad_recordsets):
for rs in bad_recordsets:
new_records = []
for ip in bad_recordsets[rs]['records']:
ip = '.'.join(f'{int(i)}' for i in ip.split('.'))
new_records.append(
str(netaddr.IPAddress(ip, flags=netaddr.ZEROFILL).ipv4())
str(ipaddress.IPv4Address(ip))
)
bad_recordsets[rs]['records'] = new_records
return bad_recordsets

View File

@ -11,10 +11,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import ipaddress
import os.path
import urllib
import netaddr
from oslo_config import cfg
from oslo_log import log as logging
import requests
@ -83,7 +83,7 @@ class PDNS4Backend(base.Backend):
masters = []
for master in self.masters:
host = master.host
if netaddr.IPAddress(host).version == 6:
if ipaddress.ip_address(host).version == 6:
host = '[%s]' % host
masters.append('%s:%d' % (host, master.port))

View File

@ -13,10 +13,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import ipaddress
import re
import jsonschema
import netaddr
# NOTE(kiall): All of the below regular expressions are terminated with
@ -59,9 +59,7 @@ def is_ipv4(instance):
return True
try:
address = netaddr.IPAddress(instance, version=4)
# netaddr happly accepts, and expands "127.0" into "127.0.0.0"
if str(address) != instance:
if ipaddress.ip_address(instance).version != 4:
return False
except Exception:
return False
@ -79,7 +77,8 @@ def is_ipv6(instance):
return True
try:
netaddr.IPAddress(instance, version=6)
if ipaddress.ip_address(instance).version != 6:
return False
except Exception:
return False

View File

@ -0,0 +1,5 @@
---
other:
- |
The netaddr python module has been removed as a Designate requirement. It
has been replaced with the python standard library 'ipaddress' module.

View File

@ -12,7 +12,6 @@ Jinja2>=2.10 # BSD License (3 clause)
jsonschema>=3.2.0 # MIT
keystoneauth1>=3.4.0 # Apache-2.0
keystonemiddleware>=4.17.0 # Apache-2.0
netaddr>=0.7.18 # BSD
oslo.config>=6.8.0 # Apache-2.0
oslo.concurrency>=4.2.0 # Apache-2.0
oslo.messaging>=12.4.0 # Apache-2.0