[Engine-devel] oVirt UI Plugins feature: Ready for review

Costea, George George.Costea at netapp.com
Tue Jun 26 20:39:55 UTC 2012


This sounds great.  Thanks Vojtech.

From: Vojtech Szocs [mailto:vszocs at redhat.com]
Sent: Tuesday, June 26, 2012 10:44 AM
To: engine-devel at ovirt.org
Cc: Costea, George; Schoenbrun, Dustin; Hopper, Ricky; Itamar Heim
Subject: Re: oVirt UI Plugins feature: Ready for review

Hi George,

I've been thinking about developing plugins with GWT. There are some important issues that need to be addressed:

  1.  GWT bootstrap sequence requires permutation selector script (<pluginApplication>.nocache.js) to be invoked first.
Selector script determines the correct permutation (<hashName>.cache.html) and fetches it asynchronously from the same location.
  2.  GWT bootstrap sequence is asynchronous in nature.
  3.  GWT RPC (XMLHttpRequest) is subject to Same Origin Policy [1].
This means that pluginApplication's server-side code should be deployed on oVirt JBoss AS instance (next to engine.ear).

Given these limitations, I'd say the process could be like this:

a) In pluginApplication's EntryPoint, use GWT JSNI [2] to register the plugin using native JavaScript code.

   You don't need to use gwt-exporter here, since plugin registration and logic is combined in one place.
   Using plugin-to-GWT delegate pattern with gwt-exporter is actually more complicated than going with plain JSNI.

   For example:

   package com.myplugin;

   public class MyPluginApp implements com.google.gwt.core.client.EntryPoint {

      public void void onModuleLoad() {
         // Initialize plugin application, call registerPlugin() when ready
         registerPlugin();
      }

      public static void tableContextMenu(com.google.gwt.core.client.JavaScriptObject eventContext) {
         // Consider using GWT overlay types [3] to easily work with JavaScriptObjects
      }

      private static native void registerPlugin() /*-{
         // Register 'myPlugin' into pluginApi.plugins object
         $wnd.pluginApi.plugins.myPlugin = myPlugin = {
            tableContextMenu: function(eventContext) {
               // Call Java static method to handle this event
               @com.myplugin.MyPluginApp::tableContextMenu(Lcom/google/gwt/core/client/JavaScriptObject;)(eventContext);
            }
         };
         // Call the ready() function right away
         $wnd.pluginApi.lifecycle(myPlugin).ready();
      }-*/;

   }

b) Deploy the <pluginApplication>.war file on JBoss AS instance, e.g. <JBOSS_HOME>/standalone/deployments.

   This makes pluginApplication's GWT RPC servlet(s) accessible from the same origin (protocol, domain, port).

c) Modification of plugin lifecycle step #5:

   Instead of embedding <pluginApplication>.nocache.js content into WebAdmin HTML page, just embed the link to it, e.g. http(s)://127.0.0.1:<port>/path/to/<pluginApplication>.nocache.js

d) Modification of plugin lifecycle step #6:

   During WebAdmin startup, for each plugin that is supposed to be loaded remotely, create an <iframe> that will fetch the plugin asynchronously.

   The <iframe> is required in order for <pluginApplication>.nocache.js to appear from different (pluginApplication-specific) domain than WebAdmin HTML page.

   This way, fetching permutation (<hashName>.cache.html) files, which are relative to <pluginApplication>.nocache.js, will work out-of-the-box.


George, please let me know what you think, and I will update UI Plugins wiki accordingly.

Vojtech


[1] http://en.wikipedia.org/wiki/Same_origin_policy
[2] https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI
[3] https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsOverlay

________________________________

