summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-07-05 13:36:48 -0400
committerRob Crittenden <rcritten@redhat.com>2011-07-11 18:45:49 -0400
commitd9627ab1651f4ab00c3734cc5bd69b051f79f92b (patch)
tree8c6ec64e0f0bd48791d4b326d5e4ef5912f82194 /ipalib
parent3a5e26a01c9cbb7b0a1c38d1b0467b780c3df124 (diff)
downloadfreeipa-d9627ab1651f4ab00c3734cc5bd69b051f79f92b.tar.gz
freeipa-d9627ab1651f4ab00c3734cc5bd69b051f79f92b.tar.xz
freeipa-d9627ab1651f4ab00c3734cc5bd69b051f79f92b.zip
find_entry_by_attr() should fail if multiple entries are found
It will only ever return one entry so if more than one are found then we raise an exception. This is most easily seen in the host plugin where we search on the server shortname which can be the same across sub-domains (e.g. foo.example.com & foo.lab.example.com). https://fedorahosted.org/freeipa/ticket/1388
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index cad6e37b4..04211e6ed 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -1210,6 +1210,23 @@ class AttrValueNotFound(ExecutionError):
format = _('%(attr)s does not contain \'%(value)s\'')
+class SingleMatchExpected(ExecutionError):
+ """
+ **4027** Raised when a search should return a single match
+
+ For example:
+
+ >>> raise SingleMatchExpected(found=9)
+ Traceback (most recent call last):
+ ...
+ SingleMatchExpected: The search criteria was not specific enough. Expected 1 and found 9.
+ """
+
+ errno = 4027
+ rval = 1
+ format = _('The search criteria was not specific enough. Expected 1 and found %(found)d.')
+
+
class BuiltinError(ExecutionError):
"""
**4100** Base class for builtin execution errors (*4100 - 4199*).