summaryrefslogtreecommitdiffstats
path: root/utils
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
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')
-rw-r--r--utils/env_prepare/quota_prepare.py3
-rw-r--r--utils/env_prepare/stack_prepare.py30
-rw-r--r--utils/infra_setup/runner/docker_env.py (renamed from utils/infra_setup/runner/docker_usage.py)50
-rw-r--r--utils/parser.py12
4 files changed, 77 insertions, 18 deletions
diff --git a/utils/env_prepare/quota_prepare.py b/utils/env_prepare/quota_prepare.py
index e52a3e32..850a46a4 100644
--- a/utils/env_prepare/quota_prepare.py
+++ b/utils/env_prepare/quota_prepare.py
@@ -21,7 +21,8 @@ neutron_quota = {"subnet": -1,
"floatingip": -1,
"subnetpool": -1,
"router": -1,
- "port": -1}
+ "port": -1,
+ "security_group": -1}
nova_quota = {"ram": -1,
"cores": -1,
diff --git a/utils/env_prepare/stack_prepare.py b/utils/env_prepare/stack_prepare.py
index 3c706fad..ce8da619 100644
--- a/utils/env_prepare/stack_prepare.py
+++ b/utils/env_prepare/stack_prepare.py
@@ -13,25 +13,41 @@ import errno
from utils.logger import Logger
from utils.parser import Parser as config
import utils.infra_setup.heat.manager as utils
+import utils.infra_setup.runner.docker_env as docker_env
LOG = Logger(__name__).getLogger()
-def _prepare_env_daemon():
-
- installer_ip = os.environ.get('INSTALLER_IP', 'undefined')
- installer_type = os.environ.get('INSTALLER_TYPE', 'undefined')
+def _prepare_env_daemon(test_yardstick):
rc_file = config.bottlenecks_config["rc_dir"]
- _get_remote_rc_file(rc_file, installer_ip, installer_type)
+ if not os.path.exists(rc_file):
+ installer_ip = os.environ.get('INSTALLER_IP', 'undefined')
+ installer_type = os.environ.get('INSTALLER_TYPE', 'undefined')
+ _get_remote_rc_file(rc_file, installer_ip, installer_type)
_source_file(rc_file)
- # _append_external_network(rc_file)
+ if not os.environ.get("EXTERNAL_NETWORK"):
+ _append_external_network(rc_file)
+ if test_yardstick:
+ cmd = "cp %s %s" % (rc_file,
+ config.bottlenecks_config["yardstick_rc_dir"])
+ yardstick_contain = docker_env.yardstick_info["container"]
+ docker_env.docker_exec_cmd(yardstick_contain,
+ cmd)
# update the external_network
- # _source_file(rc_file)
+ _source_file(rc_file)
+
+
+def file_copy(src_file, dest_file):
+ src = file(src_file, "r+")
+ des = file(dest_file, "w+")
+ des.writelines(src.read())
+ src.close()
+ des.close()
def _get_remote_rc_file(rc_file, installer_ip, installer_type):
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):
diff --git a/utils/parser.py b/utils/parser.py
index ad141acb..65072c06 100644
--- a/utils/parser.py
+++ b/utils/parser.py
@@ -17,6 +17,7 @@ import yaml
import json
import time
from pyroute2 import IPDB
+import utils.infra_setup.runner.docker_env as docker_env
class Parser():
@@ -41,6 +42,8 @@ class Parser():
cls.bottlenecks_config["fetch_os"] = common_config["fetch_os_file"]
cls.bottlenecks_config["log_dir"] = common_config['log_dir']
cls.bottlenecks_config["rc_dir"] = common_config['rc_dir']
+ cls.bottlenecks_config["yardstick_rc_dir"] = \
+ common_config['yardstick_rc_dir']
cls.config_dir_check(cls.bottlenecks_config["log_dir"])
@classmethod
@@ -93,6 +96,15 @@ class Parser():
return test_cfg, stack_cfg
@staticmethod
+ def convert_docker_env(config, ip_type):
+ if ip_type is "dashboard":
+ config["contexts"]["dashboard_ip"] = \
+ docker_env.ELK_info["ip"] + ":9200"
+ elif ip_type is "yardstick":
+ config["contexts"]["yardstick_ip"] = \
+ docker_env.yardstick_info["ip"] + ":8888"
+
+ @staticmethod
def ip_parser(ip_type):
with IPDB() as ip:
GATEWAY_IP = ip.routes['default'].gateway