summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/plugins')
-rw-r--r--ipalib/plugins/f_automount.py76
-rw-r--r--ipalib/plugins/f_group.py38
-rw-r--r--ipalib/plugins/f_host.py47
-rw-r--r--ipalib/plugins/f_hostgroup.py34
-rw-r--r--ipalib/plugins/f_passwd.py16
-rw-r--r--ipalib/plugins/f_pwpolicy.py26
-rw-r--r--ipalib/plugins/f_ra.py10
-rw-r--r--ipalib/plugins/f_service.py25
-rw-r--r--ipalib/plugins/f_user.py67
9 files changed, 162 insertions, 177 deletions
diff --git a/ipalib/plugins/f_automount.py b/ipalib/plugins/f_automount.py
index 4c392438..2365ce22 100644
--- a/ipalib/plugins/f_automount.py
+++ b/ipalib/plugins/f_automount.py
@@ -23,13 +23,9 @@ Frontend plugins for automount.
RFC 2707bis http://www.padl.com/~lukeh/rfc2307bis.txt
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
from ldap import explode_dn
+from ipalib import crud, errors
+from ipalib import api, Str, Flag, Object, Command
map_attributes = ['automountMapName', 'description', ]
key_attributes = ['description', 'automountKey', 'automountInformation']
@@ -57,12 +53,12 @@ def make_automount_dn(mapname):
api.env.basedn,
)
-class automount(frontend.Object):
+class automount(Object):
"""
Automount object.
"""
takes_params = (
- Param('automountmapname',
+ Str('automountmapname',
cli_name='mapname',
primary_key=True,
doc='A group of related automount objects',
@@ -73,8 +69,9 @@ api.register(automount)
class automount_addmap(crud.Add):
'Add a new automount map.'
+
takes_options = (
- Param('description?',
+ Str('description?',
doc='A description of the automount map'),
)
@@ -96,6 +93,7 @@ class automount_addmap(crud.Add):
kw['objectClass'] = ['automountMap']
return ldap.create(**kw)
+
def output_for_cli(self, textui, result, map, **options):
"""
Output result of this command to command line interface.
@@ -108,13 +106,13 @@ api.register(automount_addmap)
class automount_addkey(crud.Add):
'Add a new automount key.'
takes_options = (
- Param('automountkey',
+ Str('automountkey',
cli_name='key',
doc='An entry in an automount map'),
- Param('automountinformation',
+ Str('automountinformation',
cli_name='info',
doc='Mount information for this key'),
- Param('description?',
+ Str('description?',
doc='A description of the mount'),
)
@@ -138,6 +136,7 @@ class automount_addkey(crud.Add):
kw['objectClass'] = ['automount']
return ldap.create(**kw)
+
def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
@@ -177,7 +176,7 @@ api.register(automount_delmap)
class automount_delkey(crud.Del):
'Delete an automount key.'
takes_options = (
- Param('automountkey',
+ Str('automountkey',
cli_name='key',
doc='The automount key to remove'),
)
@@ -213,7 +212,7 @@ api.register(automount_delkey)
class automount_modmap(crud.Mod):
'Edit an existing automount map.'
takes_options = (
- Param('description?',
+ Str('description?',
doc='A description of the automount map'),
)
def execute(self, mapname, **kw):
@@ -246,13 +245,13 @@ api.register(automount_modmap)
class automount_modkey(crud.Mod):
'Edit an existing automount key.'
takes_options = (
- Param('automountkey',
+ Str('automountkey',
cli_name='key',
doc='An entry in an automount map'),
- Param('automountinformation?',
+ Str('automountinformation?',
cli_name='info',
doc='Mount information for this key'),
- Param('description?',
+ Str('description?',
doc='A description of the automount map'),
)
def execute(self, mapname, **kw):
@@ -293,7 +292,7 @@ api.register(automount_modkey)
class automount_findmap(crud.Find):
'Search automount maps.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all attributes'),
+ Flag('all', doc='Retrieve all attributes'),
)
def execute(self, term, **kw):
ldap = self.api.Backend.ldap
@@ -331,10 +330,10 @@ api.register(automount_findmap)
class automount_findkey(crud.Find):
'Search automount keys.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all attributes'),
+ Flag('all?', doc='Retrieve all attributes'),
)
def get_args(self):
- return (Param('automountkey',
+ return (Str('automountkey',
cli_name='key',
doc='An entry in an automount map'),)
def execute(self, term, **kw):
@@ -372,7 +371,7 @@ api.register(automount_findkey)
class automount_showmap(crud.Get):
'Examine an existing automount map.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all attributes'),
+ Flag('all?', doc='Retrieve all attributes'),
)
def execute(self, mapname, **kw):
"""
@@ -400,10 +399,10 @@ api.register(automount_showmap)
class automount_showkey(crud.Get):
'Examine an existing automount key.'
takes_options = (
- Param('automountkey',
+ Str('automountkey',
cli_name='key',
doc='The automount key to display'),
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all attributes'),
+ Flag('all?', doc='Retrieve all attributes'),
)
def execute(self, mapname, **kw):
"""
@@ -446,10 +445,10 @@ class automount_showkey(crud.Get):
api.register(automount_showkey)
-class automount_getkeys(frontend.Command):
+class automount_getkeys(Command):
'Retrieve all keys for an automount map.'
takes_args = (
- Param('automountmapname',
+ Str('automountmapname',
cli_name='mapname',
primary_key=True,
doc='A group of related automount objects',
@@ -478,10 +477,10 @@ class automount_getkeys(frontend.Command):
api.register(automount_getkeys)
-class automount_getmaps(frontend.Command):
+class automount_getmaps(Command):
'Retrieve all automount maps'
takes_args = (
- Param('automountmapname?',
+ Str('automountmapname?',
cli_name='mapname',
primary_key=True,
doc='A group of related automount objects',
@@ -510,17 +509,23 @@ class automount_getmaps(frontend.Command):
api.register(automount_getmaps)
class automount_addindirectmap(crud.Add):
- 'Add a new automap indirect mount point.'
+ """
+ Add a new automap indirect mount point.
+ """
+
takes_options = (
- Param('parentmap?',
+ Str('parentmap?',
cli_name='parentmap',
- default='auto.master',
- doc='The parent map to connect this to. Default: auto.master'),
- Param('automountkey',
+ default=u'auto.master',
+ doc='The parent map to connect this to.',
+ ),
+ Str('automountkey',
cli_name='key',
- doc='An entry in an automount map'),
- Param('description?',
- doc='A description of the automount map'),
+ doc='An entry in an automount map',
+ ),
+ Str('description?',
+ doc='A description of the automount map',
+ ),
)
def execute(self, mapname, **kw):
@@ -556,4 +561,3 @@ class automount_addindirectmap(crud.Add):
textui.print_plain("Indirect automount map %s added" % map)
api.register(automount_addindirectmap)
-
diff --git a/ipalib/plugins/f_group.py b/ipalib/plugins/f_group.py
index 803e5d00..740b32f8 100644
--- a/ipalib/plugins/f_group.py
+++ b/ipalib/plugins/f_group.py
@@ -21,12 +21,9 @@
Frontend plugins for group (Identity).
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
+from ipalib import api, crud, errors
+from ipalib import Object, Command # Plugin base classes
+from ipalib import Str, Int # Parameter types
def get_members(members):
@@ -42,24 +39,23 @@ def get_members(members):
return members
-class group(frontend.Object):
+class group(Object):
"""
Group object.
"""
takes_params = (
- Param('description',
+ Str('description',
doc='A description of this group',
),
- Param('gidnumber?',
+ Int('gidnumber?',
cli_name='gid',
- type=ipa_types.Int(),
doc='The gid to use for this group. If not included one is automatically set.',
),
- Param('cn',
+ Str('cn',
cli_name='name',
primary_key=True,
- normalize=lambda value: value.lower(),
- )
+ normalizer=lambda value: value.lower(),
+ ),
)
api.register(group)
@@ -256,14 +252,14 @@ class group_show(crud.Get):
api.register(group_show)
-class group_add_member(frontend.Command):
+class group_add_member(Command):
'Add a member to a group.'
takes_args = (
- Param('group', primary_key=True),
+ Str('group', primary_key=True),
)
takes_options = (
- Param('users?', doc='comma-separated list of users to add'),
- Param('groups?', doc='comma-separated list of groups to add'),
+ Str('users?', doc='comma-separated list of users to add'),
+ Str('groups?', doc='comma-separated list of groups to add'),
)
def execute(self, cn, **kw):
"""
@@ -323,14 +319,14 @@ class group_add_member(frontend.Command):
api.register(group_add_member)
-class group_remove_member(frontend.Command):
+class group_remove_member(Command):
'Remove a member from a group.'
takes_args = (
- Param('group', primary_key=True),
+ Str('group', primary_key=True),
)
takes_options = (
- Param('users?', doc='comma-separated list of users to remove'),
- Param('groups?', doc='comma-separated list of groups to remove'),
+ Str('users?', doc='comma-separated list of users to remove'),
+ Str('groups?', doc='comma-separated list of groups to remove'),
)
def execute(self, cn, **kw):
"""
diff --git a/ipalib/plugins/f_host.py b/ipalib/plugins/f_host.py
index 7903ff90..3fcda77c 100644
--- a/ipalib/plugins/f_host.py
+++ b/ipalib/plugins/f_host.py
@@ -21,13 +21,9 @@
Frontend plugins for host/machine Identity.
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib import util
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
+from ipalib import api, crud, errors
+from ipalib import Object # Plugin base class
+from ipalib import Str, Flag # Parameter types
def get_host(hostname):
@@ -57,37 +53,36 @@ def validate_host(cn):
default_attributes = ['cn','description','localityname','nshostlocation','nshardwareplatform','nsosversion']
-class host(frontend.Object):
+class host(Object):
"""
Host object.
"""
takes_params = (
- Param('cn',
+ Str('cn', validate_host,
cli_name='hostname',
primary_key=True,
- normalize=lambda value: value.lower(),
- rules=(validate_host,)
+ normalizer=lambda value: value.lower(),
),
- Param('description?',
+ Str('description?',
doc='Description of the host',
),
- Param('localityname?',
+ Str('localityname?',
cli_name='locality',
doc='Locality of this host (Baltimore, MD)',
),
- Param('nshostlocation?',
+ Str('nshostlocation?',
cli_name='location',
doc='Location of this host (e.g. Lab 2)',
),
- Param('nshardwareplatform?',
+ Str('nshardwareplatform?',
cli_name='platform',
doc='Hardware platform of this host (e.g. Lenovo T61)',
),
- Param('nsosversion?',
+ Str('nsosversion?',
cli_name='os',
doc='Operating System and version on this host (e.g. Fedora 9)',
),
- Param('userpassword?',
+ Str('userpassword?',
cli_name='password',
doc='Set a password to be used in bulk enrollment',
),
@@ -211,14 +206,18 @@ api.register(host_mod)
class host_find(crud.Find):
'Search the hosts.'
+
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all attributes'),
+ Flag('all', doc='Retrieve all attributes'),
)
- def get_args(self):
- """
- Override Find.get_args() so we can exclude the validation rules
- """
- yield self.obj.primary_key.__clone__(rules=tuple())
+
+ # FIXME: This should no longer be needed with the Param.query kwarg.
+# def get_args(self):
+# """
+# Override Find.get_args() so we can exclude the validation rules
+# """
+# yield self.obj.primary_key.__clone__(rules=tuple())
+
def execute(self, term, **kw):
ldap = self.api.Backend.ldap
@@ -258,7 +257,7 @@ api.register(host_find)
class host_show(crud.Get):
'Examine an existing host.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Display all host attributes'),
+ Flag('all', doc='Display all host attributes'),
)
def execute(self, hostname, **kw):
"""
diff --git a/ipalib/plugins/f_hostgroup.py b/ipalib/plugins/f_hostgroup.py
index 3e14b09a..c365c918 100644
--- a/ipalib/plugins/f_hostgroup.py
+++ b/ipalib/plugins/f_hostgroup.py
@@ -21,12 +21,10 @@
Frontend plugins for groups of hosts
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
+from ipalib import api, crud, errors
+from ipalib import Object, Command # Plugin base classes
+from ipalib import Str # Parameter types
+
hostgroup_filter = "groupofnames)(!(objectclass=posixGroup)"
@@ -43,18 +41,18 @@ def get_members(members):
return members
-class hostgroup(frontend.Object):
+class hostgroup(Object):
"""
Host Group object.
"""
takes_params = (
- Param('description',
+ Str('description',
doc='A description of this group',
),
- Param('cn',
+ Str('cn',
cli_name='name',
primary_key=True,
- normalize=lambda value: value.lower(),
+ normalizer=lambda value: value.lower(),
)
)
api.register(hostgroup)
@@ -220,14 +218,14 @@ class hostgroup_show(crud.Get):
api.register(hostgroup_show)
-class hostgroup_add_member(frontend.Command):
+class hostgroup_add_member(Command):
'Add a member to a group.'
takes_args = (
- Param('group', primary_key=True),
+ Str('group', primary_key=True),
)
takes_options = (
- Param('groups?', doc='comma-separated list of host groups to add'),
- Param('hosts?', doc='comma-separated list of hosts to add'),
+ Str('groups?', doc='comma-separated list of host groups to add'),
+ Str('hosts?', doc='comma-separated list of hosts to add'),
)
def execute(self, cn, **kw):
"""
@@ -288,14 +286,14 @@ class hostgroup_add_member(frontend.Command):
api.register(hostgroup_add_member)
-class hostgroup_remove_member(frontend.Command):
+class hostgroup_remove_member(Command):
'Remove a member from a group.'
takes_args = (
- Param('group', primary_key=True),
+ Str('group', primary_key=True),
)
takes_options = (
- Param('hosts?', doc='comma-separated list of hosts to add'),
- Param('groups?', doc='comma-separated list of groups to remove'),
+ Str('hosts?', doc='comma-separated list of hosts to add'),
+ Str('groups?', doc='comma-separated list of groups to remove'),
)
def execute(self, cn, **kw):
"""
diff --git a/ipalib/plugins/f_passwd.py b/ipalib/plugins/f_passwd.py
index 1e0dfc1c..ea78c4c1 100644
--- a/ipalib/plugins/f_passwd.py
+++ b/ipalib/plugins/f_passwd.py
@@ -21,23 +21,21 @@
Frontend plugins for password changes.
"""
-from ipalib import frontend
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
-from ipalib import util
+from ipalib import api, errors, util
+from ipalib import Command # Plugin base classes
+from ipalib import Str, Password # Parameter types
-class passwd(frontend.Command):
+
+class passwd(Command):
'Edit existing password policy.'
takes_args = (
- Param('principal',
+ Str('principal',
cli_name='user',
primary_key=True,
default_from=util.get_current_principal,
),
- Param('password', flags=['password']),
+ Password('password'),
)
def execute(self, principal, password):
diff --git a/ipalib/plugins/f_pwpolicy.py b/ipalib/plugins/f_pwpolicy.py
index 87a7d8fa..d914ce72 100644
--- a/ipalib/plugins/f_pwpolicy.py
+++ b/ipalib/plugins/f_pwpolicy.py
@@ -21,40 +21,32 @@
Frontend plugins for password policy.
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
+from ipalib import Command # Plugin base classes
+from ipalib import Int # Parameter types
-class pwpolicy_mod(frontend.Command):
+class pwpolicy_mod(Command):
'Edit existing password policy.'
takes_options = (
- Param('krbmaxpwdlife?',
+ Int('krbmaxpwdlife?',
cli_name='maxlife',
- type=ipa_types.Int(),
doc='Max. Password Lifetime (days)'
),
- Param('krbminpwdlife?',
+ Int('krbminpwdlife?',
cli_name='minlife',
- type=ipa_types.Int(),
doc='Min. Password Lifetime (hours)'
),
- Param('krbpwdhistorylength?',
+ Int('krbpwdhistorylength?',
cli_name='history',
- type=ipa_types.Int(),
doc='Password History Size'
),
- Param('krbpwdmindiffchars?',
+ Int('krbpwdmindiffchars?',
cli_name='minclasses',
- type=ipa_types.Int(),
doc='Min. Number of Character Classes'
),
- Param('krbpwdminlength?',
+ Int('krbpwdminlength?',
cli_name='minlength',
- type=ipa_types.Int(),
doc='Min. Length of Password'
),
)
@@ -94,7 +86,7 @@ class pwpolicy_mod(frontend.Command):
api.register(pwpolicy_mod)
-class pwpolicy_show(frontend.Command):
+class pwpolicy_show(Command):
'Retrieve current password policy'
def execute(self, *args, **kw):
"""
diff --git a/ipalib/plugins/f_ra.py b/ipalib/plugins/f_ra.py
index 724cbf5e..7ac84e65 100644
--- a/ipalib/plugins/f_ra.py
+++ b/ipalib/plugins/f_ra.py
@@ -22,8 +22,7 @@
Frontend plugins for IPA-RA PKI operations.
"""
-from ipalib import api, Command, Param
-from ipalib import cli
+from ipalib import api, Command, Str, Int
class request_certificate(Command):
@@ -31,7 +30,7 @@ class request_certificate(Command):
takes_args = ['csr']
- takes_options = [Param('request_type?', default='pkcs10')]
+ takes_options = [Str('request_type?', default=u'pkcs10')]
def execute(self, csr, **options):
return self.Backend.ra.request_certificate(csr, **options)
@@ -85,7 +84,8 @@ class revoke_certificate(Command):
takes_args = ['serial_number']
- takes_options = [Param('revocation_reason?', default=0)]
+ # FIXME: The default is 0. Is this really an Int param?
+ takes_options = [Int('revocation_reason?', default=0)]
def execute(self, serial_number, **options):
@@ -115,5 +115,3 @@ class take_certificate_off_hold(Command):
textui.print_plain('Failed to take a revoked certificate off hold.')
api.register(take_certificate_off_hold)
-
-
diff --git a/ipalib/plugins/f_service.py b/ipalib/plugins/f_service.py
index a353d52e..06d6a5d0 100644
--- a/ipalib/plugins/f_service.py
+++ b/ipalib/plugins/f_service.py
@@ -22,27 +22,30 @@
Frontend plugins for service (Identity).
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
-
-class service(frontend.Object):
+from ipalib import api, crud, errors
+from ipalib import Object # Plugin base classes
+from ipalib import Str, Flag # Parameter types
+
+
+class service(Object):
"""
Service object.
"""
takes_params = (
- Param('principal', primary_key=True),
+ Str('principal', primary_key=True),
)
api.register(service)
class service_add(crud.Add):
- 'Add a new service.'
+ """
+ Add a new service.
+ """
+
takes_options = (
- Param('force?', type=ipa_types.Bool(), default=False, doc='Force a service principal name'),
+ Flag('force',
+ doc='Force a service principal name',
+ ),
)
def execute(self, principal, **kw):
"""
diff --git a/ipalib/plugins/f_user.py b/ipalib/plugins/f_user.py
index 04d7c930..506ad14d 100644
--- a/ipalib/plugins/f_user.py
+++ b/ipalib/plugins/f_user.py
@@ -21,12 +21,9 @@
Frontend plugins for user (Identity).
"""
-from ipalib import frontend
-from ipalib import crud
-from ipalib.frontend import Param
-from ipalib import api
-from ipalib import errors
-from ipalib import ipa_types
+from ipalib import api, crud, errors
+from ipalib import Object, Command # Plugin base classes
+from ipalib import Str, Password, Flag, Int # Parameter types
def display_user(user):
@@ -48,62 +45,62 @@ def display_user(user):
default_attributes = ['uid','givenname','sn','homeDirectory','loginshell']
-class user(frontend.Object):
+class user(Object):
"""
User object.
"""
+
takes_params = (
- Param('givenname',
+ Str('givenname',
cli_name='first',
- doc='User\'s first name',
+ doc="User's first name",
),
- Param('sn',
+ Str('sn',
cli_name='last',
- doc='User\'s last name',
+ doc="User's last name",
),
- Param('uid',
+ Str('uid',
cli_name='user',
primary_key=True,
default_from=lambda givenname, sn: givenname[0] + sn,
- normalize=lambda value: value.lower(),
+ normalizer=lambda value: value.lower(),
),
- Param('gecos?',
+ Str('gecos?',
doc='GECOS field',
default_from=lambda uid: uid,
),
- Param('homedirectory?',
+ Str('homedirectory?',
cli_name='home',
- doc='User\'s home directory',
+ doc="User's home directory",
default_from=lambda uid: '/home/%s' % uid,
),
- Param('loginshell?',
+ Str('loginshell?',
cli_name='shell',
default=u'/bin/sh',
- doc='User\'s Login shell',
+ doc="User's Login shell",
),
- Param('krbprincipalname?', cli_name='principal',
- doc='User\'s Kerberos Principal name',
+ Str('krbprincipalname?',
+ cli_name='principal',
+ doc="User's Kerberos Principal name",
default_from=lambda uid: '%s@%s' % (uid, api.env.realm),
),
- Param('mailaddress?',
- cli_name='mail',
- doc='User\'s e-mail address',
+ Str('mailaddress?',
+ cli_name='email',
+ doc="User's e-mail address",
),
- Param('userpassword?',
+ Password('userpassword?',
cli_name='password',
doc="Set user's password",
- flags=['password'],
),
- Param('groups?',
+ Str('groups?',
doc='Add account to one or more groups (comma-separated)',
),
- Param('uidnumber?',
+ Int('uidnumber?',
cli_name='uid',
- type=ipa_types.Int(),
doc='The uid to use for this user. If not included one is automatically set.',
),
-
)
+
api.register(user)
@@ -254,7 +251,7 @@ api.register(user_mod)
class user_find(crud.Find):
'Search the users.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all user attributes'),
+ Flag('all', doc='Retrieve all user attributes'),
)
def execute(self, term, **kw):
ldap = self.api.Backend.ldap
@@ -304,7 +301,7 @@ api.register(user_find)
class user_show(crud.Get):
'Examine an existing user.'
takes_options = (
- Param('all?', type=ipa_types.Bool(), doc='Retrieve all user attributes'),
+ Flag('all', doc='Retrieve all user attributes'),
)
def execute(self, uid, **kw):
"""
@@ -332,11 +329,11 @@ class user_show(crud.Get):
api.register(user_show)
-class user_lock(frontend.Command):
+class user_lock(Command):
'Lock a user account.'
takes_args = (
- Param('uid', primary_key=True),
+ Str('uid', primary_key=True),
)
def execute(self, uid, **kw):
@@ -351,11 +348,11 @@ class user_lock(frontend.Command):
api.register(user_lock)
-class user_unlock(frontend.Command):
+class user_unlock(Command):
'Unlock a user account.'
takes_args = (
- Param('uid', primary_key=True),
+ Str('uid', primary_key=True),
)
def execute(self, uid, **kw):