From 206d2d48fab45072af4660f9692dd5b8643b4c4d Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Mon, 8 Feb 2010 14:21:46 +0100 Subject: 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). --- ipaserver/install/bindinstance.py | 52 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'ipaserver/install/bindinstance.py') diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 13e9e16c..105cf4e2 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()) -- cgit