From 92d11d139e9f76d4fd76859aea78643fc32ef36b Mon Sep 17 00:00:00 2001 From: asteroide Date: Thu, 24 Sep 2015 16:27:16 +0200 Subject: Update Keystone code from repository. Change-Id: Ib3d0a06b10902fcc6d520f58e85aa617bc326d00 --- .../keystone/resource/config_backends/sql.py | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'keystone-moon/keystone/resource/config_backends') diff --git a/keystone-moon/keystone/resource/config_backends/sql.py b/keystone-moon/keystone/resource/config_backends/sql.py index e54bf22b..7c296074 100644 --- a/keystone-moon/keystone/resource/config_backends/sql.py +++ b/keystone-moon/keystone/resource/config_backends/sql.py @@ -42,7 +42,13 @@ class SensitiveConfig(sql.ModelBase, sql.ModelDictMixin): return d -class DomainConfig(resource.DomainConfigDriver): +class ConfigRegister(sql.ModelBase, sql.ModelDictMixin): + __tablename__ = 'config_register' + type = sql.Column(sql.String(64), primary_key=True) + domain_id = sql.Column(sql.String(64), nullable=False) + + +class DomainConfig(resource.DomainConfigDriverV8): def choose_table(self, sensitive): if sensitive: @@ -117,3 +123,30 @@ class DomainConfig(resource.DomainConfigDriver): if option: query = query.filter_by(option=option) query.delete(False) + + def obtain_registration(self, domain_id, type): + try: + with sql.transaction() as session: + ref = ConfigRegister(type=type, domain_id=domain_id) + session.add(ref) + return True + except sql.DBDuplicateEntry: + pass + return False + + def read_registration(self, type): + with sql.transaction() as session: + ref = session.query(ConfigRegister).get(type) + if not ref: + raise exception.ConfigRegistrationNotFound() + return ref.domain_id + + def release_registration(self, domain_id, type=None): + """Silently delete anything registered for the domain specified.""" + + with sql.transaction() as session: + query = session.query(ConfigRegister) + if type: + query = query.filter_by(type=type) + query = query.filter_by(domain_id=domain_id) + query.delete(False) -- cgit 1.2.3-korg