Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "HA testcase containerized Compass support"
[yardstick.git]
/
yardstick
/
common
/
utils.py
diff --git
a/yardstick/common/utils.py
b/yardstick/common/utils.py
index
a4f7b30
..
92bb7b7
100644
(file)
--- a/
yardstick/common/utils.py
+++ b/
yardstick/common/utils.py
@@
-24,7
+24,10
@@
import os
import subprocess
import sys
import collections
import subprocess
import sys
import collections
+import socket
+import random
from functools import reduce
from functools import reduce
+from contextlib import closing
import yaml
import six
import yaml
import six
@@
-263,3
+266,11
@@
def set_dict_value(dic, keys, value):
else:
return_dic = return_dic[key]
return dic
else:
return_dic = return_dic[key]
return dic
+
+
+def get_free_port(ip):
+ with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
+ while True:
+ port = random.randint(5000, 10000)
+ if s.connect_ex((ip, port)) != 0:
+ return port