Canonizes IPv6 before insert it into the db
This is normalize IPv6 to be inserted always in shortened and no mixed form into db, this way postgresql, which uses INET type, and other databases like mysql will have equivalent contents. Fix bug 1116236 Related to bp migration-testing-with-data Change-Id: Iae5aa8a28e3ccc0d3a1a96459232b827c3a19d5c
This commit is contained in:
@@ -892,6 +892,15 @@ def is_valid_ipv4(address):
|
||||
return False
|
||||
|
||||
|
||||
def is_valid_ipv6(address):
|
||||
return netaddr.valid_ipv6(address)
|
||||
|
||||
|
||||
def get_shortened_ipv6(address):
|
||||
addr = netaddr.IPAddress(address, version=6)
|
||||
return str(addr.ipv6())
|
||||
|
||||
|
||||
def is_valid_cidr(address):
|
||||
"""Check if the provided ipv4 or ipv6 address is a valid
|
||||
CIDR address or not"""
|
||||
|
||||
Reference in New Issue
Block a user