summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index f6e98c2eb..fc4bbd53b 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -844,3 +844,19 @@ def bool_from_str(val):
return True if int(val) else False
except ValueError:
return val.lower() == 'true'
+
+
+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:
+ return False
+ for item in parts:
+ try:
+ if not 0 <= int(item) <= 255:
+ return False
+ except ValueError:
+ return False
+ return True