All us Zenoss users know that transforms play a big part in customizing Zenoss. Many times we re-use blocks of code in other transforms thoughout zenoss.
Is there a way to configure a "transform function library" where custom functions could be stored and called from within other transforms?
If not, it seems like this would be a great feature to have in a future version of zenoss..
I just did this recently. Add a module to your ZenPack with transform helper
methods. Assuming your ZenPack is called "ZenPacks.org.Thing" you could drop
a file called transforms.py into its ZenPacks/org/Thing/ directory. In this
transforms.py file you could add a method like the following.
def changeSummary(self, evt):
evt.summary = 'I changed this'
Then you can use the following code in your transform to change the summary
from ZenPacks.org.Thing import transforms
Can this only be implemented using a Zenpack?
I was hoping I could just place the functions in a file somewhere and then place an import statement in the transform(?).
You could add the same kind of thing under any of the existing
$ZENHOME/Products/ subdirectories such as ZenModel if you really wanted to,
but I wouldn't recommend it. It's better to keep these kinds of things in
ZenPacks so you don't have the possibility of being overwritten during
upgrades. Your customizations will also be included in backups if you put
them in ZenPacks.
I know this is an old thread, but are you sure that this actually works? I need to do create a transform library, so I've followed your directions to include a transforms module in one of my ZenPacks.
In event.log I get the following error:
2012-05-31T16:25:57 WARNING zen.Events Error processing transform/mapping on Event Class /Test/MyEventClass
Problem on line 1: AttributeError: 'module' object has no attribute 'changeSummary'
It seems that there's something wrong with how the transforms module is being imported. Any ideas, (I'm on 3.1.x btw)?
Follow Us On Twitter »
||Latest from the Zenoss Blog »||Community||Products||Services||Customers||About Us|
Copyright © 2005-2011 Zenoss, Inc.