Remove leading zeroes from an IP address

In python3.9, ipaddress.IPv4Interface does not support defining an
IP address with leading zeroes. E.g.:

>>> ipaddress.IPv4Interface('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/", line 1390, in __init__
    IPv4Address.__init__(self, addr)
  File "/usr/lib/python3.9/", line 1307, in __init__
    self._ip = self._ip_int_from_string(addr_str)
  File "/usr/lib/python3.9/", line 1199, in
    raise AddressValueError("%s in %r" % (exc, ip_str)) from None
ipaddress.AddressValueError: Leading zeros are not permitted in '00' in

Change-Id: I29137b22c158e979e81be9e41464948aa99f5498
Closes-Bug: #1930222
Rodolfo Alonso Hernandez 2 years ago
parent 5a6f61af4a
commit b141aed512

@ -476,7 +476,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
'id': self.uuid}]
ip_prefixes = {'source_ip_prefix': '',
'destination_ip_prefix': ''}
'destination_ip_prefix': ''}
with self.router(tenant_id=self.tenant_id, set_context=True):
with self.metering_label(tenant_id=self.tenant_id,
set_context=True) as label: