summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/bindinstance.py
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2010-02-08 14:21:46 +0100
committerRob Crittenden <rcritten@redhat.com>2010-02-09 16:30:06 -0500
commit206d2d48fab45072af4660f9692dd5b8643b4c4d (patch)
tree118cd597bc3cf67f947a910c7e610840d7359630 /ipaserver/install/bindinstance.py
parentb05f94fb4c747d924fe5c89472663ba9226d2db1 (diff)
downloadfreeipa-206d2d48fab45072af4660f9692dd5b8643b4c4d.tar.gz
freeipa-206d2d48fab45072af4660f9692dd5b8643b4c4d.tar.xz
freeipa-206d2d48fab45072af4660f9692dd5b8643b4c4d.zip
Get rid of ipapython.config in ipa-replica-prepare
Also get rid of functions get_host_name(), get_realm_name() and get_domain_name(). They used the old ipapython.config. Instead, use the variables from api.env. We also change them to bootstrap() and finalize() correctly. Additionally, we add the dns_container_exists() function that will be used in ipa-replica-prepare (next patch).
Diffstat (limited to 'ipaserver/install/bindinstance.py')
-rw-r--r--ipaserver/install/bindinstance.py52
1 files changed, 27 insertions, 25 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 13e9e16c7..105cf4e21 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -54,6 +54,31 @@ def check_inst(unattended):
return True
+def dns_container_exists(fqdn, realm):
+ """
+ Test whether the dns container exists.
+ """
+
+ def object_exists(dn):
+ """
+ Test whether the given object exists in LDAP.
+ """
+ try:
+ server.search_ext_s(dn, ldap.SCOPE_BASE)
+ except ldap.NO_SUCH_OBJECT:
+ return False
+ else:
+ return True
+
+ server = ldap.initialize("ldap://" + fqdn)
+ server.simple_bind_s()
+
+ suffix = util.realm_to_suffix(realm)
+ ret = object_exists("cn=dns,%s" % suffix)
+ server.unbind_s()
+
+ return ret
+
def get_reverse_zone(ip_address):
tmp = ip_address.split(".")
tmp.reverse()
@@ -155,7 +180,8 @@ class BindInstance(service.Service):
except:
pass
- self.__add_zone_steps()
+ if not dns_container_exists(self.fqdn, self.suffix):
+ self.step("adding DNS container", self.__setup_dns_container)
self.step("setting up our zone", self.__setup_zone)
self.step("setting up reverse zone", self.__setup_reverse_zone)
@@ -168,30 +194,6 @@ class BindInstance(service.Service):
self.step("changing resolv.conf to point to ourselves", self.__setup_resolv_conf)
self.start_creation("Configuring named:")
- def __add_zone_steps(self):
- """
- Add a DNS container if it doesn't exist.
- """
-
- def object_exists(dn):
- """
- Test whether the given object exists in LDAP.
- """
- try:
- server.search_ext_s(dn, ldap.SCOPE_BASE)
- except ldap.NO_SUCH_OBJECT:
- return False
- else:
- return True
-
- server = ldap.initialize("ldap://" + self.fqdn)
- server.simple_bind_s()
-
- if not object_exists("cn=dns,%s" % self.suffix):
- self.step("adding DNS container", self.__setup_dns_container)
-
- server.unbind_s()
-
def __start(self):
try:
self.backup_state("running", self.is_running())