summaryrefslogtreecommitdiffstats
path: root/utils/infra_setup/runner
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-07-13 11:54:08 +0800
committerAce Lee <liyin11@huawei.com>2017-07-14 09:43:39 +0000
commitbde702f95563cf953c32f9bfd0587083a3fea26d (patch)
tree2bb402a5b730adf28508e12208131c5f3b2cd9ee /utils/infra_setup/runner
parentc821b792db011dbbe1c70d256fadbe9c745570ff (diff)
Add frame support of elk one docker support
JIRA: BOTTLENECK-171 Add support of Bottlenecks docker frame refact, After this patch we will provide the ability of several installer. Add Yardstick_TAG to adjust yardstick docker version Change-Id: Ib431f8acf4a76b59f9d5e8783bcc7d2e5be208ae Signed-off-by: liyin <liyin11@huawei.com>
Diffstat (limited to 'utils/infra_setup/runner')
-rw-r--r--utils/infra_setup/runner/docker_env.py (renamed from utils/infra_setup/runner/docker_usage.py)50
1 files changed, 40 insertions, 10 deletions
diff --git a/utils/infra_setup/runner/docker_usage.py b/utils/infra_setup/runner/docker_env.py
index 63dc6e7a..1e8728eb 100644
--- a/utils/infra_setup/runner/docker_usage.py
+++ b/utils/infra_setup/runner/docker_env.py
@@ -14,9 +14,11 @@ At present, This file contain the following function:
3.Remove a docker.'''
import docker
+import os
+import socket
-yardstick_info = None
-ELK_info = None
+yardstick_info = {}
+ELK_info = {}
def get_client():
@@ -35,23 +37,40 @@ def env_yardstick(docker_name):
yardstick_info["name"] = docker_name
try:
env_docker = docker_find(docker_name)
- yardstick_info["containner"] = env_docker
+ yardstick_info["container"] = env_docker
yardstick_info["ip"] = get_docker_ip(docker_name)
return env_docker
except docker.errors.NotFound:
pass
- env_docker = client.containers.run(image="opnfv/yardstick:latest",
+ volume = get_self_volume()
+ yardstick_tag = os.getenv("Yardstick_TAG")
+ if yardstick_tag is None:
+ yardstick_tag = "latest"
+ env_docker = client.containers.run(image="opnfv/yardstick:%s"
+ % yardstick_tag,
privileged=True,
+ tty=True,
detach=True,
- ports={'8888': '5000'},
- volumes={'/var/run/docker.sock':
- '/var/run/docker.sock'},
+ ports={'5000': '8888'},
+ volumes=volume,
name=docker_name)
- yardstick_info["containner"] = env_docker
+ yardstick_info["container"] = env_docker
yardstick_info["ip"] = get_docker_ip(docker_name)
return env_docker
+def env_bottlenecks(docker_name):
+ client = get_client()
+ volume = get_self_volume()
+ env_docker = client.containers.run(image="opnfv/bottlenecks:latest",
+ privileged=True,
+ detach=True,
+ ports={'8888': '5000'},
+ volumes=volume,
+ name=docker_name)
+ return env_docker
+
+
def env_elk(docker_name):
client = get_client()
ELK_info["name"] = docker_name
@@ -77,12 +96,23 @@ def env_elk(docker_name):
def get_docker_ip(docker_name):
env_docker = docker_find(docker_name)
client = docker.APIClient(base_url='unix://var/run/docker.sock')
- ip_address = client.inspect_container(env_docker.id)
+ docker_inspect = client.inspect_container(env_docker.id)
+ ip_address = docker_inspect["NetworkSettings"]["IPAddress"]
return ip_address
def docker_exec_cmd(docker, cmd):
- return docker.exec_cmd(cmd)
+ return docker.exec_run(cmd)
+
+
+def get_self_volume():
+ self_volume = {}
+ hostname = socket.gethostname()
+ client = docker.APIClient(base_url='unix://var/run/docker.sock')
+ volume = client.inspect_container(hostname)["Mounts"]
+ for i in volume:
+ self_volume[i['Source']] = i['Destination']
+ return self_volume
def remove_docker(docker_name):