summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2016-03-02 15:53:27 +0100
committerMartin Basti <mbasti@redhat.com>2016-04-13 17:44:56 +0200
commit9a0f92be0dc1dc22827c918b5808b1ccb4e4b409 (patch)
treef2915726a39a36610ebf768ced3ca4614ac50c18 /ipalib
parent40e3a0bf63c766fc281517c9d192907376c2d353 (diff)
downloadfreeipa-9a0f92be0dc1dc22827c918b5808b1ccb4e4b409.tar.gz
freeipa-9a0f92be0dc1dc22827c918b5808b1ccb4e4b409.tar.xz
freeipa-9a0f92be0dc1dc22827c918b5808b1ccb4e4b409.zip
host_del: replace dns-record find command with show
Due the configuration of dnsrecord_find, it works as dnsrecord-show, thus it can be replaced. https://fedorahosted.org/freeipa/ticket/5675 Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/host.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 97c9e1588..ef0738041 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -769,18 +769,23 @@ class host_del(LDAPDelete):
domain = result['idnsname'][0]
except errors.NotFound:
self.obj.handle_not_found(*keys)
- # Get all forward resources for this host
- records = api.Command['dnsrecord_find'](domain, idnsname=parts[0])['result']
- for record in records:
- for attr in _record_attributes:
- for val in record.get(attr, []):
- if attr in ('arecord', 'aaaarecord'):
- remove_fwd_ptr(val, parts[0], domain, attr)
- elif (val.endswith(parts[0]) or
- val.endswith(fqdn + '.')):
- delkw = {unicode(attr): val}
- api.Command['dnsrecord_del'](
- domain, record['idnsname'][0], **delkw)
+ else:
+ # Get all forward resources for this host
+ try:
+ record = api.Command['dnsrecord_show'](
+ domain, parts[0])['result']
+ except errors.NotFound:
+ pass
+ else:
+ for attr in _record_attributes:
+ for val in record.get(attr, []):
+ if attr in ('arecord', 'aaaarecord'):
+ remove_fwd_ptr(val, parts[0], domain, attr)
+ elif (val.endswith(parts[0]) or
+ val.endswith(fqdn + '.')):
+ delkw = {unicode(attr): val}
+ api.Command['dnsrecord_del'](
+ domain, record['idnsname'][0], **delkw)
if self.api.Command.ca_is_enabled()['result']:
try: