]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/utils: added new network module
authorFrancisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
Fri, 19 Feb 2016 22:05:41 +0000 (16:05 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 28 Feb 2016 11:32:33 +0000 (11:32 +0000)
A network module was added, and will contain network utility funcions for now.
with get_free_port that returns available network port in the system.

Signed-off-by: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/utils/network.py [new file with mode: 0644]

diff --git a/meta/lib/oeqa/utils/network.py b/meta/lib/oeqa/utils/network.py
new file mode 100644 (file)
index 0000000..2768f6c
--- /dev/null
@@ -0,0 +1,8 @@
+import socket
+
+def get_free_port():
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    s.bind(('', 0))
+    addr = s.getsockname()
+    s.close()
+    return addr[1]