From: "George Costea" <George.Costea at netapp.com<mailto:George.Costea at netapp.com>>
To: "Vojtech Szocs" <vszocs at redhat.com<mailto:vszocs at redhat.com>>, engine-devel at ovirt.org<mailto:engine-devel at ovirt.org>
Cc: "Dustin Schoenbrun" <Dustin.Schoenbrun at netapp.com<mailto:Dustin.Schoenbrun at netapp.com>>, "Ricky Hopper" <Ricky.Hopper at netapp.com<mailto:Ricky.Hopper at netapp.com>>, "Itamar Heim" <iheim at redhat.com<mailto:iheim at redhat.com>>
Sent: Monday, June 25, 2012 9:11:33 PM
Subject: RE: oVirt UI Plugins feature: Ready for review

Thanks Vojtech.

Since the plugins are embedded into the WebAdmin HTML page, that seems to simplify things; no external web service is needed.  This approach ties into the issue over the freedom to decide which technology to use when developing a plugin.  While I agree that jQuery is best for simple dialogs, a wizard-driven workflow is easier to develop in GWT.

For example, if I want to step a user through the process of creating a new storage domain I would like to provide a workflow to select a storage array, provide credentials, and configure the details of the NFS export.  This workflow could presumably have a GWT-RPC mechanism that relies on some additional libraries on the backend (libraries that allow me to communicate with the storage array).  Using the GWT-Exporter, I could export the classes that would display the workflow which would then get launched as my extension is selected.  You said that I would have my oVirt UI plugin depend on my compiled 'plugin support application'.  My compiled plugin support application would normally be a war file containing my compiled GWT code and a web-inf folder containing my libraries.  Is the plugin depending on the war file?  Is that what I specify?

-George

-----Original Message-----
From: Vojtech Szocs [mailto:vszocs at redhat.com]<mailto:[mailto:vszocs at redhat.com]>
Sent: Monday, June 25, 2012 1:12 PM
To: Costea, George; engine-devel at ovirt.org<mailto:engine-devel at ovirt.org>
Cc: Schoenbrun, Dustin; Hopper, Ricky; Itamar Heim
Subject: Re: oVirt UI Plugins feature: Ready for review

Hi George,

thanks for your feedback. Please find my answers below.

1) Are the plugins hosted by the same jboss server that hosts the engine?  It would appear the answer is yes and that no separate container is required for the plugins.

In short, yes.


Plugins, along with their configuration and 3rd party dependencies, are meant to be embedded into final WebAdmin HTML page, see [http://www.ovirt.org/wiki/Features/UIPlugins#Plugin_lifecycle] step #5.
JBoss AS instance serves WebAdmin HTML page (WebadminDynamicHostingServlet), along with providing GWT RPC and REST endpoints that delegate to Engine business logic through EJB BackendLocal interface.

However, plugins are not 'hosted' in a typical sense - WebadminDynamicHostingServlet reads and embeds all plugin data directly into final WebAdmin HTML page.

2) Does each plugin map to a unique extension within WebAdmin?  Your example shows that I can extend the VM table to have a "Show VM name and edit VM" context-sensitive extension.  This is named pluginApi.plugins.myPlugin.  Can I safely assume that this is per extension?  I would have pluginApi.plugins.myPlugin2 for extending a storage domain?

Extension points are represented by application events, triggered by WebAdmin and consumed by plugins. For example, 'tableContextMenu' event gets triggered when a table context menu is about to be shown to the user, which gives plugins the ability to do something custom with the context menu before it's shown.


There can be multiple plugins handling the same event (extension point). You can have two plugins, say 'pluginApi.plugins.One' and 'pluginApi.plugins.Two', each providing 'tableContextMenu' function for handling the above mentioned event. WebAdmin will invoke all plugins for the given event.

To answer your question, in order to handle X events (extension points), you don't need to write X plugins. You can write one plugin that handles X events.

3) Instead of launching a jQuery dialog, can I point to a compiled GWT html file to display a dialog that fits my needs?

You can do anything you want in your plugin event handler function. Show a jQuery UI dialog, make oVirt REST API request, call arbitrary remote server using cross-domain technique like JSONP [1] or CORS [2], etc. Plugin authors are free to decide if they want to rely on 3rd party JavaScript libraries, or if they want to write entire plugin code by themselves.


