Initial class creds creation in test base class
Each test class may now define at class level which credentials
are needed, and they will be allocated automatically by the base
class. To start using this a test class that requires network
resources must implement the setup_credentials method and
define the required resources before super is invoked.
In this patch this only affects the creation of credentials
as defined in the various base classes. Other tests will be
migrated as part of the resource-cleanup bp. Note that this
changes baremetal, identity and orchestration tests to
honour the tenant isolation settings.
Partially-implements: bp resource-cleanup
Change-Id: Id36a6ebddb618a78cee7025c9537cd1e2746190e
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
index c34df48..71d905f 100644
--- a/tempest/common/credentials.py
+++ b/tempest/common/credentials.py
@@ -69,3 +69,25 @@
except exceptions.InvalidConfiguration:
is_admin = False
return is_admin
+
+
+# We want a helper function here to check and see if alt credentials
+# are available so we can do a single call from skip_checks if alt
+# creds area vailable.
+def is_alt_available():
+ # If tenant isolation is enabled admin will be available
+ if CONF.auth.allow_tenant_isolation:
+ 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)):
+ check_accounts = accounts.Accounts(name='check_alt')
+ else:
+ check_accounts = accounts.NotLockingAccounts(name='check_alt')
+ try:
+ if not check_accounts.is_multi_user():
+ return False
+ else:
+ return True
+ except exceptions.InvalidConfiguration:
+ return False