Merge "Remove pre-check for test accounts file in credential factory"
diff --git a/tempest/common/credentials_factory.py b/tempest/common/credentials_factory.py
index 95dcafc..5d290d4 100644
--- a/tempest/common/credentials_factory.py
+++ b/tempest/common/credentials_factory.py
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
-
from oslo_concurrency import lockutils
from oslo_log import log as logging
from tempest_lib import auth
@@ -170,8 +168,7 @@
admin_creds=admin_creds,
**_get_dynamic_provider_params())
else:
- if (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ if CONF.auth.test_accounts_file:
# Most params are not relevant for pre-created accounts
return preprov_creds.PreProvisionedCredentialProvider(
name=name, identity_version=identity_version,
@@ -193,8 +190,7 @@
if CONF.auth.use_dynamic_credentials:
return is_admin
# Check whether test accounts file has the admin specified or not
- elif (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ elif CONF.auth.test_accounts_file:
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
identity_version=identity_version, name='check_admin',
**_get_preprov_provider_params())
@@ -219,8 +215,7 @@
if CONF.auth.use_dynamic_credentials:
return True
# Check whether test accounts file has the admin specified or not
- if (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ if CONF.auth.test_accounts_file:
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
identity_version=identity_version, name='check_alt',
**_get_preprov_provider_params())
diff --git a/tempest/common/preprov_creds.py b/tempest/common/preprov_creds.py
index 74cc3f0..34af31e 100644
--- a/tempest/common/preprov_creds.py
+++ b/tempest/common/preprov_creds.py
@@ -31,8 +31,13 @@
def read_accounts_yaml(path):
- with open(path, 'r') as yaml_file:
- accounts = yaml.load(yaml_file)
+ try:
+ with open(path, 'r') as yaml_file:
+ accounts = yaml.load(yaml_file)
+ except IOError:
+ raise exceptions.InvalidConfiguration(
+ 'The path for the test accounts file: %s '
+ 'could not be found' % path)
return accounts
@@ -74,7 +79,7 @@
identity_version=identity_version, name=name,
admin_role=admin_role, credentials_domain=credentials_domain)
self.test_accounts_file = test_accounts_file
- if test_accounts_file and os.path.isfile(test_accounts_file):
+ if test_accounts_file:
accounts = read_accounts_yaml(self.test_accounts_file)
self.use_default_creds = False
else: