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/opnfv_tests/openstack/snaps/snaps_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'functest/opnfv_tests/openstack/snaps/snaps_utils.py') diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py index 6bc50ad6..59bd063c 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py @@ -10,6 +10,7 @@ """Some common utils wrapping snaps functions """ from functest.utils.constants import CONST +from functest.utils import env from snaps.openstack.tests import openstack_tests from snaps.openstack.utils import neutron_utils, nova_utils @@ -24,8 +25,8 @@ def get_ext_net_name(os_creds): """ neutron = neutron_utils.neutron_client(os_creds) ext_nets = neutron_utils.get_external_networks(neutron) - if hasattr(CONST, 'EXTERNAL_NETWORK'): - extnet_config = CONST.__getattribute__('EXTERNAL_NETWORK') + if env.get('EXTERNAL_NETWORK'): + extnet_config = env.get('EXTERNAL_NETWORK') for ext_net in ext_nets: if ext_net.name == extnet_config: return extnet_config -- cgit 1.2.3-korg