summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-09 07:33:51 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-09 10:05:11 -0500
commitd9d96ee0b39de247e83beb92ec24f6adc02a4698 (patch)
treeb713f4689cb9d9a4567e71e05216bfed29239e97 /server
parent74447bc4656959eb3e3b55eeb9dfe66bffb104b5 (diff)
downloadsssd-d9d96ee0b39de247e83beb92ec24f6adc02a4698.tar.gz
sssd-d9d96ee0b39de247e83beb92ec24f6adc02a4698.tar.xz
sssd-d9d96ee0b39de247e83beb92ec24f6adc02a4698.zip
SSSDConfig.get_domain() should properly detect active state
Diffstat (limited to 'server')
-rw-r--r--server/config/SSSDConfig.py29
-rw-r--r--server/config/SSSDConfigTest.py1
2 files changed, 30 insertions, 0 deletions
diff --git a/server/config/SSSDConfig.py b/server/config/SSSDConfig.py
index f00824d59..10d2f02a1 100644
--- a/server/config/SSSDConfig.py
+++ b/server/config/SSSDConfig.py
@@ -1238,6 +1238,9 @@ class SSSDConfig(SSSDChangeConf):
for opt in self.strip_comments_empty(self.options('domain/%s' % name))
if opt not in providers]
+ # Determine if this domain is currently active
+ domain.active = self.is_domain_active(name)
+
return domain
def new_domain(self, name):
@@ -1266,6 +1269,32 @@ class SSSDConfig(SSSDChangeConf):
self.save_domain(domain)
return domain
+ def is_domain_active(self, name):
+ """
+ Is a particular domain set active
+
+ name:
+ The name of the configured domain to check
+
+ === Returns ===
+ True if the domain is active, False if it is inactive
+
+ === Errors ===
+ NotInitializedError:
+ This SSSDConfig object has not had import_config() or new_config()
+ run on it yet.
+ NoDomainError:
+ No domain by this name is configured
+ """
+
+ if not self.initialized:
+ raise NotInitializedError
+
+ if name not in self.list_domains():
+ raise NoDomainError
+
+ return name in self.list_active_domains()
+
def activate_domain(self, name):
"""
Activate a configured domain
diff --git a/server/config/SSSDConfigTest.py b/server/config/SSSDConfigTest.py
index 0d42d8a67..abb2b071c 100644
--- a/server/config/SSSDConfigTest.py
+++ b/server/config/SSSDConfigTest.py
@@ -1103,6 +1103,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
domain = sssdconfig.get_domain('IPA')
self.assertTrue(isinstance(domain, SSSDConfig.SSSDDomain))
+ self.assertTrue(domain.active)
# TODO verify the contents of this domain