diff options
author | Martin Basti <mbasti@redhat.com> | 2016-03-03 13:28:19 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-04-13 17:44:56 +0200 |
commit | 1e70d6b914656d670f9afed26ccd5f93e3aa54d5 (patch) | |
tree | fc5ee736dfffc3ab727e046ff0c9d193b7c97ba9 /ipalib | |
parent | bea066c33647c16a7b18deb1392838acb831ac88 (diff) | |
download | freeipa-1e70d6b914656d670f9afed26ccd5f93e3aa54d5.tar.gz freeipa-1e70d6b914656d670f9afed26ccd5f93e3aa54d5.tar.xz freeipa-1e70d6b914656d670f9afed26ccd5f93e3aa54d5.zip |
host_del: split removing A/AAAA and PTR records to separate functions
This change is needed because A/AAAA and PTR record will be handled
separately.
https://fedorahosted.org/freeipa/ticket/5675
Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/host.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index b22768aa0..5a85b95ae 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -121,8 +121,17 @@ register = Registry() host_pwd_chars = string.digits + string.ascii_letters + '_,.@+-=' -def remove_fwd_ptr(ipaddr, host, domain, recordtype): - api.log.debug('deleting ipaddr %s' % ipaddr) +def remove_fwd_rec(ipaddr, host, domain, recordtype): + api.log.debug('deleting ipaddr %s', ipaddr) + try: + delkw = {recordtype: ipaddr} + api.Command['dnsrecord_del'](domain, host, **delkw) + except errors.NotFound: + api.log.debug('ipaddr %s not found', ipaddr) + + +def remove_ptr_rec(ipaddr, host, domain): + api.log.debug('deleting PTR record of ipaddr %s', ipaddr) try: revzone, revname = get_reverse_zone(ipaddr) @@ -133,13 +142,7 @@ def remove_fwd_ptr(ipaddr, host, domain, recordtype): api.Command['dnsrecord_del'](revzone, revname, **delkw) except errors.NotFound: - pass - - try: - delkw = {recordtype: ipaddr} - api.Command['dnsrecord_del'](domain, host, **delkw) - except errors.NotFound: - pass + api.log.debug('PTR record of ipaddr %s not found', ipaddr) def update_sshfp_record(zone, record, entry_attrs): @@ -774,7 +777,8 @@ class host_del(LDAPDelete): for attr in _record_attributes: for val in record.get(attr, []): if attr in ('arecord', 'aaaarecord'): - remove_fwd_ptr(val, parts[0], domain, attr) + remove_fwd_rec(val, parts[0], domain, attr) + remove_ptr_rec(val, parts[0], domain) elif (val.endswith(parts[0]) or val.endswith(fqdn + '.')): delkw = {unicode(attr): val} |