netaddr: fix IP conversion issues with netaddr>1.0.0

netaddr 1.0.0 and above changed the way things are
converted to IPs (see [1]), make Horizon work
after bumping to this new version (see [2])

[1]: https://netaddr.readthedocs.io/en/latest/changes.html#release-1-0-0
[2]: https://review.opendev.org/c/openstack/requirements/+/909300

Change-Id: I3d7da8ef919f0607a1d32e2b28760e95449b4eaa
This commit is contained in:
elajkat 2024-08-28 13:18:09 +02:00 committed by Lajos Katona
parent 5daabe542d
commit d6ffcdd149

View File

@ -89,7 +89,11 @@ class IPField(fields.Field):
try: try:
if self.mask: if self.mask:
self.ip = netaddr.IPNetwork(value) try:
self.ip = netaddr.IPNetwork(value.strip())
except netaddr.AddrFormatError:
self.ip = netaddr.IPNetwork(
netaddr.cidr_abbrev_to_verbose(value.strip()))
else: else:
self.ip = netaddr.IPAddress(value) self.ip = netaddr.IPAddress(value)
except Exception: except Exception: