From e03c699e862071fc20cef4fceac022ca4d34c397 Mon Sep 17 00:00:00 2001 From: Samuel de Medeiros Queiroz Date: Sat, 21 Feb 2015 00:52:31 -0300 Subject: [PATCH] Standardize notifications types as constants Constants are used to define notifications entity types on managers. Change-Id: I18555c58a08f7867cd60d3b2e74a9135c1fe686b --- keystone/assignment/core.py | 8 +++++--- keystone/resource/core.py | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/keystone/assignment/core.py b/keystone/assignment/core.py index 63f241d8ac..4ec66268aa 100644 --- a/keystone/assignment/core.py +++ b/keystone/assignment/core.py @@ -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) diff --git a/keystone/resource/core.py b/keystone/resource/core.py index f11d4b981f..7b5d4771de 100644 --- a/keystone/resource/core.py +++ b/keystone/resource/core.py @@ -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