In my opinion, tools like jQuery are far more elegant for handling simple things such as UI dialogs. But if you really want to use GWT for this purpose, I suggest following approach:

a, develop a 'plugin support application' in GWT, which implements the necessary dialog functionality b, export its main (e.g. dialog handling) classes for use in native JavaScript through gwt-exporter [3] c, have your oVirt UI plugin depend on your compiled 'plugin support application' (this will cause your 'plugin support application' to be called during WebAdmin startup) d, in your oVirt UI plugin, invoke 'plugin support application' functionality through exported classes (plugin -> GWT delegate pattern)

4) Is session info passed into the plugin so that I can invoke APIs into the engine?  To power on a VM for instance?  Or to mount a new NFS storage domain?

Yes, this should be part of [http://www.ovirt.org/wiki/Features/UIPlugins#Global_API_functions] "Plugin utility functions" (global API).


Your plugin might access user session information in the following way: pluginApi.util().userInfo().* (replace * with id(), name(), domain(), etc.)

As you pointed out, this could be used to authenticate oVirt REST API requests made from your plugin code.

BTW, the link to the original design notes on the wiki doesn't work.

This is strange, [http://rhevmf.pad.engineering.redhat.com/68] has its visibility set to "Public (Allow Internet guests)" ... Does anybody know why this doesn't work?



Vojtech


[1] http://en.wikipedia.org/wiki/JSONP
[2] http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
[3] http://code.google.com/p/gwt-exporter/


----- Original Message -----
From: "George Costea" <George.Costea at netapp.com<mailto:George.Costea at netapp.com>>
To: "Vojtech Szocs" <vszocs at redhat.com<mailto:vszocs at redhat.com>>, engine-devel at ovirt.org<mailto:engine-devel at ovirt.org>
Cc: "Dustin Schoenbrun" <Dustin.Schoenbrun at netapp.com<mailto:Dustin.Schoenbrun at netapp.com>>, "Ricky Hopper" <Ricky.Hopper at netapp.com<mailto:Ricky.Hopper at netapp.com>>
Sent: Monday, June 25, 2012 3:09:43 PM
Subject: RE: oVirt UI Plugins feature: Ready for review

Hi Vojtech,

I have a few questions on this feature.

1) Are the plugins hosted by the same jboss server that hosts the engine?  It would appear the answer is yes and that no separate container is required for the plugins.
2) Does each plugin map to a unique extension within WebAdmin?  Your example shows that I can extend the VM table to have a "Show VM name and edit VM" context-sensitive extension.  This is named pluginApi.plugins.myPlugin.  Can I safely assume that this is per extension?  I would have pluginApi.plugins.myPlugin2 for extending a storage domain?
3) Instead of launching a jQuery dialog, can I point to a compiled GWT html file to display a dialog that fits my needs?
4) Is session info passed into the plugin so that I can invoke APIs into the engine?  To power on a VM for instance?  Or to mount a new NFS storage domain?

BTW, the link to the original design notes on the wiki doesn't work.

Thanks,
George

-----Original Message-----
From: Vojtech Szocs [mailto:vszocs at redhat.com]<mailto:[mailto:vszocs at redhat.com]>
Sent: Thursday, June 21, 2012 11:03 AM
To: engine-devel at ovirt.org<mailto:engine-devel at ovirt.org>
Cc: Schoenbrun, Dustin; Costea, George; Hopper, Ricky
Subject: oVirt UI Plugins feature: Ready for review

Hi guys,

I wrote a wiki page describing UI Plugins, a feature planned for oVirt web administration (WebAdmin) application:
http://www.ovirt.org/wiki/Features/UIPlugins

Feature design is finished and ready for review. Please feel free to add comments, ask questions or reach me directly on #ovirt channel.

Cheers,
Vojtech
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20120626/3d6d6393/attachment-0002.html>


More information about the Devel mailing list