aboutsummaryrefslogtreecommitdiffstats
path: root/func/env_setup.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-09-20 13:58:21 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-09-21 15:02:44 +0800
commit6183cefebbc1af8ad1987dc61372d6c2d6a59f6d (patch)
treed2300ba196eb5e61fd2366a44e29f018791ad961 /func/env_setup.py
parentfac2a3bff97efed6d4e50bfe249c8107100b8f52 (diff)
add unified logger process for qtip
log the output information to both file and console, and unify the log file path and level JIRA: QTIP-108 Change-Id: I3a881e9da1f74c6959250a94f05cf90a231c34e6 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'func/env_setup.py')
-rw-r--r--func/env_setup.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/func/env_setup.py b/func/env_setup.py
index 96f984cb..cd82f303 100644
--- a/func/env_setup.py
+++ b/func/env_setup.py
@@ -8,18 +8,19 @@
##############################################################################
import os
+import random
+import socket
import sys
-from collections import defaultdict
-import yaml
import time
-import paramiko
-import socket
+from collections import defaultdict
from os.path import expanduser
-import random
-import logging
-LOG = logging.getLogger(__name__)
-LOG.setLevel(logging.DEBUG)
+import paramiko
+import yaml
+
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('env_setup').get
class Env_setup:
@@ -100,7 +101,7 @@ class Env_setup:
@staticmethod
def fetch_compute_ips():
- LOG.info("Fetch compute ips through installer")
+ logger.info("Fetch compute ips through installer")
ips = []
installer_type = str(os.environ['INSTALLER_TYPE'].lower())
@@ -112,18 +113,18 @@ class Env_setup:
cmd = "bash ./func/fetch_compute_ips.sh -i %s -a %s" % \
(installer_type, installer_ip)
- LOG.info(cmd)
+ logger.info(cmd)
os.system(cmd)
home = expanduser("~")
with open(home + "/ips.log", "r") as file:
data = file.read()
if data:
ips.extend(data.rstrip('\n').split('\n'))
- LOG.info("All compute ips: %s" % ips)
+ logger.info("All compute ips: %s" % ips)
return ips
def check_machine_ips(self, host_tag):
- LOG.info("Check machine ips")
+ logger.info("Check machine ips")
ips = self.fetch_compute_ips()
ips_num = len(ips)
num = len(host_tag)
@@ -137,7 +138,7 @@ class Env_setup:
if host_tag[hostlabel]['ip'] in ips:
info = "%s's ip %s is defined by test case yaml file" % \
(hostlabel, host_tag[hostlabel]['ip'])
- LOG.info(info)
+ logger.info(info)
else:
err = "%s is not in %s" % (host_tag[hostlabel]['ip'], ips)
raise RuntimeError(err)