Standardize notifications types as constants

Constants are used to define notifications
entity types on managers.

Change-Id: I18555c58a08f7867cd60d3b2e74a9135c1fe686b
This commit is contained in:
Samuel de Medeiros Queiroz 2015-02-21 00:52:31 -03:00
parent b5abd5e242
commit e03c699e86
2 changed files with 10 additions and 7 deletions

View File

@ -902,6 +902,8 @@ class Driver(object):
class RoleManager(manager.Manager):
"""Default pivot point for the Role backend."""
_ROLE = 'role'
def __init__(self):
# If there is a specific driver specified for role, then use it.
# Otherwise retrieve the driver type from the assignment driver.
@ -919,7 +921,7 @@ class RoleManager(manager.Manager):
def get_role(self, role_id):
return self.driver.get_role(role_id)
@notifications.created('role')
@notifications.created(_ROLE)
def create_role(self, role_id, role):
ret = self.driver.create_role(role_id, role)
if SHOULD_CACHE(ret):
@ -930,13 +932,13 @@ class RoleManager(manager.Manager):
def list_roles(self, hints=None):
return self.driver.list_roles(hints or driver_hints.Hints())
@notifications.updated('role')
@notifications.updated(_ROLE)
def update_role(self, role_id, role):
ret = self.driver.update_role(role_id, role)
self.get_role.invalidate(self, role_id)
return ret
@notifications.deleted('role')
@notifications.deleted(_ROLE)
def delete_role(self, role_id):
try:
self.assignment_api.delete_tokens_for_role_assignments(role_id)

View File

@ -56,6 +56,7 @@ class Manager(manager.Manager):
dynamically calls the backend.
"""
_DOMAIN = 'domain'
_PROJECT = 'project'
def __init__(self):
@ -374,7 +375,7 @@ class Manager(manager.Manager):
def get_domain_by_name(self, domain_name):
return self.driver.get_domain_by_name(domain_name)
@notifications.created('domain')
@notifications.created(_DOMAIN)
def create_domain(self, domain_id, domain):
if (not self.identity_api.multiple_domains_supported and
domain_id != CONF.identity.default_domain_id):
@ -392,7 +393,7 @@ class Manager(manager.Manager):
def list_domains(self, hints=None):
return self.driver.list_domains(hints or driver_hints.Hints())
@notifications.disabled('domain', public=False)
@notifications.disabled(_DOMAIN, public=False)
def _disable_domain(self, domain_id):
"""Emit a notification to the callback system domain is been disabled.
@ -405,7 +406,7 @@ class Manager(manager.Manager):
"""
pass
@notifications.updated('domain')
@notifications.updated(_DOMAIN)
def update_domain(self, domain_id, domain):
self.assert_domain_not_federated(domain_id, domain)
original_domain = self.driver.get_domain(domain_id)
@ -421,7 +422,7 @@ class Manager(manager.Manager):
self.get_domain_by_name.invalidate(self, original_domain['name'])
return ret
@notifications.deleted('domain')
@notifications.deleted(_DOMAIN)
def delete_domain(self, domain_id):
# explicitly forbid deleting the default domain (this should be a
# carefully orchestrated manual process involving configuration