summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2011-12-07 03:36:27 -0500
committerRob Crittenden <rcritten@redhat.com>2012-02-13 22:24:02 -0500
commita3125214c78f5ba1d32877175c026aa646c37f88 (patch)
treec30ca9c7aabc632818f352591b4749c04c6f707a
parentf2f4f57a9619a6f637e4b9a2d14853be4dec24c5 (diff)
downloadfreeipa.git-a3125214c78f5ba1d32877175c026aa646c37f88.tar.gz
freeipa.git-a3125214c78f5ba1d32877175c026aa646c37f88.tar.xz
freeipa.git-a3125214c78f5ba1d32877175c026aa646c37f88.zip
Move the nsupdate functionality to separate function in ipa-client-install.
Done as part of adding SSH support. https://fedorahosted.org/freeipa/ticket/1634
-rwxr-xr-xipa-client/ipa-install/ipa-client-install44
1 files changed, 26 insertions, 18 deletions
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 170a009c..10769ba7 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -765,6 +765,29 @@ def resolve_ipaddress(server):
return addr
+def do_nsupdate(update_txt):
+ root_logger.debug("Writing nsupdate commands to %s:\n%s"
+ % (UPDATE_FILE, update_txt))
+
+ update_fd = file(UPDATE_FILE, "w")
+ update_fd.write(update_txt)
+ update_fd.flush()
+ update_fd.close()
+
+ result = False
+ try:
+ ipautil.run(['/usr/bin/nsupdate', '-g', UPDATE_FILE])
+ result = True
+ except CalledProcessError, e:
+ root_logger.debug('nsupdate failed: %s' % str(e))
+
+ try:
+ os.remove(UPDATE_FILE)
+ except:
+ pass
+
+ return result
+
UPDATE_TEMPLATE_A = """
zone $ZONE.
update delete $HOSTNAME. IN A
@@ -807,25 +830,10 @@ def update_dns(server, hostname):
update_txt = ipautil.template_str(template, sub_dict)
- root_logger.debug("Writing nsupdate commands to %s:\n%s"
- % (UPDATE_FILE, update_txt))
-
- update_fd = file(UPDATE_FILE, "w")
- update_fd.write(update_txt)
- update_fd.flush()
- update_fd.close()
-
- try:
- ipautil.run(['/usr/bin/nsupdate', '-g', UPDATE_FILE],
- env={'KRB5CCNAME':CCACHE_FILE})
+ if do_nsupdate(update_txt):
print "DNS server record set to: %s -> %s" % (hostname, ip)
- except CalledProcessError, e:
- print >>sys.stderr, "Failed to update DNS A record. (%s)" % str(e)
-
- try:
- os.remove(UPDATE_FILE)
- except:
- pass
+ else:
+ print >>sys.stderr, "Failed to update DNS records."
def client_dns(server, hostname, dns_updates=False):