diff options
Diffstat (limited to 'functest/utils')
-rw-r--r-- | functest/utils/functest_logger.py | 83 | ||||
-rw-r--r-- | functest/utils/functest_utils.py | 4 | ||||
-rw-r--r-- | functest/utils/openstack/cinder.py | 7 | ||||
-rw-r--r-- | functest/utils/openstack/glance.py | 7 | ||||
-rw-r--r-- | functest/utils/openstack/keystone.py | 7 | ||||
-rw-r--r-- | functest/utils/openstack/neutron.py | 7 | ||||
-rw-r--r-- | functest/utils/openstack/nova.py | 7 | ||||
-rwxr-xr-x | functest/utils/openstack_clean.py | 5 | ||||
-rwxr-xr-x | functest/utils/openstack_snapshot.py | 5 | ||||
-rw-r--r-- | functest/utils/openstack_tacker.py | 4 | ||||
-rw-r--r-- | functest/utils/openstack_utils.py | 21 |
11 files changed, 25 insertions, 132 deletions
diff --git a/functest/utils/functest_logger.py b/functest/utils/functest_logger.py deleted file mode 100644 index ba52829f..00000000 --- a/functest/utils/functest_logger.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -# jose.lausuch@ericsson.com -# 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 -# -# Logging levels: -# Level Numeric value -# CRITICAL 50 -# ERROR 40 -# WARNING 30 -# INFO 20 -# DEBUG 10 -# NOTSET 0 -# -# Usage: -# import functest_logger as fl -# logger = fl.Logger("script_name").getLogger() -# logger.info("message to be shown with - INFO - ") -# logger.debug("message to be shown with - DEBUG -") -import logging -import logging.config -import os - -import json - -from functest.utils.constants import CONST - -ignore = ["paramiko", - "stevedore.extension", - "keystoneauth.session", - "keystoneauth.identity.v3.base", - "novaclient.v2.client", - "neutronclient.v2_0.client", - "glanceclient.common.http", - "cinderclient.v2.client", - "cinderclient.client"] - - -class Logger(object): - - instance = None - - def __new__(cls, logger_name): - if cls.instance is None: - cls.instance = object.__new__(cls) - return cls.instance - - def __init__(self, logger_name): - self.setup_logging() - self.logger = logging.getLogger(logger_name) - for module_name in ignore: - logging.getLogger(module_name).setLevel(logging.WARNING) - - def getLogger(self): - return self.logger - - def is_debug(self): - if CONST.CI_DEBUG and CONST.CI_DEBUG.lower() == "true": - return True - return False - - def setup_logging(self, default_path=CONST.dir_functest_logging_cfg, - default_level=logging.INFO, - env_key='LOG_CFG'): - path = default_path - value = os.getenv(env_key, None) - if value: - path = value - if os.path.exists(path): - with open(path, 'rt') as f: - config = json.load(f) - if (config['handlers'] and - config['handlers']['console']): - stream_level = logging.INFO - if self.is_debug(): - stream_level = logging.DEBUG - config['handlers']['console']['level'] = stream_level - logging.config.dictConfig(config) - else: - logging.basicConfig(level=default_level) diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py index 7d993cbf..3e85b9e4 100644 --- a/functest/utils/functest_utils.py +++ b/functest/utils/functest_utils.py @@ -9,6 +9,7 @@ # import functools import json +import logging import os import re import shutil @@ -24,9 +25,8 @@ import yaml from git import Repo from functest.utils import decorators -import functest.utils.functest_logger as ft_logger -logger = ft_logger.Logger("functest_utils").getLogger() +logger = logging.getLogger(__name__) # ---------------------------------------------------------- diff --git a/functest/utils/openstack/cinder.py b/functest/utils/openstack/cinder.py deleted file mode 100644 index f966468a..00000000 --- a/functest/utils/openstack/cinder.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# -# 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 -# diff --git a/functest/utils/openstack/glance.py b/functest/utils/openstack/glance.py deleted file mode 100644 index f966468a..00000000 --- a/functest/utils/openstack/glance.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# -# 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 -# diff --git a/functest/utils/openstack/keystone.py b/functest/utils/openstack/keystone.py deleted file mode 100644 index f966468a..00000000 --- a/functest/utils/openstack/keystone.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# -# 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 -# diff --git a/functest/utils/openstack/neutron.py b/functest/utils/openstack/neutron.py deleted file mode 100644 index f966468a..00000000 --- a/functest/utils/openstack/neutron.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# -# 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 -# diff --git a/functest/utils/openstack/nova.py b/functest/utils/openstack/nova.py deleted file mode 100644 index f966468a..00000000 --- a/functest/utils/openstack/nova.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -# -# 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 -# diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py index ce61fcac..29106d9e 100755 --- a/functest/utils/openstack_clean.py +++ b/functest/utils/openstack_clean.py @@ -24,13 +24,13 @@ import time +import logging import yaml -import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils from functest.utils.constants import CONST -logger = ft_logger.Logger("openstack_clean").getLogger() +logger = logging.getLogger(__name__) OS_SNAPSHOT_FILE = CONST.openstack_snapshot_file @@ -428,4 +428,5 @@ def main(): if __name__ == '__main__': + logging.basicConfig() main() diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py index e64030f7..952fb7bb 100755 --- a/functest/utils/openstack_snapshot.py +++ b/functest/utils/openstack_snapshot.py @@ -20,13 +20,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import logging import yaml -import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils from functest.utils.constants import CONST -logger = ft_logger.Logger("openstack_snapshot").getLogger() +logger = logging.getLogger(__name__) OS_SNAPSHOT_FILE = CONST.openstack_snapshot_file @@ -162,4 +162,5 @@ def main(): if __name__ == '__main__': + logging.basicConfig() main() diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py index 8327fdbe..9fd9d5c4 100644 --- a/functest/utils/openstack_tacker.py +++ b/functest/utils/openstack_tacker.py @@ -11,13 +11,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ########################################################################## +import logging from tackerclient.v1_0 import client as tackerclient -import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils import time -logger = ft_logger.Logger("tacker_utils").getLogger() +logger = logging.getLogger(__name__) def get_tacker_client(other_creds={}): diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index 929a761e..7e00a269 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import os +import logging import os.path import re import sys @@ -23,10 +23,9 @@ from novaclient import client as novaclient from keystoneclient import client as keystoneclient from neutronclient.neutron import client as neutronclient -import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils -logger = ft_logger.Logger("openstack_utils").getLogger() +logger = logging.getLogger(__name__) DEFAULT_API_VERSION = '2' DEFAULT_HEAT_API_VERSION = '1' @@ -139,11 +138,11 @@ def get_credentials_for_rally(): endpoint_types = [('internalURL', 'internal'), ('publicURL', 'public'), ('adminURL', 'admin')] - endpoint_type = os.getenv('OS_ENDPOINT_TYPE') + endpoint_type = get_endpoint_type_from_env() if endpoint_type is not None: cred_key = env_cred_dict.get('OS_ENDPOINT_TYPE') for k, v in endpoint_types: - if endpoint_type == k: + if endpoint_type == v: rally_conf[cred_key] = v region_name = os.getenv('OS_REGION_NAME') @@ -158,6 +157,14 @@ def get_credentials_for_rally(): return rally_conf +def get_endpoint_type_from_env(): + endpoint_type = os.environ.get("OS_ENDPOINT_TYPE", + os.environ.get("OS_INTERFACE")) + if endpoint_type and "URL" in endpoint_type: + endpoint_type = endpoint_type.replace("URL", "") + return endpoint_type + + def get_session_auth(other_creds={}): loader = loading.get_plugin_loader('password') creds = get_credentials(other_creds) @@ -198,7 +205,9 @@ def get_keystone_client_version(): def get_keystone_client(other_creds={}): sess = get_session(other_creds) - return keystoneclient.Client(get_keystone_client_version(), session=sess) + return keystoneclient.Client(get_keystone_client_version(), + session=sess, + interface=os.getenv('OS_INTERFACE', 'admin')) def get_nova_client_version(): |