Adds method to verify multiple tenants are available
Based on is_multi_user()
Change-Id: Ifeceb3244a87c378e70f387dde1d22bc20c9f612
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index 88e8ced..66285e4 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -65,6 +65,9 @@
else:
return len(self.hash_dict) > 1
+ def is_multi_tenant(self):
+ return self.is_multi_user()
+
def _create_hash_file(self, hash_string):
path = os.path.join(os.path.join(self.accounts_dir, hash_string))
if not os.path.isfile(path):
@@ -149,13 +152,13 @@
to preserve the current behaviour of the serial tempest run.
"""
- def is_multi_user(self):
+ def _unique_creds(self, cred_arg=None):
+ """Verify that the configured credentials are valid and distinct """
if self.use_default_creds:
- # Verify that the configured users are valid and distinct
try:
user = self.get_primary_creds()
alt_user = self.get_alt_creds()
- return user.username != alt_user.username
+ return getattr(user, cred_arg) != getattr(alt_user, cred_arg)
except exceptions.InvalidCredentials as ic:
msg = "At least one of the configured credentials is " \
"not valid: %s" % ic.message
@@ -164,6 +167,12 @@
# TODO(andreaf) Add a uniqueness check here
return len(self.hash_dict) > 1
+ def is_multi_user(self):
+ return self._unique_creds('username')
+
+ def is_multi_tenant(self):
+ return self._unique_creds('tenant_id')
+
def get_creds(self, id):
try:
# No need to sort the dict as within the same python process
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index b09c964..c5be0c0 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -48,3 +48,7 @@
@abc.abstractmethod
def is_multi_user(self):
return
+
+ @abc.abstractmethod
+ def is_multi_tenant(self):
+ return
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 2d16107..228e47c 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -354,3 +354,6 @@
def is_multi_user(self):
return True
+
+ def is_multi_tenant(self):
+ return True