summaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/resource/config_backends
diff options
context:
space:
mode:
Diffstat (limited to 'keystone-moon/keystone/resource/config_backends')
-rw-r--r--keystone-moon/keystone/resource/config_backends/sql.py35
1 files changed, 34 insertions, 1 deletions
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)