From d6ffcdd149fb2969909c8263828654810aedb6ab Mon Sep 17 00:00:00 2001 From: elajkat Date: Wed, 28 Aug 2024 13:18:09 +0200 Subject: [PATCH] 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 --- horizon/forms/fields.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/horizon/forms/fields.py b/horizon/forms/fields.py index 05ccbf376e..648be448cb 100644 --- a/horizon/forms/fields.py +++ b/horizon/forms/fields.py @@ -89,7 +89,11 @@ class IPField(fields.Field): try: 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: self.ip = netaddr.IPAddress(value) except Exception: