On Fri, 2012-02-03 at 10:05 -0500, Rob Crittenden wrote:
> Martin Kosek wrote:
> > When a new DNS record is being added to DNS zone via command
> >    ipa dnsrecord-add ZONE @
> > and the target ZONE does not exist it returns ObjectclassViolation
> > which may confuse users. Make sure that standard DNS Zone NotFound
> > exception is returned.
> >
> > https://fedorahosted.org/freeipa/ticket/2270
> 
> nack, I show two test failures with this patch.
> 

Thanks for catching this. It was a stupid mistake, possibly from some
clever late fix. Fixed patch attached.

Martin
>From 5eb37fb23df14f6dd1cd5c1951a6a62042061ff6 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Thu, 2 Feb 2012 13:40:26 +0100
Subject: [PATCH] Improve dnszone-add error message

When a new DNS record is being added to DNS zone via command
  ipa dnsrecord-add ZONE @
and the target ZONE does not exist it returns ObjectclassViolation
which may confuse users. Make sure that standard DNS Zone NotFound
exception is returned.

https://fedorahosted.org/freeipa/ticket/2270
---
 ipalib/plugins/dns.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index da4934fc971cb1cb8b2b930cad55b341b692cb5c..09f803effe98a901257a96fe4af2113b6a4e8ac8 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -1464,6 +1464,13 @@ class dnsrecord(LDAPObject):
 
     def get_dn(self, *keys, **options):
         if self.is_pkey_zone_record(*keys):
+            dn = self.api.Object[self.parent_object].get_dn(*keys[:-1], **options)
+            # zone must exist
+            ldap = self.api.Backend.ldap2
+            try:
+                (dn_, zone) = ldap.get_entry(dn, [])
+            except errors.NotFound:
+                self.api.Object['dnszone'].handle_not_found(keys[-2])
             return self.api.Object[self.parent_object].get_dn(*keys[:-1], **options)
         return super(dnsrecord, self).get_dn(*keys, **options)
 
-- 
1.7.7.6

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

Reply via email to