From 0a29e9ec59e21dc46db0497187cc9d0de0844b05 Mon Sep 17 00:00:00 2001 From: liyin Date: Tue, 7 Feb 2017 15:29:50 +0800 Subject: Log_dir bug fix&Add function of test_ip init JIRA:BOTTLENECK-129 This patch fix the error of log_dir can't be found. And change several thing: 1.Add if config don't have test_ip, it will use local:8888 as test ip. 2.Fix the bug in setup.py. 3.Add parser init to logger file. Change-Id: I808c69e2b2ff3c04f271cc7f3e14e1ab406a4d1b Signed-off-by: liyin --- utils/logger.py | 5 +++-- utils/parser.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'utils') diff --git a/utils/logger.py b/utils/logger.py index 80392f59..5ce64238 100644 --- a/utils/logger.py +++ b/utils/logger.py @@ -19,7 +19,8 @@ import logging import os -from utils.parser import Parser as conf +from utils.parser import Parser as conf_parser +conf_parser.config_init() class Logger: @@ -47,7 +48,7 @@ class Logger: ch.setLevel(logging.INFO) self.logger.addHandler(ch) - result_path = conf.bottlenecks_config["log_dir"] + result_path = conf_parser.bottlenecks_config["log_dir"] if not os.path.exists(result_path): os.makedirs(result_path) result_file = os.path.join(result_path, 'bottlenecks.log') diff --git a/utils/parser.py b/utils/parser.py index 7b1f4e2e..a9098a98 100644 --- a/utils/parser.py +++ b/utils/parser.py @@ -14,6 +14,7 @@ Second is reading config file.''' import os import yaml +from pyroute2 import IPDB class Parser(): @@ -82,6 +83,16 @@ class Parser(): # TO-DO add cli parameters to stack_config. return test_cfg, stack_cfg + @staticmethod + def ip_parser(ip_type): + with IPDB() as ip: + GATEWAY_IP = ip.routes['default'].gateway + if ip_type is "dashboard": + TEST_IP = GATEWAY_IP + ":9200" + elif ip_type is "yardstick_test_ip": + TEST_IP = GATEWAY_IP + ":8888" + return TEST_IP + class HeatTemplate_Parser(): """parser a Heat template and a method to deploy template to a stack""" @@ -282,4 +293,3 @@ class HeatTemplate_Parser(): def get_template_date(self): return self.heat_date - -- cgit 1.2.3-korg