From d589e4e5345ed82c68d9a011ac89f8cdbefe2ca3 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Wed, 14 Feb 2018 16:02:53 +0100 Subject: Get properly env vars or their default values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It defines env.get() as an unique way to get Functest env vars or their default values. It can be considered as a wrapper above os.environ. It enforces backward compatibility via CONST which mustn't be used for that purpose. It should be noted that it also stops using CONST for getting OpenStack env vars. Change-Id: I333dc1afbc0123166a7eaff8b551370098efa341 Signed-off-by: Cédric Ollivier --- functest/api/resources/v1/testcases.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'functest/api') diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py index bc21c6fa..064661c8 100644 --- a/functest/api/resources/v1/testcases.py +++ b/functest/api/resources/v1/testcases.py @@ -11,22 +11,23 @@ Resources to handle testcase related requests """ +import ConfigParser import logging import os import re -import pkg_resources import socket import uuid -import ConfigParser from flask import jsonify from flasgger.utils import swag_from +import pkg_resources from functest.api.base import ApiResource from functest.api.common import api_utils, thread from functest.cli.commands.cli_testcase import Testcase from functest.api.database.v1.handlers import TasksHandler from functest.utils.constants import CONST +from functest.utils import env import functest.utils.functest_utils as ft_utils LOGGER = logging.getLogger(__name__) @@ -127,10 +128,10 @@ class V1Testcase(ApiResource): result = 'FAIL' env_info = { - 'installer': os.environ.get('INSTALLER_TYPE', None), - 'scenario': os.environ.get('DEPLOY_SCENARIO', None), - 'build_tag': os.environ.get('BUILD_TAG', None), - 'ci_loop': os.environ.get('CI_LOOP', 'daily') + 'installer': env.get('INSTALLER_TYPE'), + 'scenario': env.get('DEPLOY_SCENARIO'), + 'build_tag': env.get('BUILD_TAG'), + 'ci_loop': env.get('CI_LOOP') } result = { 'task_id': args.get('task_id'), -- cgit 1.2.3-korg