From 2a6f97940f71c056b4bfb0cd9a86f5d676abc4e1 Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Mon, 11 Jul 2011 13:34:39 -0700 Subject: add optional parameter networks to the Create server OS API --- nova/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'nova/utils.py') diff --git a/nova/utils.py b/nova/utils.py index 8784a227d..22b3a29bf 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -775,6 +775,22 @@ def bool_from_str(val): 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 + + class Bootstrapper(object): """Provides environment bootstrapping capabilities for entry points.""" -- cgit