summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py20
-rw-r--r--ipalib/errors2.py79
-rw-r--r--ipalib/plugins/f_automount.py10
-rw-r--r--ipalib/plugins/f_delegation.py1
-rw-r--r--ipalib/plugins/f_group.py10
-rw-r--r--ipalib/plugins/f_host.py6
-rw-r--r--ipalib/plugins/f_hostgroup.py10
-rw-r--r--ipalib/plugins/f_netgroup.py4
-rw-r--r--ipalib/plugins/f_service.py10
-rw-r--r--ipalib/plugins/f_user.py9
10 files changed, 110 insertions, 49 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index beb6342d9..722de7658 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -320,14 +320,6 @@ class MidairCollision(GenericError):
"""Change collided with another change"""
faultCode = 1002
-class NotFound(GenericError):
- """Entry not found"""
- faultCode = 1003
-
-class DuplicateEntry(GenericError):
- """This entry already exists"""
- faultCode = 1004
-
class MissingDN(GenericError):
"""The distinguished name (DN) is missing"""
faultCode = 1005
@@ -360,14 +352,6 @@ class PrincipalError(GenericError):
"""There is a problem with the kerberos principal"""
faultCode = 1012
-class MalformedServicePrincipal(PrincipalError):
- """The requested service principal is not of the form: service/fully-qualified host name"""
- faultCode = 1013
-
-class RealmMismatch(PrincipalError):
- """The realm for the principal does not match the realm for this IPA server"""
- faultCode = 1014
-
class PrincipalRequired(PrincipalError):
"""You cannot remove IPA server service principals"""
faultCode = 1015
@@ -412,10 +396,6 @@ class DefaultGroup(ConfigurationError):
"""You cannot remove the default users group"""
faultCode = 1025
-class HostService(ConfigurationError):
- """You must enroll a host in order to create a host service"""
- faultCode = 1026
-
class InsufficientAccess(GenericError):
"""You do not have permission to perform this task"""
faultCode = 1027
diff --git a/ipalib/errors2.py b/ipalib/errors2.py
index 4a6a517dd..83ea2aab4 100644
--- a/ipalib/errors2.py
+++ b/ipalib/errors2.py
@@ -599,6 +599,85 @@ class ExecutionError(PublicError):
errno = 4000
+class NotFound(ExecutionError):
+ """
+ **4001** Raised when an entry is not found.
+
+ For example:
+
+ >>> raise NotFound(msg='Entry not found')
+ Traceback (most recent call last):
+ ...
+ NotFound: Entry not found
+
+ """
+
+ errno = 4001
+ format = _('%(msg)s')
+
+class DuplicateEntry(ExecutionError):
+ """
+ **4002** Raised when an entry already exists.
+
+ For example:
+
+ >>> raise DuplicateEntry
+ Traceback (most recent call last):
+ ...
+ DuplicateEntry: This entry already exists
+
+ """
+
+ errno = 4002
+ format = _('This entry already exists')
+
+class HostService(ExecutionError):
+ """
+ **4003** Raised when a host service principal is requested
+
+ For example:
+
+ >>> raise HostService
+ Traceback (most recent call last):
+ ...
+ HostService: You must enroll a host in order to create a host service
+
+ """
+
+ errno = 4003
+ format = _('You must enroll a host in order to create a host service')
+
+class MalformedServicePrincipal(ExecutionError):
+ """
+ **4004** Raised when a service principal is not of the form: service/fully-qualified host name
+
+ For example:
+
+ >>> raise MalformedServicePrincipal
+ Traceback (most recent call last):
+ ...
+ MalformedServicePrincipal: Service principal is not of the form: service/fully-qualified host name
+
+ """
+
+ errno = 4004
+ format = _('Service principal is not of the form: service/fully-qualified host name')
+
+class RealmMismatch(ExecutionError):
+ """
+ **4005** Raised when the requested realm does not match the IPA realm
+
+ For example:
+
+ >>> raise RealmMismatch
+ Traceback (most recent call last):
+ ...
+ RealmMismatch: The realm for the principal does not match the realm for this IPA server
+
+ """
+
+ errno = 4005
+ format = _('The realm for the principal does not match the realm for this IPA server')
class BuiltinError(ExecutionError):
"""
diff --git a/ipalib/plugins/f_automount.py b/ipalib/plugins/f_automount.py
index 2365ce221..1c6511e5c 100644
--- a/ipalib/plugins/f_automount.py
+++ b/ipalib/plugins/f_automount.py
@@ -24,7 +24,7 @@ RFC 2707bis http://www.padl.com/~lukeh/rfc2307bis.txt
"""
from ldap import explode_dn
-from ipalib import crud, errors
+from ipalib import crud, errors2
from ipalib import api, Str, Flag, Object, Command
map_attributes = ['automountMapName', 'description', ]
@@ -199,7 +199,7 @@ class automount_delkey(crud.Del):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
return ldap.delete(keydn)
def output_for_cli(self, textui, result, *args, **options):
"""
@@ -277,7 +277,7 @@ class automount_modkey(crud.Mod):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
return ldap.update(keydn, **kw)
def output_for_cli(self, textui, result, *args, **options):
@@ -425,7 +425,7 @@ class automount_showkey(crud.Get):
keydn = k.get('dn')
break
if not keydn:
- raise errors.NotFound
+ raise errors2.NotFound(msg='Entry not found')
# FIXME: should kw contain the list of attributes to display?
if kw.get('all', False):
return ldap.retrieve(keydn)
@@ -466,7 +466,7 @@ class automount_getkeys(Command):
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
try:
keys = ldap.get_one_entry(dn, 'objectclass=*', ['automountkey'])
- except errors.NotFound:
+ except errors2.NotFound:
keys = []
return keys
diff --git a/ipalib/plugins/f_delegation.py b/ipalib/plugins/f_delegation.py
index fbf8cfbff..4c207b338 100644
--- a/ipalib/plugins/f_delegation.py
+++ b/ipalib/plugins/f_delegation.py
@@ -25,7 +25,6 @@ from ipalib import frontend
from ipalib import crud
from ipalib.frontend import Param
from ipalib import api
-from ipalib import errors
class delegation(frontend.Object):
"""
diff --git a/ipalib/plugins/f_group.py b/ipalib/plugins/f_group.py
index 740b32f8c..99a8e1324 100644
--- a/ipalib/plugins/f_group.py
+++ b/ipalib/plugins/f_group.py
@@ -21,7 +21,7 @@
Frontend plugins for group (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str, Int # Parameter types
@@ -283,7 +283,7 @@ class group_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -293,7 +293,7 @@ class group_add_member(Command):
try:
member_dn = ldap.find_entry_dn("uid", m)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -350,7 +350,7 @@ class group_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
@@ -359,7 +359,7 @@ class group_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("uid", m,)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
diff --git a/ipalib/plugins/f_host.py b/ipalib/plugins/f_host.py
index ea819a77d..17bec9774 100644
--- a/ipalib/plugins/f_host.py
+++ b/ipalib/plugins/f_host.py
@@ -21,7 +21,7 @@
Frontend plugins for host/machine Identity.
"""
-from ipalib import api, crud, errors, util
+from ipalib import api, crud, errors2, util
from ipalib import Object # Plugin base class
from ipalib import Str, Flag # Parameter types
@@ -38,7 +38,7 @@ def get_host(hostname):
hostname = hostname[:-1]
try:
dn = ldap.find_entry_dn("cn", hostname, "ipaHost")
- except errors.NotFound:
+ except errors2.NotFound:
dn = ldap.find_entry_dn("serverhostname", hostname, "ipaHost")
return dn
@@ -120,7 +120,7 @@ class host_add(crud.Add):
current = util.get_current_principal()
if not current:
- raise errors.NotFound('Unable to determine current user')
+ raise errors2.NotFound('Unable to determine current user')
kw['enrolledby'] = ldap.find_entry_dn("krbPrincipalName", current, "posixAccount")
# Get our configuration
diff --git a/ipalib/plugins/f_hostgroup.py b/ipalib/plugins/f_hostgroup.py
index 706712c9a..85dbfc496 100644
--- a/ipalib/plugins/f_hostgroup.py
+++ b/ipalib/plugins/f_hostgroup.py
@@ -21,7 +21,7 @@
Frontend plugins for groups of hosts
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str # Parameter types
@@ -249,7 +249,7 @@ class hostgroup_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, hostgroup_filter)
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -259,7 +259,7 @@ class hostgroup_add_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
to_add.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
add_failed.append(m)
continue
@@ -317,7 +317,7 @@ class hostgroup_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, hostgroup_filter)
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
@@ -327,7 +327,7 @@ class hostgroup_remove_member(Command):
try:
member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
to_remove.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
remove_failed.append(m)
continue
diff --git a/ipalib/plugins/f_netgroup.py b/ipalib/plugins/f_netgroup.py
index 6ee55b0db..3fa81c7e3 100644
--- a/ipalib/plugins/f_netgroup.py
+++ b/ipalib/plugins/f_netgroup.py
@@ -21,7 +21,7 @@
Frontend plugin for netgroups.
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str # Parameter types
from ipalib import uuid
@@ -53,7 +53,7 @@ def find_members(ldap, failed, members, attribute, filter=None):
try:
member_dn = ldap.find_entry_dn(attribute, m, filter)
found.append(member_dn)
- except errors.NotFound:
+ except errors2.NotFound:
failed.append(m)
continue
diff --git a/ipalib/plugins/f_service.py b/ipalib/plugins/f_service.py
index 06d6a5d08..99446b598 100644
--- a/ipalib/plugins/f_service.py
+++ b/ipalib/plugins/f_service.py
@@ -22,7 +22,7 @@
Frontend plugins for service (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object # Plugin base classes
from ipalib import Str, Flag # Parameter types
@@ -72,11 +72,11 @@ class service_add(crud.Add):
# may not include the realm.
sp = principal.split('/')
if len(sp) != 2:
- raise errors.MalformedServicePrincipal
+ raise errors2.MalformedServicePrincipal
service = sp[0]
if service.lower() == "host":
- raise errors.HostService
+ raise errors2.HostService
sr = sp[1].split('@')
if len(sr) == 1:
@@ -86,7 +86,7 @@ class service_add(crud.Add):
hostname = sr[0].lower()
realm = sr[1]
else:
- raise MalformedServicePrincipal
+ raise errors2.MalformedServicePrincipal
"""
FIXME once DNS client is done
@@ -102,7 +102,7 @@ class service_add(crud.Add):
# At some point we'll support multiple realms
if (realm != self.api.env.realm):
- raise errors.RealmMismatch
+ raise errors2.RealmMismatch
# Put the principal back together again
princ_name = service + "/" + hostname + "@" + realm
diff --git a/ipalib/plugins/f_user.py b/ipalib/plugins/f_user.py
index 58ff53cda..ce880b24e 100644
--- a/ipalib/plugins/f_user.py
+++ b/ipalib/plugins/f_user.py
@@ -21,7 +21,7 @@
Frontend plugins for user (Identity).
"""
-from ipalib import api, crud, errors
+from ipalib import api, crud, errors2
from ipalib import Object, Command # Plugin base classes
from ipalib import Str, Password, Flag, Int # Parameter types
@@ -99,6 +99,9 @@ class user(Object):
cli_name='uid',
doc='The uid to use for this user. If not included one is automatically set.',
),
+ Str('street?',
+ doc='The street address',
+ ),
)
api.register(user)
@@ -151,9 +154,9 @@ class user_add(crud.Add):
default_group = ldap.retrieve(group_dn, ['dn','gidNumber'])
if default_group:
kw['gidnumber'] = default_group.get('gidnumber')
- except errors.NotFound:
+ except errors2.NotFound:
# Fake an LDAP error so we can return something useful to the kw
- raise errors.NotFound, "The default group for new kws, '%s', cannot be found." % config.get('ipadefaultprimarygroup')
+ raise errors2.NotFound, "The default group for new kws, '%s', cannot be found." % config.get('ipadefaultprimarygroup')
except Exception, e:
# catch everything else
raise e