Re: [Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
On 08/13/2010 03:17 PM, Adam Young wrote: On 08/11/2010 02:07 PM, Pavel Zůna wrote: On 2010-08-10 21:47, Rob Crittenden wrote: Pavel Zuna wrote: This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel The code looks ok but export.py doesn't seem like it matches the functions the plugin provides (and is rather generic in nature). Can we rename this json.py or something? rob I thought that we might use the file for other plugins that export data, but there probably won't be any for a while. Renamed it to internal.py as I'm sure we'll see more internal commands as we progress with the webUI. Patch attached. Pavel ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel ACK ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel Pushed to master ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
On 08/11/2010 02:07 PM, Pavel Zůna wrote: On 2010-08-10 21:47, Rob Crittenden wrote: Pavel Zuna wrote: This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel The code looks ok but export.py doesn't seem like it matches the functions the plugin provides (and is rather generic in nature). Can we rename this json.py or something? rob I thought that we might use the file for other plugins that export data, but there probably won't be any for a while. Renamed it to internal.py as I'm sure we'll see more internal commands as we progress with the webUI. Patch attached. Pavel ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel ACK ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
On 2010-08-10 21:47, Rob Crittenden wrote: Pavel Zuna wrote: This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel The code looks ok but export.py doesn't seem like it matches the functions the plugin provides (and is rather generic in nature). Can we rename this json.py or something? rob I thought that we might use the file for other plugins that export data, but there probably won't be any for a while. Renamed it to internal.py as I'm sure we'll see more internal commands as we progress with the webUI. Patch attached. Pavel From c0c862db3b8fad97902d3cec378d06bfa1e03e7c Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Tue, 10 Aug 2010 16:41:28 -0400 Subject: [PATCH 2/6] Add a new INTERNAL plugin that exports plugin meta-data into JSON. This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. --- ipalib/plugins/internal.py | 65 1 files changed, 65 insertions(+), 0 deletions(-) create mode 100644 ipalib/plugins/internal.py diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py new file mode 100644 index 000..6f0c2cf --- /dev/null +++ b/ipalib/plugins/internal.py @@ -0,0 +1,65 @@ +# Authors: +# Pavel Zuna +# +# Copyright (c) 2010 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 +""" +Plugins not accessible directly through the CLI, commands used internally +""" + +import json + +from ipalib import api, errors +from ipalib import Command +from ipalib import Str +from ipalib.output import Output +from ipalib.text import _ +from ipalib.util import json_serialize + +class json_metadata(Command): +""" +Export plugin meta-data for the webUI. +""" +INTERNAL = True + +takes_args = ( +Str('objname?', +doc=_('Name of object to export'), +), +) + +has_output = ( +Output('result', dict, doc=_('Dict of JSON encoded IPA Objects')), +) + +def execute(self, objname): +if objname and objname in self.api.Object: +return dict( +result=dict( +((objname, json_serialize(self.api.Object[objname])), ) +) +) +return dict( +result=dict( +(o.name, json_serialize(o)) for o in self.api.Object() +) +) + +def output_for_cli(self, textui, result, *args, **options): +print json.dumps(result, default=json_serialize) + +api.register(json_metadata) + -- 1.7.1.1 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
On 08/10/2010 03:47 PM, Rob Crittenden wrote: Pavel Zuna wrote: This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel The code looks ok but export.py doesn't seem like it matches the functions the plugin provides (and is rather generic in nature). Can we rename this json.py or something? rob ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel Shouldn't be JSON, should it, as it exports the plugin meta data in both json and in xml format based on how it is called. Can we call it metadata.py? ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
Pavel Zuna wrote: This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel The code looks ok but export.py doesn't seem like it matches the functions the plugin provides (and is rather generic in nature). Can we rename this json.py or something? rob ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
[Freeipa-devel] [PATCH] Add a new INTERNAL plugin that exports plugin meta-data into JSON.
This is required for the webUI, since we're dropping Genshi. *ehm* :) You can't use this command on the CLI. It takes one optional argument: the name of an IPA object. If not specified, meta-data for all objects are returned. Note: If you want to try it out on the CLI, just comment out the INTERNAL = True line. Pavel pzuna-freeipa-0011-export.patch Description: application/mbox ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel