summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-07-20 18:36:02 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-07-20 18:36:02 +0000
commit14339cfae01b843949d0f9972670f56f952a5faa (patch)
treef37c378ee0ba619424f654bf345aa4faa30c7630
parent89e9b7eaeca5e96d0fdeddf76fd74a2176d96d6f (diff)
downloadfreeipa-14339cfae01b843949d0f9972670f56f952a5faa.tar.gz
freeipa-14339cfae01b843949d0f9972670f56f952a5faa.tar.xz
freeipa-14339cfae01b843949d0f9972670f56f952a5faa.zip
20: Updated example plugins, added '_api_' command to ipa script with prints the api
-rwxr-xr-xipa22
-rw-r--r--ipalib/base.py3
-rw-r--r--ipalib/plugins.py43
3 files changed, 64 insertions, 4 deletions
diff --git a/ipa b/ipa
index e536e341e..91bdc021d 100755
--- a/ipa
+++ b/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]()
diff --git a/ipalib/base.py b/ipalib/base.py
index 4731a872e..3c302369f 100644
--- a/ipalib/base.py
+++ b/ipalib/base.py
@@ -158,7 +158,8 @@ class WithObj(Named):
class Command(WithObj):
- pass
+ def __call__(self):
+ print 'You called %s()' % self.name
class Property(WithObj):
pass
diff --git a/ipalib/plugins.py b/ipalib/plugins.py
index 21a608352..a28ac2fb3 100644
--- a/ipalib/plugins.py
+++ b/ipalib/plugins.py
@@ -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)