summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-02-02 13:40:26 +0100
committerMartin Kosek <mkosek@redhat.com>2012-02-03 16:31:00 +0100
commitde9a0df508c8749294d177a45f7a27a4a8ada0d4 (patch)
treefdc90a074070cd5473a88b781b5e784e0f72f20c
parentf411ed1e4717200016594acff05fb6e6e3b33b0b (diff)
downloadfreeipa-de9a0df508c8749294d177a45f7a27a4a8ada0d4.tar.gz
freeipa-de9a0df508c8749294d177a45f7a27a4a8ada0d4.tar.xz
freeipa-de9a0df508c8749294d177a45f7a27a4a8ada0d4.zip
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
-rw-r--r--ipalib/plugins/dns.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 8a3bc5ede..fe32efccd 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -1495,6 +1495,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)