mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-23 06:43:13 -06:00
20: Updated example plugins, added '_api_' command to ipa script with prints the api
This commit is contained in:
parent
89e9b7eaec
commit
14339cfae0
22
ipa
22
ipa
@ -36,14 +36,30 @@ def print_commands():
|
||||
def print_help(cmd):
|
||||
print 'Help on %s' % cmd
|
||||
|
||||
def print_api():
|
||||
print '\nCommands:'
|
||||
for n in api.commands:
|
||||
print ' %s' % n
|
||||
|
||||
print '\nObjects:'
|
||||
for obj in api.objects():
|
||||
print ' %s' % obj.name
|
||||
for n in obj.commands:
|
||||
print ' .%s()' % n
|
||||
|
||||
print '%d objects' % len(api.objects)
|
||||
print '%d commands' % len(api.commands)
|
||||
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print_commands()
|
||||
print 'Usage: ipa COMMAND [OPTIONS]'
|
||||
sys.exit(2)
|
||||
|
||||
cmd = sys.argv[1]
|
||||
|
||||
if cmd not in api.commands:
|
||||
if cmd == '_api_':
|
||||
print_api()
|
||||
elif cmd not in api.commands:
|
||||
print_commands()
|
||||
print 'ipa: ERROR: unknown command %r' % cmd
|
||||
sys.exit(2)
|
||||
api.commands[cmd]()
|
||||
|
@ -158,7 +158,8 @@ class WithObj(Named):
|
||||
|
||||
|
||||
class Command(WithObj):
|
||||
pass
|
||||
def __call__(self):
|
||||
print 'You called %s()' % self.name
|
||||
|
||||
class Property(WithObj):
|
||||
pass
|
||||
|
@ -44,3 +44,46 @@ api.register(moduser)
|
||||
class finduser(crud.Find):
|
||||
_obj = 'user'
|
||||
api.register(finduser)
|
||||
|
||||
|
||||
|
||||
class group(base.Object):
|
||||
pass
|
||||
api.register(group)
|
||||
|
||||
class addgroup(crud.Add):
|
||||
_obj = 'group'
|
||||
api.register(addgroup)
|
||||
|
||||
class delgroup(crud.Del):
|
||||
_obj = 'group'
|
||||
api.register(delgroup)
|
||||
|
||||
class modgroup(crud.Mod):
|
||||
_obj = 'group'
|
||||
api.register(modgroup)
|
||||
|
||||
class findgroup(crud.Find):
|
||||
_obj = 'group'
|
||||
api.register(findgroup)
|
||||
|
||||
|
||||
class service(base.Object):
|
||||
pass
|
||||
api.register(service)
|
||||
|
||||
class addservice(crud.Add):
|
||||
_obj = 'service'
|
||||
api.register(addservice)
|
||||
|
||||
class delservice(crud.Del):
|
||||
_obj = 'service'
|
||||
api.register(delservice)
|
||||
|
||||
class modservice(crud.Mod):
|
||||
_obj = 'service'
|
||||
api.register(modservice)
|
||||
|
||||
class findservice(crud.Find):
|
||||
_obj = 'service'
|
||||
api.register(findservice)
|
||||
|
Loading…
Reference in New Issue
Block a user