diff options
author | Jan Cholasta <jcholast@redhat.com> | 2011-12-07 03:36:27 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-02-13 22:21:38 -0500 |
commit | 9b6649a1ce7c15043c9d197363c3b9fdd4b12a1d (patch) | |
tree | 8e8a77021fe9110aa36aa0221c14c96ed943b5be /ipa-client | |
parent | 04b8575c52410bb6d31e0e55f1cf431d7cc9c7c3 (diff) | |
download | freeipa-9b6649a1ce7c15043c9d197363c3b9fdd4b12a1d.tar.gz freeipa-9b6649a1ce7c15043c9d197363c3b9fdd4b12a1d.tar.xz freeipa-9b6649a1ce7c15043c9d197363c3b9fdd4b12a1d.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
Diffstat (limited to 'ipa-client')
-rwxr-xr-x | ipa-client/ipa-install/ipa-client-install | 44 |
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 170a009cf..10769ba7c 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): |