Regression is caused by different output types for dnsrecord-mod and dnsrecord-del. dnsrecord-mod internally calls remove record, if there is no more records in owner name, which cause output validation error.

[root@vm-035 git]# ipa dnsrecord-mod ipa.example ds --ns-rec=
ipa: ERROR: an internal error has occurred

ipa: ERROR: non-public: TypeError: dnsrecord_mod.validate_output() => PrimaryKey.validate(): output['value']: need <class 'ipapython.dnsutil.DNSName'>; got <type 'list'>: [<DNS name ds>]
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ipaserver/rpcserver.py", line 348, in wsgi_execute
    result = self.Command[name](*args, **options)
File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 451, in __call__
    self.validate_output(ret, options['version'])
File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 944, in validate_output
    o.validate(self, value, version)
File "/usr/lib/python2.7/site-packages/ipalib/output.py", line 126, in validate
    types[0], type(value), value))
TypeError: dnsrecord_mod.validate_output() => PrimaryKey.validate():
output['value']: need <class 'ipapython.dnsutil.DNSName'>; got <type 'list'>: [<DNS name ds>] ipa: INFO: [jsonserver_session] admin@IPA.EXAMPLE: dnsrecord_mod(<DNS name ipa.example.>, <DNS name ds>, nsrecord=None, rights=False, structured=False, all=False, raw=False, version=u'2.102'): TypeError


Patch attached.

--
Martin Basti

From 9aaf34c44c97ecf62cd1f143af13b0205ce4dbf2 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 4 Sep 2014 15:48:16 +0200
Subject: [PATCH] Fix dnsrecord-mod raise error if last record attr is removed

Removing last record attribute causes output type validation error
---
 ipalib/plugins/dns.py                   | 7 +++++++
 ipatests/test_xmlrpc/test_dns_plugin.py | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 7d513c252a43b846098d4364d78c45ce4391528d..d4b015f27955ca5fe487df6302e5315ccb8e2448 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -3440,6 +3440,13 @@ class dnsrecord_mod(LDAPUpdate):
             if del_all:
                 result = self.obj.methods.delentry(*keys,
                                                    version=options['version'])
+
+                # we need to modify delete result to match mod output type
+                # only one value is expected, not a list
+                assert len(result['value']) == 1
+                if client_has_capability(options['version'], 'primary_key_types'):
+                    result['value'] = result['value'][0]
+
                 # indicate that entry was deleted
                 context.dnsrecord_entry_mods[(keys[0], keys[1])] = None
 
diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index 0253cf4507be55b0b3c2d89de0a955733fb4813d..79638b00bb9fa414c611f00715d1c9c97ab8476d 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -1463,10 +1463,10 @@ class test_dns(Declarative):
 
 
         dict(
-            desc='Delete record %r in zone %r' % (tlsa, zone1),
-            command=('dnsrecord_del', [zone1, tlsa], {'del_all': True}),
+            desc='Remove record using dnsrecord-mod %r in zone %r' % (tlsa, zone1),
+            command=('dnsrecord_mod', [zone1, tlsa], {'tlsarecord': ''}),
             expected={
-                'value': [tlsa_dnsname],
+                'value': tlsa_dnsname,
                 'summary': u'Deleted record "%s"' % tlsa,
                 'result': {'failed': []},
             },
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to