Reference driver methods through the Manager

The driver methods should be referenced through the Manager when
possible so that the Manager can modify the driver call or return
value if we need to.

Change-Id: I66bda7a9b8a6a2cce6d9999e26f14a78a0ae4fef
This commit is contained in:
Brant Knudson 2016-01-07 14:08:38 -06:00
parent 7f485562f9
commit c937b765ad
4 changed files with 14 additions and 11 deletions

View File

@ -327,9 +327,8 @@ class Manager(manager.Manager):
# membership recover the endpoint group
self.resource_api.get_project(project_id)
try:
refs = self.driver.list_endpoint_groups_for_project(
project_id)
endpoint_groups = [self.driver.get_endpoint_group(
refs = self.list_endpoint_groups_for_project(project_id)
endpoint_groups = [self.get_endpoint_group(
ref['endpoint_group_id']) for ref in refs]
return endpoint_groups
except exception.EndpointGroupNotFound:
@ -337,7 +336,7 @@ class Manager(manager.Manager):
def get_endpoints_filtered_by_endpoint_group(self, endpoint_group_id):
endpoints = self.list_endpoints()
filters = self.driver.get_endpoint_group(endpoint_group_id)['filters']
filters = self.get_endpoint_group(endpoint_group_id)['filters']
filtered_endpoints = []
for endpoint in endpoints:

View File

@ -158,7 +158,7 @@ class Manager(manager.Manager):
matching_endpoints = []
endpoints = self.catalog_api.list_endpoints()
regions = self.catalog_api.list_regions()
for ref in self.driver.list_associations_for_policy(policy_id):
for ref in self.list_associations_for_policy(policy_id):
if ref.get('endpoint_id') is not None:
matching_endpoints.append(
_get_endpoint(ref['endpoint_id'], policy_id))
@ -212,7 +212,7 @@ class Manager(manager.Manager):
regions_examined = []
while region_id is not None:
try:
ref = self.driver.get_policy_association(
ref = self.get_policy_association(
service_id=endpoint['service_id'],
region_id=region_id)
return ref['policy_id']
@ -237,7 +237,7 @@ class Manager(manager.Manager):
# this endpoint.
try:
ref = self.driver.get_policy_association(endpoint_id=endpoint_id)
ref = self.get_policy_association(endpoint_id=endpoint_id)
return _get_policy(ref['policy_id'], endpoint_id)
except exception.PolicyAssociationNotFound: # nosec
# There wasn't a policy explicitly defined for this endpoint,
@ -254,7 +254,7 @@ class Manager(manager.Manager):
# Finally, just check if there is one for the service.
try:
ref = self.driver.get_policy_association(
ref = self.get_policy_association(
service_id=endpoint['service_id'])
return _get_policy(ref['policy_id'], endpoint_id)
except exception.PolicyAssociationNotFound: # nosec

View File

@ -276,6 +276,7 @@ class Manager(manager.Manager):
'projects') % project_id)
def update_project(self, tenant_id, tenant, initiator=None):
# Use the driver directly to prevent using old cached value.
original_tenant = self.driver.get_project(tenant_id)
tenant = tenant.copy()
@ -325,6 +326,7 @@ class Manager(manager.Manager):
return ret
def delete_project(self, tenant_id, initiator=None):
# Use the driver directly to prevent using old cached value.
project = self.driver.get_project(tenant_id)
if project['is_domain'] and project['enabled']:
raise exception.ValidationError(
@ -332,7 +334,7 @@ class Manager(manager.Manager):
'domain. Please disable the project %s first.')
% project.get('id'))
if not self.driver.is_leaf_project(tenant_id):
if not self.is_leaf_project(tenant_id):
raise exception.ForbiddenAction(
action=_('cannot delete the project %s since it is not '
'a leaf in the hierarchy.') % tenant_id)
@ -532,6 +534,7 @@ class Manager(manager.Manager):
def update_domain(self, domain_id, domain, initiator=None):
self.assert_domain_not_federated(domain_id, domain)
# Use the driver directly to prevent using old cached value.
original_domain = self.driver.get_domain(domain_id)
if (CONF.resource.domain_name_url_safe != 'off' and
'name' in domain and domain['name'] != original_domain['name'] and
@ -560,6 +563,7 @@ class Manager(manager.Manager):
raise exception.ForbiddenAction(action=_('delete the default '
'domain'))
# Use the driver directly to prevent using old cached value.
domain = self.driver.get_domain(domain_id)
# To help avoid inadvertent deletes, we insist that the domain

View File

@ -243,7 +243,7 @@ class Manager(manager.Manager):
self.revoke_api.check_token(token_values)
def check_revocation(self, token):
version = self.driver.get_token_version(token)
version = self.get_token_version(token)
if version == V2:
return self.check_revocation_v2(token)
else:
@ -275,7 +275,7 @@ class Manager(manager.Manager):
if not self._needs_persistence:
return self.driver.validate_v3_token(token_id)
token_ref = self._persistence.get_token(token_id)
version = self.driver.get_token_version(token_ref)
version = self.get_token_version(token_ref)
if version == self.V3:
return self.driver.validate_v3_token(token_ref)
elif version == self.V2: