summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py15
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally-cert.py16
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py16
-rw-r--r--testcases/features/doctor.py11
-rw-r--r--testcases/features/promise.py18
-rw-r--r--testcases/vIMS/CI/vIMS.py81
-rw-r--r--testcases/vPing/CI/libraries/vPing_ssh.py18
-rw-r--r--testcases/vPing/CI/libraries/vPing_userdata.py19
8 files changed, 47 insertions, 147 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index f106526af..b9ddbf78f 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -16,30 +16,19 @@ lanqinglong@huawei.com
import argparse
import datetime
-import logging
import os
import re
import time
import yaml
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--installer", help="Installer type")
args = parser.parse_args()
""" logging configuration """
-
-logger = logging.getLogger('onos')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-
-
-formatter = logging.Formatter('%(asctime)s - %(name)s'
- '- %(levelname)s - %(message)s')
-
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("onos").getLogger()
with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
functest_yaml = yaml.safe_load(f)
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
index 6c753b024..4acc432bc 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
@@ -16,7 +16,6 @@
import argparse
import iniparse
import json
-import logging
import os
import re
import requests
@@ -30,6 +29,7 @@ from keystoneclient.v2_0 import client as keystoneclient
from neutronclient.v2_0 import client as neutronclient
from cinderclient import client as cinderclient
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.openstack_utils as openstack_utils
@@ -74,19 +74,7 @@ else:
RALLY_STDERR = open(os.devnull, 'w')
""" logging configuration """
-logger = logging.getLogger("run_rally")
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter("%(asctime)s - %(name)s - "
- "%(levelname)s - %(message)s")
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("run_rally").getLogger()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
if not os.path.exists(REPO_PATH):
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 68961d824..3afbbffa6 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -15,7 +15,6 @@
#
import argparse
import json
-import logging
import os
import re
import requests
@@ -28,6 +27,7 @@ import ConfigParser
import keystoneclient.v2_0.client as ksclient
from neutronclient.v2_0 import client as neutronclient
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.openstack_utils as openstack_utils
@@ -56,19 +56,7 @@ parser.add_argument("-n", "--noclean",
args = parser.parse_args()
""" logging configuration """
-logger = logging.getLogger('run_tempest')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter('%(asctime)s - %(name)s - '
- '%(levelname)s - %(message)s')
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("run_tempest").getLogger()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
diff --git a/testcases/features/doctor.py b/testcases/features/doctor.py
index e9ac3df9f..e270f7e97 100644
--- a/testcases/features/doctor.py
+++ b/testcases/features/doctor.py
@@ -14,10 +14,10 @@
#
#
-import logging
import time
import yaml
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
with open('/home/opnfv/functest/conf/config_functest.yaml') as f:
@@ -28,14 +28,7 @@ FUNCTEST_REPO = dirs.get('dir_repo_functest')
DOCTOR_REPO = dirs.get('dir_repo_doctor')
TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
-logger = logging.getLogger('doctor')
-logger.setLevel(logging.DEBUG)
-ch = logging.StreamHandler()
-ch.setLevel(logging.DEBUG)
-formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - ' +
- '%(message)s')
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("doctor").getLogger()
def main():
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index 179ebca55..804cd6655 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -11,7 +11,6 @@
#
import argparse
import json
-import logging
import os
import requests
import subprocess
@@ -22,6 +21,7 @@ import glanceclient.client as glclient
import novaclient.client as nvclient
from neutronclient.v2_0 import client as ntclient
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.openstack_utils as openstack_utils
@@ -61,21 +61,7 @@ GLANCE_IMAGE_PATH = functest_yaml.get('general').get('directories').get(
'dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME
""" logging configuration """
-logger = logging.getLogger('Promise')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter('%(asctime)s - %(name)s'
- '- %(levelname)s - %(message)s')
-
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("promise").getLogger()
def main():
diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py
index 19aa0271f..f88494330 100644
--- a/testcases/vIMS/CI/vIMS.py
+++ b/testcases/vIMS/CI/vIMS.py
@@ -14,7 +14,6 @@
import argparse
import datetime
import json
-import logging
import os
import pprint
import requests
@@ -30,8 +29,9 @@ from neutronclient.v2_0 import client as ntclient
import clearwater
import orchestrator
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
-import functest.utils.openstack_utils as openstack_utils
+import functest.utils.openstack_utils as os_utils
pp = pprint.PrettyPrinter(indent=4)
@@ -48,18 +48,7 @@ parser.add_argument("-n", "--noclean",
args = parser.parse_args()
""" logging configuration """
-logger = logging.getLogger('vIMS')
-logger.setLevel(logging.INFO)
-
-ch = logging.StreamHandler()
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-formatter = logging.Formatter(
- '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("vIMS").getLogger()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
if not os.path.exists(REPO_PATH):
@@ -114,7 +103,7 @@ def download_and_add_image_on_glance(glance, image_name, image_url):
logger.error("Failed to download image %s" % file_name)
return False
- image = openstack_utils.create_glance_image(
+ image = os_utils.create_glance_image(
glance, image_name, dest_path + file_name)
if not image:
logger.error("Failed to upload image on glance")
@@ -278,19 +267,19 @@ def main():
if not os.path.exists(VIMS_DATA_DIR):
os.makedirs(VIMS_DATA_DIR)
- ks_creds = openstack_utils.get_credentials("keystone")
- nv_creds = openstack_utils.get_credentials("nova")
- nt_creds = openstack_utils.get_credentials("neutron")
+ ks_creds = os_utils.get_credentials("keystone")
+ nv_creds = os_utils.get_credentials("nova")
+ nt_creds = os_utils.get_credentials("neutron")
logger.info("Prepare OpenStack plateform (create tenant and user)")
keystone = ksclient.Client(**ks_creds)
- user_id = openstack_utils.get_user_id(keystone, ks_creds['username'])
+ user_id = os_utils.get_user_id(keystone, ks_creds['username'])
if user_id == '':
step_failure("init", "Error : Failed to get id of " +
ks_creds['username'])
- tenant_id = openstack_utils.create_tenant(
+ tenant_id = os_utils.create_tenant(
keystone, TENANT_NAME, TENANT_DESCRIPTION)
if tenant_id == '':
step_failure("init", "Error : Failed to create " +
@@ -300,17 +289,16 @@ def main():
role_id = ''
for role_name in roles_name:
if role_id == '':
- role_id = openstack_utils.get_role_id(keystone, role_name)
+ role_id = os_utils.get_role_id(keystone, role_name)
if role_id == '':
logger.error("Error : Failed to get id for %s role" % role_name)
- if not openstack_utils.add_role_user(keystone, user_id,
- role_id, tenant_id):
+ if not os_utils.add_role_user(keystone, user_id, role_id, tenant_id):
logger.error("Error : Failed to add %s on tenant" %
ks_creds['username'])
- user_id = openstack_utils.create_user(
+ user_id = os_utils.create_user(
keystone, TENANT_NAME, TENANT_NAME, None, tenant_id)
if user_id == '':
logger.error("Error : Failed to create %s user" % TENANT_NAME)
@@ -339,7 +327,7 @@ def main():
image_name = IMAGES[img]['image_name']
image_url = IMAGES[img]['image_url']
- image_id = openstack_utils.get_image_id(glance, image_name)
+ image_id = os_utils.get_image_id(glance, image_name)
if image_id == '':
logger.info("""%s image doesn't exist on glance repository. Try
@@ -357,7 +345,7 @@ def main():
logger.info("Update security group quota for this tenant")
neutron = ntclient.Client(**nt_creds)
- if not openstack_utils.update_sg_quota(neutron, tenant_id, 50, 100):
+ if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100):
step_failure(
"init",
"Failed to update security group quota for tenant " + TENANT_NAME)
@@ -365,14 +353,13 @@ def main():
logger.info("Update cinder quota for this tenant")
from cinderclient import client as cinderclient
- creds_cinder = openstack_utils.get_credentials("cinder")
+ creds_cinder = os_utils.get_credentials("cinder")
cinder_client = cinderclient.Client('1', creds_cinder['username'],
creds_cinder['api_key'],
creds_cinder['project_id'],
creds_cinder['auth_url'],
service_type="volume")
- if not openstack_utils.update_cinder_quota(cinder_client, tenant_id,
- 20, 10, 150):
+ if not os_utils.update_cinder_quota(cinder_client, tenant_id, 20, 10, 150):
step_failure(
"init", "Failed to update cinder quota for tenant " + TENANT_NAME)
@@ -388,18 +375,17 @@ def main():
nova = nvclient.Client("2", **nv_creds)
flavor_name = "m1.medium"
- flavor_id = openstack_utils.get_flavor_id(nova, flavor_name)
+ flavor_id = os_utils.get_flavor_id(nova, flavor_name)
for requirement in CFY_MANAGER_REQUIERMENTS:
if requirement == 'ram_min':
- flavor_id = openstack_utils.get_flavor_id_by_ram_range(
+ flavor_id = os_utils.get_flavor_id_by_ram_range(
nova, CFY_MANAGER_REQUIERMENTS['ram_min'], 8196)
if flavor_id == '':
logger.error(
"Failed to find %s flavor. "
"Try with ram range default requirement !" % flavor_name)
- flavor_id = openstack_utils.get_flavor_id_by_ram_range(
- nova, 4000, 8196)
+ flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)
if flavor_id == '':
step_failure("orchestrator",
@@ -408,10 +394,10 @@ def main():
cfy.set_flavor_id(flavor_id)
image_name = "centos_7"
- image_id = openstack_utils.get_image_id(glance, image_name)
+ image_id = os_utils.get_image_id(glance, image_name)
for requirement in CFY_MANAGER_REQUIERMENTS:
if requirement == 'os_image':
- image_id = openstack_utils.get_image_id(
+ image_id = os_utils.get_image_id(
glance, CFY_MANAGER_REQUIERMENTS['os_image'])
if image_id == '':
@@ -421,7 +407,7 @@ def main():
cfy.set_image_id(image_id)
- ext_net = openstack_utils.get_external_net(neutron)
+ ext_net = os_utils.get_external_net(neutron)
if not ext_net:
step_failure("orchestrator", "Failed to get external network")
@@ -465,18 +451,17 @@ def main():
nova = nvclient.Client("2", **nv_creds)
flavor_name = "m1.small"
- flavor_id = openstack_utils.get_flavor_id(nova, flavor_name)
+ flavor_id = os_utils.get_flavor_id(nova, flavor_name)
for requirement in CW_REQUIERMENTS:
if requirement == 'ram_min':
- flavor_id = openstack_utils.get_flavor_id_by_ram_range(
+ flavor_id = os_utils.get_flavor_id_by_ram_range(
nova, CW_REQUIERMENTS['ram_min'], 8196)
if flavor_id == '':
logger.error(
"Failed to find %s flavor. Try with ram range "
"default requirement !" % flavor_name)
- flavor_id = openstack_utils.get_flavor_id_by_ram_range(
- nova, 4000, 8196)
+ flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196)
if flavor_id == '':
step_failure(
@@ -485,10 +470,10 @@ def main():
cw.set_flavor_id(flavor_id)
image_name = "ubuntu_14.04"
- image_id = openstack_utils.get_image_id(glance, image_name)
+ image_id = os_utils.get_image_id(glance, image_name)
for requirement in CW_REQUIERMENTS:
if requirement == 'os_image':
- image_id = openstack_utils.get_image_id(
+ image_id = os_utils.get_image_id(
glance, CW_REQUIERMENTS['os_image'])
if image_id == '':
@@ -498,7 +483,7 @@ def main():
cw.set_image_id(image_id)
- ext_net = openstack_utils.get_external_net(neutron)
+ ext_net = os_utils.get_external_net(neutron)
if not ext_net:
step_failure("vIMS", "Failed to get external network")
@@ -537,29 +522,29 @@ def main():
if args.noclean:
exit(0)
- ks_creds = openstack_utils.get_credentials("keystone")
+ ks_creds = os_utils.get_credentials("keystone")
keystone = ksclient.Client(**ks_creds)
logger.info("Removing %s tenant .." % CFY_INPUTS['keystone_tenant_name'])
- tenant_id = openstack_utils.get_tenant_id(
+ tenant_id = os_utils.get_tenant_id(
keystone, CFY_INPUTS['keystone_tenant_name'])
if tenant_id == '':
logger.error("Error : Failed to get id of %s tenant" %
CFY_INPUTS['keystone_tenant_name'])
else:
- if not openstack_utils.delete_tenant(keystone, tenant_id):
+ if not os_utils.delete_tenant(keystone, tenant_id):
logger.error("Error : Failed to remove %s tenant" %
CFY_INPUTS['keystone_tenant_name'])
logger.info("Removing %s user .." % CFY_INPUTS['keystone_username'])
- user_id = openstack_utils.get_user_id(
+ user_id = os_utils.get_user_id(
keystone, CFY_INPUTS['keystone_username'])
if user_id == '':
logger.error("Error : Failed to get id of %s user" %
CFY_INPUTS['keystone_username'])
else:
- if not openstack_utils.delete_user(keystone, user_id):
+ if not os_utils.delete_user(keystone, user_id):
logger.error("Error : Failed to remove %s user" %
CFY_INPUTS['keystone_username'])
diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py
index acf3065db..23b3d46f8 100644
--- a/testcases/vPing/CI/libraries/vPing_ssh.py
+++ b/testcases/vPing/CI/libraries/vPing_ssh.py
@@ -15,7 +15,6 @@
#
import argparse
import datetime
-import logging
import os
import paramiko
import pprint
@@ -29,6 +28,7 @@ from neutronclient.v2_0 import client as neutronclient
from keystoneclient.v2_0 import client as keystoneclient
from glanceclient import client as glanceclient
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.openstack_utils as openstack_utils
@@ -45,22 +45,8 @@ parser.add_argument("-r", "--report",
args = parser.parse_args()
""" logging configuration """
+logger = ft_logger.Logger("vping_ssh").getLogger()
-logger = logging.getLogger('vPing_ssh')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter('%(asctime)s - %(name)s'
- '- %(levelname)s - %(message)s')
-
-ch.setFormatter(formatter)
-logger.addHandler(ch)
paramiko.util.log_to_file("/var/log/paramiko.log")
REPO_PATH = os.environ['repos_dir'] + '/functest/'
diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py
index 862343c1b..3e69ddfe0 100644
--- a/testcases/vPing/CI/libraries/vPing_userdata.py
+++ b/testcases/vPing/CI/libraries/vPing_userdata.py
@@ -16,7 +16,6 @@
import argparse
import datetime
-import logging
import os
import pprint
import time
@@ -27,6 +26,7 @@ from neutronclient.v2_0 import client as neutronclient
from keystoneclient.v2_0 import client as keystoneclient
from glanceclient import client as glanceclient
+import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.openstack_utils as openstack_utils
@@ -43,22 +43,7 @@ parser.add_argument("-r", "--report",
args = parser.parse_args()
""" logging configuration """
-
-logger = logging.getLogger('vPing_userdata')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter('%(asctime)s - %(name)s'
- '- %(levelname)s - %(message)s')
-
-ch.setFormatter(formatter)
-logger.addHandler(ch)
+logger = ft_logger.Logger("vping_userdata").getLogger()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
if not os.path.exists(REPO_PATH):