e75b17d1a48d67a2a22b075f46351d80d3e6ccca
[functest.git] / functest / utils / env.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2018 Orange and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # pylint: disable=missing-docstring
11
12 import os
13
14 import six
15
16 INPUTS = {
17     'EXTERNAL_NETWORK': None,
18     'CI_LOOP': 'daily',
19     'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha',
20     'INSTALLER_TYPE': None,
21     'SDN_CONTROLLER_IP': None,
22     'BUILD_TAG': None,
23     'NODE_NAME': None,
24     'POD_ARCH': None,
25     'TEST_DB_URL': 'http://testresults.opnfv.org/test/api/v1/results',
26     'ENERGY_RECORDER_API_URL': 'http://energy.opnfv.fr/resources',
27     'ENERGY_RECORDER_API_USER': '',
28     'ENERGY_RECORDER_API_PASSWORD': ''
29 }
30
31
32 def get(env_var):
33     if env_var not in INPUTS.keys():
34         return os.environ.get(env_var, None)
35     return os.environ.get(env_var, INPUTS[env_var])
36
37
38 class Environment(object):  # pylint: disable=too-few-public-methods
39
40     # Backward compatibility (waiting for SDNVPN and SFC)
41     def __init__(self):
42         for key, _ in six.iteritems(INPUTS):
43             setattr(self, key, get(key))
44
45 # Backward compatibility (waiting for SDNVPN and SFC)
46 ENV = Environment()