From 20983093b42bf5a9c43f8fa5d23784d26ccbd7b7 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 7 Oct 2024 11:06:26 +0900 Subject: [PATCH] Fix compatibility with netaddr 1.1.0 Fix a few different behaviors detected in unit tests. Closes-Bug: #2054134 Change-Id: I34f29d983fccc10cc4994fb23527a6dd0eac2b83 --- oslo_utils/netutils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py index 6e4c54c1..405256ee 100644 --- a/oslo_utils/netutils.py +++ b/oslo_utils/netutils.py @@ -101,6 +101,9 @@ def is_valid_ipv4(address, strict=None): (``a.b.c.d``) as opposed to address format (``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``). """ + if not address: + return False + if strict is not None: flag = INET_PTON if strict else INET_ATON try: @@ -228,6 +231,9 @@ def get_ipv6_addr_by_EUI64(prefix, mac): .. versionadded:: 1.4 """ + if not isinstance(prefix, str): + msg = _("Prefix must be a string") + raise TypeError(msg) # Check if the prefix is an IPv4 address if is_valid_ipv4(prefix): msg = _("Unable to generate IP address by EUI64 for IPv4 prefix")