summaryrefslogtreecommitdiffstats
path: root/functest/utils/env.py
blob: 3724ec998bab90d919d2324637e995960aa5c04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python

import os
import re

import six


default_envs = {
    'NODE_NAME': 'unknown_pod',
    'CI_DEBUG': 'false',
    'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha',
    'DEPLOY_TYPE': 'virt',
    'INSTALLER_TYPE': None,
    'INSTALLER_IP': None,
    'BUILD_TAG': None,
    'OS_ENDPOINT_TYPE': None,
    'OS_AUTH_URL': None,
    'CONFIG_FUNCTEST_YAML': os.path.normpath(os.path.join(os.path.dirname(
        os.path.abspath(__file__)), '../ci/config_functest.yaml'))
}


class Environment(object):

    def __init__(self):
        for k, v in six.iteritems(os.environ):
            self.__setattr__(k, v)
        for k, v in six.iteritems(default_envs):
            if k not in os.environ:
                self.__setattr__(k, v)
        self._set_ci_run()
        self._set_ci_loop()

    def _set_ci_run(self):
        if self.BUILD_TAG:
            self.IS_CI_RUN = True
        else:
            self.IS_CI_RUN = False

    def _set_ci_loop(self):
        if self.BUILD_TAG and re.search("daily", self.BUILD_TAG):
            self.CI_LOOP = "daily"
        else:
            self.CI_LOOP = "weekly"


ENV = Environment()