2008-07-19 21:03:15 -05:00
|
|
|
# Authors:
|
|
|
|
# Jason Gerard DeRose <jderose@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation; version 2 only
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
"""
|
|
|
|
Some example plugins.
|
|
|
|
"""
|
|
|
|
|
2008-08-12 19:56:46 -05:00
|
|
|
|
|
|
|
from ipalib import public
|
2008-08-25 18:35:29 -05:00
|
|
|
from ipalib import api
|
2008-09-12 19:22:01 -05:00
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
|
2008-07-20 20:44:59 -05:00
|
|
|
# Hypothetical functional commands (not associated with any object):
|
2008-08-15 14:49:04 -05:00
|
|
|
class krbtest(public.Command):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Test your Kerberos ticket.'
|
2008-07-20 20:44:59 -05:00
|
|
|
api.register(krbtest)
|
|
|
|
|
2008-08-15 14:49:04 -05:00
|
|
|
class discover(public.Command):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Discover IPA servers on network.'
|
2008-07-20 20:44:59 -05:00
|
|
|
api.register(discover)
|
|
|
|
|
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
# Register some methods for the 'user' object:
|
2008-08-22 15:23:19 -05:00
|
|
|
class user_add(public.Method):
|
2008-09-04 00:18:14 -05:00
|
|
|
'Add a new user.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(user_add)
|
2008-07-19 21:03:15 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class user_del(public.Method):
|
2008-09-04 00:18:14 -05:00
|
|
|
'Delete an existing user.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(user_del)
|
2008-07-19 21:03:15 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class user_mod(public.Method):
|
2008-09-04 00:18:14 -05:00
|
|
|
'Edit an existing user.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(user_mod)
|
2008-07-19 21:03:15 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class user_find(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Search the users.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(user_find)
|
2008-07-19 21:03:15 -05:00
|
|
|
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
# Register some properties for the 'user' object:
|
2008-08-22 15:32:23 -05:00
|
|
|
class user_givenname(public.Property):
|
2008-08-15 14:19:42 -05:00
|
|
|
'User first name'
|
2008-08-13 00:25:00 -05:00
|
|
|
required = True
|
2008-08-11 21:03:47 -05:00
|
|
|
api.register(user_givenname)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 15:32:23 -05:00
|
|
|
class user_sn(public.Property):
|
2008-08-15 14:19:42 -05:00
|
|
|
'User last name'
|
2008-08-13 00:25:00 -05:00
|
|
|
required = True
|
2008-08-11 21:03:47 -05:00
|
|
|
api.register(user_sn)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 15:32:23 -05:00
|
|
|
class user_login(public.Property):
|
2008-08-15 14:19:42 -05:00
|
|
|
'User login'
|
2008-08-13 00:25:00 -05:00
|
|
|
required = True
|
2008-08-26 14:23:50 -05:00
|
|
|
default_from = public.DefaultFrom(
|
|
|
|
lambda first, last: (first[0] + last).lower(),
|
|
|
|
'givenname', 'sn'
|
|
|
|
)
|
2008-08-12 14:22:48 -05:00
|
|
|
api.register(user_login)
|
|
|
|
|
2008-08-22 15:32:23 -05:00
|
|
|
class user_initials(public.Property):
|
2008-08-15 14:19:42 -05:00
|
|
|
'User initials'
|
2008-08-13 00:25:00 -05:00
|
|
|
required = True
|
2008-08-26 14:23:50 -05:00
|
|
|
default_from = public.DefaultFrom(
|
|
|
|
lambda first, last: first[0] + last[0],
|
|
|
|
'givenname', 'sn'
|
|
|
|
)
|
2008-08-12 12:42:21 -05:00
|
|
|
api.register(user_initials)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
# Register some methods for the 'group' object:
|
2008-08-22 15:23:19 -05:00
|
|
|
class group_add(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Add a new group.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(group_add)
|
2008-07-20 18:43:16 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class group_del(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Delete an existing group.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(group_del)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class group_mod(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Edit an existing group.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(group_mod)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class group_find(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Search the groups.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(group_find)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
# Register some methods for the 'service' object
|
2008-08-22 15:23:19 -05:00
|
|
|
class service_add(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Add a new service.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(service_add)
|
2008-07-20 18:43:16 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class service_del(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Delete an existing service.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(service_del)
|
2008-07-20 18:43:16 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class service_mod(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Edit an existing service.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(service_mod)
|
2008-07-20 18:43:16 -05:00
|
|
|
|
2008-08-22 15:23:19 -05:00
|
|
|
class service_find(public.Method):
|
2008-09-04 04:22:18 -05:00
|
|
|
'Search the services.'
|
2008-08-05 17:21:57 -05:00
|
|
|
api.register(service_find)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
|
|
|
|
2008-07-20 18:43:16 -05:00
|
|
|
# And to emphasis that the registration order doesn't matter,
|
|
|
|
# we'll register the objects last:
|
2008-08-22 16:50:53 -05:00
|
|
|
class group(public.Object):
|
2008-08-15 14:19:42 -05:00
|
|
|
'Group object'
|
2008-07-20 18:43:16 -05:00
|
|
|
api.register(group)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 16:50:53 -05:00
|
|
|
class service(public.Object):
|
2008-08-15 14:19:42 -05:00
|
|
|
'Service object'
|
2008-07-20 18:43:16 -05:00
|
|
|
api.register(service)
|
2008-07-20 13:36:02 -05:00
|
|
|
|
2008-08-22 16:50:53 -05:00
|
|
|
class user(public.Object):
|
2008-08-15 14:19:42 -05:00
|
|
|
'User object'
|
2008-07-20 18:43:16 -05:00
|
|
|
api.register(user)
|