diff options
author | 2016-04-27 16:28:55 +0200 | |
---|---|---|
committer | 2016-04-27 15:09:38 +0000 | |
commit | a2c96362067e32d569b8a02ca0ec022195e54b35 (patch) | |
tree | 43a9ae5642b290259024cf36ac7fed48a41a7277 /testcases/vIMS/CI/vIMS.py | |
parent | 9c13968cdb32806da738dc520d45270e019f0ad3 (diff) |
Replace all the loggers by the functest logger module
JIRA: FUNCTEST-228
Change-Id: If7a3c8cb08e9fbdf155fc5eff5330f79e5f8d234
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/vIMS/CI/vIMS.py')
-rw-r--r-- | testcases/vIMS/CI/vIMS.py | 81 |
1 files changed, 33 insertions, 48 deletions
diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py index 19aa0271..f8849433 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']) |