diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-02-03 14:02:12 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-02-03 14:02:12 +0000 |
commit | ee955d272ab4eef2e8371f2e460454058ce7e46c (patch) | |
tree | 4061fe7b9366ed467c4183d9cf8b8998da0cb0e9 /nova/utils.py | |
parent | fceed501895107c1def893c38d88e435d81d5a12 (diff) | |
parent | ed45c0b95d6eea0d4a40437dcbbc5920a72aa939 (diff) | |
download | nova-ee955d272ab4eef2e8371f2e460454058ce7e46c.tar.gz nova-ee955d272ab4eef2e8371f2e460454058ce7e46c.tar.xz nova-ee955d272ab4eef2e8371f2e460454058ce7e46c.zip |
Merge "Reimplement is_valid_ipv4()."
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/nova/utils.py b/nova/utils.py index e4d708f5c..2386e6aa8 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -881,19 +881,12 @@ def is_valid_boolstr(val): def is_valid_ipv4(address): - """valid the address strictly as per format xxx.xxx.xxx.xxx. - where xxx is a value between 0 and 255. - """ - parts = address.split(".") - if len(parts) != 4: + """Verify that address represents a valid IPv4 address.""" + try: + addr = netaddr.IPAddress(address) + return addr.version == 4 + except Exception: return False - for item in parts: - try: - if not 0 <= int(item) <= 255: - return False - except ValueError: - return False - return True def is_valid_cidr(address): |