From 968e3d348d57d60016e9b17615234b83fb7bc20c Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Tue, 2 Aug 2022 21:52:40 +0000 Subject: 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 --- contrib/fixleadingzeros.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/fixleadingzeros.py b/contrib/fixleadingzeros.py index cdf49f1d..3659a29a 100755 --- a/contrib/fixleadingzeros.py +++ b/contrib/fixleadingzeros.py @@ -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 -- cgit v1.2.1