summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsomor@gmail.com>2022-08-02 21:52:40 +0000
committerMichael Johnson <johnsomor@gmail.com>2022-08-02 22:02:13 +0000
commit968e3d348d57d60016e9b17615234b83fb7bc20c (patch)
tree872001480130389f08348ce16edf48d7858eb64c
parent9876b7b9357765e430833b149fe7480ddb005550 (diff)
downloaddesignate-968e3d348d57d60016e9b17615234b83fb7bc20c.tar.gz
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
-rwxr-xr-xcontrib/fixleadingzeros.py5
-rw-r--r--designate/backend/impl_pdns4.py4
-rw-r--r--designate/schema/format.py9
-rw-r--r--releasenotes/notes/remove-netaddr-requirement-ab9b9c2d15aa8e1c.yaml5
-rw-r--r--requirements.txt1
5 files changed, 14 insertions, 10 deletions
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
diff --git a/designate/backend/impl_pdns4.py b/designate/backend/impl_pdns4.py
index a7e8cf6e..30172233 100644
--- a/designate/backend/impl_pdns4.py
+++ b/designate/backend/impl_pdns4.py
@@ -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))
diff --git a/designate/schema/format.py b/designate/schema/format.py
index bbed2017..72f968c4 100644
--- a/designate/schema/format.py
+++ b/designate/schema/format.py
@@ -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
diff --git a/releasenotes/notes/remove-netaddr-requirement-ab9b9c2d15aa8e1c.yaml b/releasenotes/notes/remove-netaddr-requirement-ab9b9c2d15aa8e1c.yaml
new file mode 100644
index 00000000..fb810839
--- /dev/null
+++ b/releasenotes/notes/remove-netaddr-requirement-ab9b9c2d15aa8e1c.yaml
@@ -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.
diff --git a/requirements.txt b/requirements.txt
index 6fa0ddf9..ac138eb2 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -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