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/utils/openstack_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'functest/utils/openstack_utils.py') diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index b779997c..98da48b8 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -22,7 +22,7 @@ from novaclient import client as novaclient from keystoneclient import client as keystoneclient from neutronclient.neutron import client as neutronclient -from functest.utils.constants import CONST +from functest.utils import env import functest.utils.functest_utils as ft_utils logger = logging.getLogger(__name__) @@ -659,8 +659,8 @@ def get_private_net(neutron_client): def get_external_net(neutron_client): - if (hasattr(CONST, 'EXTERNAL_NETWORK')): - return CONST.__getattribute__('EXTERNAL_NETWORK') + if (env.get('EXTERNAL_NETWORK')): + return env.get('EXTERNAL_NETWORK') for network in neutron_client.list_networks()['networks']: if network['router:external']: return network['name'] @@ -668,9 +668,9 @@ def get_external_net(neutron_client): def get_external_net_id(neutron_client): - if (hasattr(CONST, 'EXTERNAL_NETWORK')): + if (env.get('EXTERNAL_NETWORK')): networks = neutron_client.list_networks( - name=CONST.__getattribute__('EXTERNAL_NETWORK')) + name=env.get('EXTERNAL_NETWORK')) net_id = networks['networks'][0]['id'] return net_id for network in neutron_client.list_networks()['networks']: -- cgit 1.2.3-korg