Jun 2, 2011 12:41 PM
Overriding a page template in Zenoss 3.x
-
Like (0)
Zenoss 3.1 on Open SuSE 11.4. I am trying to make the mib_utils ZenPack V1.08 work on Zenoss 3 - specifically the MIB Browser bit - the rest I can live with the standard Core functionality.
Something in the menu definitions in the zenpacks objects.xml file prevent the zenpack installing cleanly and uninstalling cleanly so I have hidden that file entirely.
In the ZenPack's skins directory, mibOrganizerOverview.pt is the file that sets up the javascript to drive the mib browser and adds the little browser icon to the table of MIBs. The problem is that this ZenPack mibOrganizerOverview.pt does NOT seem to override the standard mibOrganizerOverview.pt in $ZENHOME/Products/ZenModel/skins/zenmodel.
If I copy the ZenPack version to $ZENHOME/Products/ZenModel/skins/zenmodel then it all works.
How do I get the ZenPack version of the template file to override the Core one?
Cheers,
Jane
Ill notify the author (kells).
The short answer, unfortunately, is "you can't". (At least, AFAIK and from a quick look at the reference to ZCML's browser:page entry. I believe that it's also supposed to be a 'feature' in that all sorts of crazy stuff was happening where different zenpacks would override the same page.)
What is possible is to create a new hierearchy in a zenpack and then to point a new item to the page. In this scenario, there would be a 'MIBs' item and then a 'MIB Browser' item that would be displayed. It should also be possible to add a new 'cog' menu item to bring up the browser.
Zenoss 3.1.1 (not released yet) has more MIB functionality dragged into it, but not a MIB browser (it's still not done). A lot of the backend work has been completed (ie facade/router stuff), but it's still a little buggy and not ready for prime time. The current JS that I've got is not feature complete, but does have a nice tree view of OIDs. I've had to lean on some of the other members of the developer team for ExtJS help as the ExtJS framework is a little bit beyond me at the moment.
kells
Thanks Kells - very helpful (even if in a negative sort of way).
This highlights one of my issues with the brief documentation in Chapter 14 (ZenPack Conversion Tasks for V3) in the Developers Guide. It talks about REDESIGNED pages and RESKINNED pages which I have never really understood. My rule-of-thumb is that if it has been rewritten in JavaScript then it is redesigned??? However, generally the old page template .pt files are still around, and I suspect many of them are now redundant, but I'm never sure what is redundant and what isn't.
Chapter 14.1.1 says you don't need to change a ZenPack if it adds a dialog to a reskinned page. The MIBs page doesn't appear in the explicit list of redesigned pages so I am guessing it is reskinned - on this basis I hoped that my ZenPack mibOrganizerOverview.pt file would override the Core one. The same subsection says you must modify your ZenPack if it overrides the page template of a redesigned page - so I was hoping for the corollary that I didn't need to change the ZenPack as I am trying to overrride a reskinned page??? Indeed 14.1.2 explicitly says that "if your ZenPack overrides the page template of a reskinned page, then no changes are needed".
So, is my assumption that the MIBs page is merely reskinned, incorrect? Or are there more gotchas? I have proved that it uses the Core mibOrganizerOverview.pt file, simply by copying my ZenPack version file over the Core file, so it does use that page template file rather than Javascript.
I like the idea of adding to the Action cog menu - seems like the right way to do it - but note sure how to go about this????
Does anyone else have any insights to this area?
Thanks again, Kells,
Jane
Since I didn't write that piece of documentation, I'm not personally going to feel badly about it.
From a pragmatic perspective, there are now (as of 3.x) two different types of pages:
- new JavaScript pages
- backcompat pages (ie old school Zope page templates)
The actual JS pages are in the ZENHOME/Products/ZenUI3/browser/resources/js/zenoss/ directory, and are wired up using various zcml files in the ZenUI3 directory tree.
Much of the old .pt files have not been cleaned up, which can cause some confusion about what's going on. A lot of the mechanics of linking up new and backcompat pages are contained int he $ZENHOME/Products/ZenUI3 directory.
For reference, the backcompat pages have a zcml file (ZenUI3/browser/backcompat.zcml) as well as some thin Python shims (ZenUI3/browser/backcompat.py). The zcml points to the .pt files still in use.
The MIBs page is a backcompat page.
A really quick example:
From a JS file:
=============================
// New menu option on the cog wheel
Ext.ComponentMgr.onAvailable('context-configure-menu', function(config) {
var origOnGet = config.onGetMenuItems;
config.onGetMenuItems = function(uid) {
var result = origOnGet.call(this, uid) || [];
// Menu item only shows up when certain device class is selected
if( uid.match('^/zport/dmd/Devices/MyDeviceClass/') ) {
result.push( {
text: _t('Run Predefined Shell Cmmand'),
hidden: Zenoss.Security.doesNotHavePermission('Manage Device'),
handler: function() {
var win = new Zenoss.CommandWindow({
uids: Re: Overriding a page template in Zenoss 3.x,
target: 'run_predefined_command',
title: _t('Title in window')
});
win.show();
}
});
}
return result;
};
});
From a zenpack's configure.zcml
=============================
<!-- Add a command window for showing output from command run from organizer -->
<browser:page
class=".command.PredefinedCommandView"
name="run_predefined_command"
for="*"
permission="zenoss.ManageDevice"
/>
From a file called 'command.py' in the zp dir:
=============================
import Globals
from Products.ZenUtils.jsonutils import unjson
from Products.Zuul import getFacade
from Products.ZenUI3.browser.streaming import StreamingView
class PredefinedCommandView(StreamingView):
def stream(self):
data = unjson(self.request.get('data'))
uids = data['uids']
facade = getFacade('device', self.context)
organizer = facade._getObject(uids[0])
libexec = os.path.join(os.path.dirname(__file__), 'libexec')
predefinedCmd = [
libexec + '/mywrapper_script',
'arg1', 'arg2'
]
result = executeCommand(predefinedCmd, None, None)
return result
kells
That last post was a tasty morsel on the new UI stuff. Thx Kells.
Any pointers on where you would go hunting for examples of creating a new device component in the UI?
For example, user wants to create a ZP for a new ILO-enabled network hardware device and wants a component that displays its special management components or something peculiar. How would one go about adding a totally new component in? Think of how 'interfaces' or 'file systems' 'Windows Services' is implemented in 3.x - but making your own new component UI section.
This was a question I heard from a few ZP devs.
The "Creating Zenoss ZenPacks" updated paper docs/DOC-10268 does just this for Bridge MIB devices.
Cheers,
Jane
The following add-on convo took place on email and I thought it would be good to include here:
dcarmean asked:
Where does zuul fit in this? Are "routers" part of zuul or extjs or?
kkerney replied:
The Zuul directory has a lot of the new UI and Zope 3 style Zope Component Architecture (ZCA) pieces. Zuul isn't really a thing, it's just a directory (ok, technically a Zope product, but whatever). The name Zuul came from Ghostbusters.
ExtJS - a JS library that can wrap things like YUI and Mochikit, etc etc
router - the published API of what can be used (its executable code)
facade - the supporting code behind the routers
Hi Kells,
I finally got around to trying this but it breaks all panels. The python command.py gets compiled so something is happening.
I have my javascript file directly under the browser directory and I have modified the configure.zcml in the base directory of the ZenPack as you describe. No obvious error messages being spit out other than the screenshot below. It's like this javascript breaks the whole page rendition.
Any thoughts??
The problem is similar to the one I have with creating a completely new footer menu with code provided by Josh a couple of dev-chats back - that problem is recorded here - message/61820#61820
Cheers,
Jane
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||