Stop forcing non default operator role
[functest.git] / functest / opnfv_tests / openstack / snaps / snaps_utils.py
index 4b1c935..f4a6e2e 100644 (file)
@@ -7,13 +7,15 @@
 #
 # http://www.apache.org/licenses/LICENSE-2.0
 
-"""Some common utils wrapping snaps functions """
-
-from functest.utils.constants import CONST
-from functest.utils import env
+"""Some common utils wrapping snaps functions"""
 
 from snaps.openstack.tests import openstack_tests
-from snaps.openstack.utils import neutron_utils, nova_utils
+from snaps.openstack.utils import neutron_utils
+from snaps.openstack.utils import nova_utils
+
+from functest.utils import config
+from functest.utils import constants
+from functest.utils import env
 
 
 def get_ext_net_name(os_creds):
@@ -44,18 +46,21 @@ def get_active_compute_cnt(os_creds):
     return len(computes)
 
 
-def get_credentials(proxy_settings_str=None, ssh_proxy_cmd=None):
+def get_credentials(proxy_settings_str=None, ssh_proxy_cmd=None,
+                    overrides=None):
     """
     Returns snaps OSCreds object instance
     :param: proxy_settings_str: proxy settings string <host>:<port>
     :param: ssh_proxy_cmd: the SSH proxy command for the environment
+    :param overrides: dict() values to override in credentials
     :return: an instance of snaps OSCreds object
     """
-    creds_override = None
-    if hasattr(CONST, 'snaps_os_creds_override'):
-        creds_override = getattr(CONST, 'snaps_os_creds_override')
+    creds_override = {}
+    if hasattr(config.CONF, 'snaps_os_creds_override'):
+        creds_override.update(getattr(config.CONF, 'snaps_os_creds_override'))
+    if overrides:
+        creds_override.update(overrides)
     os_creds = openstack_tests.get_credentials(
-        os_env_file=getattr(CONST, 'env_file'),
-        proxy_settings_str=proxy_settings_str, ssh_proxy_cmd=ssh_proxy_cmd,
-        overrides=creds_override)
+        os_env_file=constants.ENV_FILE, proxy_settings_str=proxy_settings_str,
+        ssh_proxy_cmd=ssh_proxy_cmd, overrides=creds_override)
     return os_creds