diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-07-17 02:10:34 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-07-17 04:57:39 +0000 |
commit | 146e193c209fe654c4aeb88e9a2564df9960a8e4 (patch) | |
tree | efb8653e9fb770e19b82e7b1b5cf0cf1f53d1ae2 /yardstick/common/utils.py | |
parent | eeda3f6b215c16cbb567168cb63d987c65f8a1b9 (diff) |
Add API(v2) to create influxdb
JIRA: YARDSTICK-726
API: /api/v2/yardstick/containers/action
METHOD: POST
PARAMS:
{
'action': 'create_influxdb',
'args': {
'environment_id': environment_id
}
}
Change-Id: I20961fc6ae9918c894de7fabd3f81ca966bd24cd
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/common/utils.py')
-rw-r--r-- | yardstick/common/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index a4f7b30dc..92bb7b7d3 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -24,7 +24,10 @@ import os import subprocess import sys import collections +import socket +import random from functools import reduce +from contextlib import closing import yaml import six @@ -263,3 +266,11 @@ def set_dict_value(dic, keys, value): 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 |