Add possibility to override values from INI files with env variables

Originally, environment variables were used only to replace
default values. But if the tests are run using existing INI like:

export TESTS_CONFIGS=$(pwd)/test_salt_deployed.ini

, all enviromnet variables were ignored in favor of values from INI.

This patch improves the ordering:

- environment variables now override the values from INI and from
  defaults
- on start, now are printed only the values that were read from
  environment variables

Any of the parameter from settings_oslo.py that is registered
to 'config' object, can be set using environment variables, in
upper- or lower-case:

export SALT_MASTER_HOST=192.168.100.90
export salt_master_host=192.168.100.90

Change-Id: Ia7b7d0043c633d89a582f90b0eed021d52626733
diff --git a/tcp_tests/helpers/oslo_cfg_types.py b/tcp_tests/helpers/oslo_cfg_types.py
index 8b322b7..0430076 100644
--- a/tcp_tests/helpers/oslo_cfg_types.py
+++ b/tcp_tests/helpers/oslo_cfg_types.py
@@ -102,15 +102,31 @@
     """
     def __init__(self, *args, **kwargs):
 
-        env_var_name = args[0].upper()
-        if 'default' in kwargs:
-            # Load a default environment variable with expected type
-            kwargs['default'] = args[1](
-                os.environ.get(env_var_name, kwargs.get('default', None))
-            )
+        # if 'default' in kwargs:
+        #    # Load a default environment variable with expected type
+        #    kwargs['default'] = args[1](
+        #        os.environ.get(env_var_name, kwargs.get('default', None))
+        #    )
+
         super(Cfg, self).__init__(*args, **kwargs)
 
+        env_var_name = args[0].upper()
+        if env_var_name not in os.environ:
+            env_var_name = args[0]
+        if env_var_name in os.environ:
+            self.environment_value = self.type(os.environ.get(env_var_name))
+            print('{}={}  # {}'.format(env_var_name,
+                                       self.environment_value,
+                                       kwargs.get('help', '')))
+
         # Print info about default environment variables to console
-        print('{}={}  # {}'.format(env_var_name,
-                                   kwargs.get('default', ''),
-                                   kwargs.get('help', '')))
+        # print('{}={}  # {}'.format(env_var_name,
+        #                           kwargs.get('default', ''),
+        #                           kwargs.get('help', '')))
+
+    def _get_from_namespace(self, namespace, group_name):
+        res = super(Cfg, self)._get_from_namespace(namespace, group_name)
+        # Use the value from enviroment variable instead of config
+        if hasattr(self, 'environment_value'):
+            res = (self.environment_value, res[1])
+        return res