Verify tenant in static accounts.
Primary, alt, admin, roles accounts must be from
different projects.
Added tenant verification for tests.
Related-PROD: https://mirantis.jira.com/browse/PRODX-18762
Change-Id: I3c8d1b4eac1ee3cd8872fe997695f85cbe7e23f5
(cherry picked from commit a4add52f70f49c6f60d20491c4918de0a0c5e030)
(cherry picked from commit 362eecfb9bec04eb3c8bbaa445c0097a7736cafe)
diff --git a/tempest/lib/common/preprov_creds.py b/tempest/lib/common/preprov_creds.py
index 8bb41d1..b7fea9b 100644
--- a/tempest/lib/common/preprov_creds.py
+++ b/tempest/lib/common/preprov_creds.py
@@ -114,7 +114,7 @@
object_storage_operator_role=None,
object_storage_reseller_admin_role=None):
hash_dict = {'roles': {}, 'creds': {}, 'networks': {},
- 'scoped_roles': {}}
+ 'scoped_roles': {}, 'projects': {}}
# Loop over the accounts read from the yaml file
for account in accounts:
@@ -180,6 +180,7 @@
'Unknown resource type %s, ignoring this field',
resource
)
+ hash_dict = cls._append_project(account, temp_hash_key, hash_dict)
return hash_dict
def is_multi_user(self):
@@ -246,6 +247,7 @@
hashes = temp_list
else:
hashes = self.hash_dict['creds'].keys()
+ hashes = self._exclude_used_projects(hashes)
# NOTE(mtreinish): admin is a special case because of the increased
# privilege set which could potentially cause issues on tests where
# that is not expected. So unless the admin role isn't specified do
@@ -479,3 +481,16 @@
for attr in domain_fields.intersection(set(creds_dict.keys())):
creds_dict.pop(attr)
return creds_dict
+
+ @classmethod
+ def _append_project(cls, account, account_hash, hash_dict):
+ key_to_add = account.get('project_name') or account.get('tenant_name')
+ hash_dict['projects'].setdefault(key_to_add, [])
+ hash_dict['projects'][key_to_add].append(account_hash)
+ return hash_dict
+
+ def _exclude_used_projects(self, hashes):
+ excluded_accounts = []
+ for project in [cred.tenant_name for cred in self._creds.values()]:
+ excluded_accounts.extend(self.hash_dict['projects'][project])
+ return hashes - set(excluded_accounts)