Skip navigation
4095 Views 5 Replies Latest reply: Jul 10, 2012 1:53 PM by giocar RSS
tec Rank: Green Belt 197 posts since
Oct 21, 2008
Currently Being Moderated

Jul 15, 2011 12:48 PM

Zenoss Transform function library?

Hi

 

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..

 

Comment welcome...

 

thanks..

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    1. Jul 17, 2011 1:14 AM (in response to tec)
    Re: Zenoss Transform function library?

    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

    for example.

     

    from ZenPacks.org.Thing import transforms

    transforms.changeSummary(evt)

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    3. Jul 17, 2011 10:43 PM (in response to tec)
    Re: Zenoss Transform function library?

    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.

  • James Stewart Rank: Green Belt 91 posts since
    Dec 1, 2010
    Currently Being Moderated
    4. May 31, 2012 2:53 AM (in response to Chet Luther)
    Re: Zenoss Transform function library?

    Hi Chet,

     

    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'

    transforms.changeSummary(evt)

     

    It seems that there's something wrong with how the transforms module is being imported. Any ideas, (I'm on 3.1.x btw)?

     

    Cheers,

     

    James

  • giocar Newbie 2 posts since
    May 23, 2012
    Currently Being Moderated
    5. Jul 10, 2012 1:53 PM (in response to James Stewart)
    Re: Zenoss Transform function library?

    Hi James,

     

    it works for me in 4.1.1, just remove self from the args and use

     

    def changeSummary(evt):

        evt.summary = 'I changed this'

     

    Regards,

    Gianni

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points