2008-07-20 02:03:15 +00: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-13 00:56:46 +00:00
|
|
|
|
|
|
|
|
from ipalib import public
|
2008-08-13 01:26:30 +00:00
|
|
|
from ipalib.api import api
|
2008-07-20 02:03:15 +00:00
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
|
2008-07-21 01:44:59 +00:00
|
|
|
# Hypothetical functional commands (not associated with any object):
|
2008-08-15 19:49:04 +00:00
|
|
|
class krbtest(public.Command):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Test your Kerberos ticket'
|
2008-07-21 01:44:59 +00:00
|
|
|
api.register(krbtest)
|
|
|
|
|
|
2008-08-15 19:49:04 +00:00
|
|
|
class discover(public.Command):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Discover IPA servers on network'
|
2008-07-21 01:44:59 +00:00
|
|
|
api.register(discover)
|
|
|
|
|
|
|
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
# Register some methods for the 'user' object:
|
2008-08-22 20:23:19 +00:00
|
|
|
class user_add(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Add new user'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(user_add)
|
2008-07-20 02:03:15 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class user_del(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Delete existing user'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(user_del)
|
2008-07-20 02:03:15 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class user_mod(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Edit existing user'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(user_mod)
|
2008-07-20 02:03:15 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class user_find(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Search for users'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(user_find)
|
2008-07-20 02:03:15 +00:00
|
|
|
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
# Register some properties for the 'user' object:
|
2008-08-22 20:32:23 +00:00
|
|
|
class user_givenname(public.Property):
|
2008-08-15 19:19:42 +00:00
|
|
|
'User first name'
|
2008-08-13 05:25:00 +00:00
|
|
|
required = True
|
2008-08-12 02:03:47 +00:00
|
|
|
api.register(user_givenname)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 20:32:23 +00:00
|
|
|
class user_sn(public.Property):
|
2008-08-15 19:19:42 +00:00
|
|
|
'User last name'
|
2008-08-13 05:25:00 +00:00
|
|
|
required = True
|
2008-08-12 02:03:47 +00:00
|
|
|
api.register(user_sn)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 20:32:23 +00:00
|
|
|
class user_login(public.Property):
|
2008-08-15 19:19:42 +00:00
|
|
|
'User login'
|
2008-08-13 05:25:00 +00:00
|
|
|
required = True
|
2008-08-12 19:22:48 +00:00
|
|
|
def default(self, **kw):
|
|
|
|
|
givenname = kw.get('givenname', None)
|
|
|
|
|
sn = kw.get('sn', None)
|
|
|
|
|
if givenname is None or sn is None:
|
|
|
|
|
return None
|
|
|
|
|
return ('%s%s' % (givenname[0], sn)).lower()
|
|
|
|
|
api.register(user_login)
|
|
|
|
|
|
2008-08-22 20:32:23 +00:00
|
|
|
class user_initials(public.Property):
|
2008-08-15 19:19:42 +00:00
|
|
|
'User initials'
|
2008-08-13 05:25:00 +00:00
|
|
|
required = True
|
2008-08-12 17:42:21 +00:00
|
|
|
def default(self, **kw):
|
|
|
|
|
givenname = kw.get('givenname', None)
|
|
|
|
|
sn = kw.get('sn', None)
|
|
|
|
|
if givenname is None or sn is None:
|
|
|
|
|
return None
|
|
|
|
|
return '%s%s' % (givenname[0], sn[0])
|
|
|
|
|
api.register(user_initials)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
|
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
# Register some methods for the 'group' object:
|
2008-08-22 20:23:19 +00:00
|
|
|
class group_add(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Add new group'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(group_add)
|
2008-07-20 23:43:16 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class group_del(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Delete existing group'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(group_del)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class group_mod(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Edit existing group'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(group_mod)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class group_find(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Search for groups'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(group_find)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
|
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
# Register some methods for the 'service' object
|
2008-08-22 20:23:19 +00:00
|
|
|
class service_add(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Add new service'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(service_add)
|
2008-07-20 23:43:16 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class service_del(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Delete existing service'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(service_del)
|
2008-07-20 23:43:16 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class service_mod(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Edit existing service'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(service_mod)
|
2008-07-20 23:43:16 +00:00
|
|
|
|
2008-08-22 20:23:19 +00:00
|
|
|
class service_find(public.Method):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Search for services'
|
2008-08-05 22:21:57 +00:00
|
|
|
api.register(service_find)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
|
|
|
|
|
2008-07-20 23:43:16 +00:00
|
|
|
# And to emphasis that the registration order doesn't matter,
|
|
|
|
|
# we'll register the objects last:
|
2008-08-22 21:50:53 +00:00
|
|
|
class group(public.Object):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Group object'
|
2008-07-20 23:43:16 +00:00
|
|
|
api.register(group)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 21:50:53 +00:00
|
|
|
class service(public.Object):
|
2008-08-15 19:19:42 +00:00
|
|
|
'Service object'
|
2008-07-20 23:43:16 +00:00
|
|
|
api.register(service)
|
2008-07-20 18:36:02 +00:00
|
|
|
|
2008-08-22 21:50:53 +00:00
|
|
|
class user(public.Object):
|
2008-08-15 19:19:42 +00:00
|
|
|
'User object'
|
2008-07-20 23:43:16 +00:00
|
|
|
api.register(user)
|