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
49
50
51
52
53
|
#!/usr/bin/env python
# pylint: disable=missing-docstring
import os
import re
import pkg_resources
import six
class Environment(object): # pylint: disable=too-few-public-methods
default_envs = {
'NODE_NAME': 'unknown_pod',
'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': pkg_resources.resource_filename(
'functest', 'ci/config_functest.yaml'),
'OS_INSECURE': '',
'OS_REGION_NAME': 'RegionOne'
}
def __init__(self):
for key, value in six.iteritems(os.environ):
setattr(self, key, value)
for key, value in six.iteritems(self.default_envs):
if key not in os.environ:
setattr(self, key, value)
self._set_ci_run()
if 'CI_LOOP' not in os.environ:
self._set_ci_loop()
def _set_ci_run(self):
if getattr(self, "BUILD_TAG"):
setattr(self, "IS_CI_RUN", True)
else:
setattr(self, "IS_CI_RUN", False)
def _set_ci_loop(self):
if (getattr(self, "BUILD_TAG") and
re.search("daily", getattr(self, "BUILD_TAG"))):
setattr(self, "CI_LOOP", "daily")
else:
setattr(self, "CI_LOOP", "weekly")
ENV = Environment()
|