summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-08 18:13:42 +0000
committerGerrit Code Review <review@openstack.org>2022-08-08 18:13:42 +0000
commit7f87a8fa4ff6283c83a5ddc2afd2a74204a90f8c (patch)
tree28dbf46d2066e7ce14a166e3f78722e5cad4fc84
parent8beccabe4eb78f7da60748cec84df66946d423e7 (diff)
parent968e3d348d57d60016e9b17615234b83fb7bc20c (diff)
downloaddesignate-7f87a8fa4ff6283c83a5ddc2afd2a74204a90f8c.tar.gz
Merge "Remove netaddr module requirement"
-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