summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-11-16 15:13:32 -0600
committerSimo Sorce <ssorce@redhat.com>2012-01-11 12:04:20 -0500
commit8d1488c95f7b1c3d5350cf5e5f98937e9392b46f (patch)
treebf5ddcb08a0e4082e8b78d22234b2322b7032556 /ipalib
parent0698e54b35f68bf473a72920b4948c23b11ff83a (diff)
downloadfreeipa.git-8d1488c95f7b1c3d5350cf5e5f98937e9392b46f.tar.gz
freeipa.git-8d1488c95f7b1c3d5350cf5e5f98937e9392b46f.tar.xz
freeipa.git-8d1488c95f7b1c3d5350cf5e5f98937e9392b46f.zip
Added commands into metadata.
The json_metadata command has been modified to accept some new options and return the commands metadata. The API.txt has been updated as well. The UI has been modified to use commands metadata instead of methods metadata. Ticket #388
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py11
-rw-r--r--ipalib/plugins/internal.py58
2 files changed, 64 insertions, 5 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index b79aad95..028e17e7 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -941,6 +941,17 @@ class Command(HasParam):
return rv
+ # list of attributes we want exported to JSON
+ json_friendly_attributes = (
+ 'name', 'takes_args', 'takes_options',
+ )
+
+ def __json__(self):
+ json_dict = dict(
+ (a, getattr(self, a)) for a in self.json_friendly_attributes
+ )
+ return json_dict
+
class LocalOrRemote(Command):
"""
A command that is explicitly executed locally or remotely.
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 32d59512..9e7b0ddb 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -48,16 +48,34 @@ class json_metadata(Command):
),
)
+ takes_options = (
+ Str('object?',
+ doc=_('Name of object to export'),
+ ),
+ Str('method?',
+ doc=_('Name of method to export'),
+ ),
+ Str('command?',
+ doc=_('Name of command to export'),
+ ),
+ )
+
has_output = (
Output('objects', dict, doc=_('Dict of JSON encoded IPA Objects')),
Output('methods', dict, doc=_('Dict of JSON encoded IPA Methods')),
+ Output('commands', dict, doc=_('Dict of JSON encoded IPA Commands')),
)
- def execute(self, objname, methodname):
+ def execute(self, objname, methodname, **options):
objects = dict()
methods = dict()
+ commands = dict()
- if objname :
+ empty = True
+
+ try:
+ if not objname:
+ objname = options['object']
if objname in self.api.Object:
o = self.api.Object[objname]
objects = dict([(o.name, json_serialize(o))])
@@ -65,25 +83,52 @@ class json_metadata(Command):
objects = dict(
(o.name, json_serialize(o)) for o in self.api.Object()
)
- elif methodname:
- if methodname in self.api.Method:
+ empty = False
+ except KeyError:
+ pass
+
+ try:
+ if not methodname:
+ methodname = options['method']
+ if methodname in self.api.Method:
m = self.api.Method[methodname]
methods = dict([(m.name, json_serialize(m))])
elif methodname == "all":
methods = dict(
(m.name, json_serialize(m)) for m in self.api.Method()
)
- else:
+ empty = False
+ except KeyError:
+ pass
+
+ try:
+ cmdname = options['command']
+ if cmdname in self.api.Command:
+ c = self.api.Command[cmdname]
+ commands = dict([(c.name, json_serialize(c))])
+ elif cmdname == "all":
+ commands = dict(
+ (c.name, json_serialize(c)) for c in self.api.Command()
+ )
+ empty = False
+ except KeyError:
+ pass
+
+ if empty:
objects = dict(
(o.name, json_serialize(o)) for o in self.api.Object()
)
methods = dict(
(m.name, json_serialize(m)) for m in self.api.Method()
)
+ commands = dict(
+ (c.name, json_serialize(c)) for c in self.api.Command()
+ )
retval = dict([
("objects", objects),
("methods", methods),
+ ("commands", commands),
])
return retval
@@ -315,6 +360,9 @@ class i18n_messages(Command):
"hbacsvcgroup": {
"services": _("Services"),
},
+ "hbactest": {
+ "label": _("HBAC Test"),
+ },
"host": {
"certificate": _("Host Certificate"),
"cn": _("Host Name"),