diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-03-05 13:26:37 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-03-05 13:26:37 +0000 |
commit | 1a83c02299dc9331ec5e973145ff22ebb6efcd22 (patch) | |
tree | dcef42c5f44ea3ea9c731ec1a9bb6f4ba300cc5a /nova/utils.py | |
parent | 899d518aec818bc7609f523baa6bc1dfd45d2ece (diff) | |
parent | 481c314d6a54965fe6e0972995c6ad9afa86a908 (diff) | |
download | nova-1a83c02299dc9331ec5e973145ff22ebb6efcd22.tar.gz nova-1a83c02299dc9331ec5e973145ff22ebb6efcd22.tar.xz nova-1a83c02299dc9331ec5e973145ff22ebb6efcd22.zip |
Merge "Standarize ip validation along the code"
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/nova/utils.py b/nova/utils.py index 764fa9070..5afdf52fd 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -945,14 +945,16 @@ def is_valid_boolstr(val): def is_valid_ipv4(address): """Verify that address represents a valid IPv4 address.""" try: - addr = netaddr.IPAddress(address) - return addr.version == 4 + return netaddr.valid_ipv4(address) except Exception: return False def is_valid_ipv6(address): - return netaddr.valid_ipv6(address) + try: + return netaddr.valid_ipv6(address) + except Exception: + return False def is_valid_ipv6_cidr(address): |