-import os
-import re
-
-default_envs = {
- 'NODE_NAME': 'unknown_pod',
- 'CI_DEBUG': 'true',
- '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
-}
+#!/usr/bin/env python
+# Copyright (c) 2018 Orange and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
-class Environment(object):
+# pylint: disable=missing-docstring
- def __init__(self):
- for k, v in os.environ.iteritems():
- self.__setattr__(k, v)
- for k, v in default_envs.iteritems():
- if k not in os.environ:
- self.__setattr__(k, v)
- self._set_ci_run()
- self._set_ci_loop()
+import os
+
+import prettytable
+from xtesting.utils import env
+
+INPUTS = {
+ 'EXTERNAL_NETWORK': None,
+ 'CI_LOOP': env.INPUTS['CI_LOOP'],
+ 'DEPLOY_SCENARIO': env.INPUTS['DEPLOY_SCENARIO'],
+ 'INSTALLER_TYPE': env.INPUTS['INSTALLER_TYPE'],
+ 'SDN_CONTROLLER_IP': None,
+ 'SDN_CONTROLLER_USER': 'admin',
+ 'SDN_CONTROLLER_PASSWORD': 'admin',
+ 'SDN_CONTROLLER_WEBPORT': '8080',
+ 'SDN_CONTROLLER_RESTCONFPORT': '8181',
+ 'BUILD_TAG': env.INPUTS['BUILD_TAG'],
+ 'NODE_NAME': env.INPUTS['NODE_NAME'],
+ 'POD_ARCH': None,
+ 'TEST_DB_URL': env.INPUTS['TEST_DB_URL'],
+ 'ENERGY_RECORDER_API_URL': env.INPUTS['ENERGY_RECORDER_API_URL'],
+ 'ENERGY_RECORDER_API_USER': env.INPUTS['ENERGY_RECORDER_API_USER'],
+ 'ENERGY_RECORDER_API_PASSWORD': env.INPUTS['ENERGY_RECORDER_API_PASSWORD'],
+ 'VOLUME_DEVICE_NAME': 'vdb',
+ 'NAMESERVER': '8.8.8.8',
+ 'NEW_USER_ROLE': 'Member'
+}
- 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"
+def get(env_var):
+ if env_var not in INPUTS.keys():
+ return os.environ.get(env_var, None)
+ return os.environ.get(env_var, INPUTS[env_var])
-ENV = Environment()
+def string():
+ msg = prettytable.PrettyTable(
+ header_style='upper', padding_width=5,
+ field_names=['env var', 'value'])
+ for env_var in INPUTS:
+ msg.add_row([env_var, get(env_var) if get(env_var) else ''])
+ return msg