Reuse tempest to create admin client manager
The previous code doesn't support PreProvisionedCredentialProvider, it
was getting admin credentials from tempest config file which are not set
when using test_accounts_file.
Change-Id: Ia34d08ad659b095a114c27d6d596507f7922149a
diff --git a/patrole_tempest_plugin/policy_authority.py b/patrole_tempest_plugin/policy_authority.py
index afa358a..0a50d61 100644
--- a/patrole_tempest_plugin/policy_authority.py
+++ b/patrole_tempest_plugin/policy_authority.py
@@ -21,8 +21,6 @@
from oslo_log import log as logging
from oslo_policy import policy
import stevedore
-from tempest import clients
-from tempest.common import credentials_factory as credentials
from tempest import config
from patrole_tempest_plugin.rbac_authority import RbacAuthority
@@ -34,6 +32,7 @@
class PolicyAuthority(RbacAuthority):
"""A class that uses ``oslo.policy`` for validating RBAC."""
+ os_admin = None
def __init__(self, project_id, user_id, service, extra_target_data=None):
"""Initialization of Policy Authority class.
@@ -123,12 +122,10 @@
# Cache the list of available services in memory to avoid needlessly
# doing an API call every time.
- if not hasattr(cls, 'available_services'):
- admin_mgr = clients.Manager(
- credentials.get_configured_admin_credentials())
- services_client = (admin_mgr.identity_services_v3_client
+ if not hasattr(cls, 'available_services') and cls.os_admin:
+ services_client = (cls.os_admin.identity_services_v3_client
if CONF.identity_feature_enabled.api_v3
- else admin_mgr.identity_services_client)
+ else cls.os_admin.identity_services_client)
services = services_client.list_services()['services']
cls.available_services = [s['name'] for s in services]