Simple mapper/scheduler/partitioner functions implemented
[domino.git] / lib / util / netutil.py
diff --git a/lib/util/netutil.py b/lib/util/netutil.py
new file mode 100644 (file)
index 0000000..f8cc2d4
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+#
+# Licence statement goes here
+#
+
+import socket
+def get_ip():
+    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+    try:
+        # doesn't even have to be reachable
+        s.connect(('192.255.255.255', 1))
+        IP = s.getsockname()[0]
+    except:
+        IP = '127.0.0.1'
+    finally:
+        s.close()
+    return IP