aboutsummaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-09-21 07:17:52 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-21 07:17:52 +0000
commit58ac79cd54821bf8c3891d136be4254aa79bfa08 (patch)
tree52bd6f03a9e7d50b44ffce15dab47d5ddead381c /func
parentad90940e82c0039372d68f3136791851994557a9 (diff)
parent6183cefebbc1af8ad1987dc61372d6c2d6a59f6d (diff)
Merge "add unified logger process for qtip"
Diffstat (limited to 'func')
-rw-r--r--func/ansible_api.py11
-rw-r--r--func/driver.py12
-rw-r--r--func/env_setup.py27
3 files changed, 28 insertions, 22 deletions
diff --git a/func/ansible_api.py b/func/ansible_api.py
index 57224eb7..2f02a62e 100644
--- a/func/ansible_api.py
+++ b/func/ansible_api.py
@@ -8,12 +8,15 @@
##############################################################################
import os
from collections import namedtuple
-import logging
+from ansible.executor.playbook_executor import PlaybookExecutor
+from ansible.inventory import Inventory
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager
-from ansible.inventory import Inventory
-from ansible.executor.playbook_executor import PlaybookExecutor
+
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('ansible_api').get
class AnsibleApi:
@@ -26,7 +29,7 @@ class AnsibleApi:
def _check_path(self, file_path):
if not os.path.exists(file_path):
- logging.error('The playbook %s does not exist' % file_path)
+ logger.error('The playbook %s does not exist' % file_path)
return False
else:
return True
diff --git a/func/driver.py b/func/driver.py
index 726016a5..ff40a4cc 100644
--- a/func/driver.py
+++ b/func/driver.py
@@ -1,20 +1,22 @@
##############################################################################
-# Copyright (c) 2015 Dell Inc and others.
+# Copyright (c) 2015 Dell Inc, ZTE and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import logging
-from func.ansible_api import AnsibleApi
+from utils import logger_utils
+from ansible_api import AnsibleApi
+
+logger = logger_utils.QtipLogger('driver').get
class Driver:
def __init__(self):
- logging.info("Class driver initialized\n")
+ logger.info("Class driver initialized\n")
self.installer_username = {'fuel': 'root',
'joid': 'ubuntu',
'apex': 'heat-admin'}
@@ -58,7 +60,7 @@ class Driver:
return special_json
def run_ansible_playbook(self, benchmark, extra_vars):
- logging.info(extra_vars)
+ logger.info(extra_vars)
ansible_api = AnsibleApi()
ansible_api.execute_playbook('./data/hosts',
'./benchmarks/playbooks/{0}.yaml'.format(benchmark),
diff --git a/func/env_setup.py b/func/env_setup.py
index 3697f235..f10f8620 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)