Discussion:
Transform variable error
Al Davis
2013-04-12 20:52:46 UTC
Permalink
Al Davis [http://community.zenoss.org/people/awdavis214] created the discussion

"Transform variable error"

To view the discussion, visit: http://community.zenoss.org/message/72811#72811

--------------------------------------------------------------
Sorry for my ignorance but I am working on a transform for a paticular type of device and I am trying to change the summary to the content of one of the fields in the trap information.  The issue that I am having is the name of that field has periods in it which is causing an error.  My question is, is it possible to perfom the following transform and somehow deal with the periods.

import re
evt.summary = evt.tg1000.2.1.2

--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72811#72811]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
rtelford
2013-04-13 05:00:08 UTC
Permalink
rtelford [http://community.zenoss.org/people/rtelford] created the discussion

"Re: Transform variable error"

To view the discussion, visit: http://community.zenoss.org/message/72812#72812

--------------------------------------------------------------
I do this kind of thing all the time.

First thing to note is that if you are using Zenoss Core4 your attributes have moved to 'evt.details'

try this.
evt.summary = getattr('evt.details', 'tg1000.2.1.2', '')
if you are still having trouble you can try some logging, dump all the event details as follows.
log.warn('EVT DETAILS %s', evt.details._map.keys())
Note with this we have to violate the Zenoss Event scema and peer into _map, this is because the event object no longer behaves like a dictinoary. A baffeling omission on the behalf of the developers.

If you are still having trouble, you can dump the entire event object and save it as a python pickle. We do this do save events for regression testing of event transforms.
from cPickle import dump
    dump(evt, f, -1)
Another thing to watch out with core 4 is type, I have found that a lot of event details that were previously integers are now strings and I have to explicity convert them in the transform for my old code to work.

Im about to put together a how to convert event transforms from Zenoss 3 to Zenoss 4, as there are many changes under the hood that will stump you.  The absense of evt.keys() for example was almost a "show stopper" for me.

I hope this helps,
Rod.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72812#72812]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jcurry
2013-04-15 11:43:08 UTC
Permalink
jcurry [http://community.zenoss.org/people/jcurry] created the discussion

"Re: Transform variable error"

To view the discussion, visit: http://community.zenoss.org/message/72844#72844

--------------------------------------------------------------
What good hints from Rod here!

If you want to dig lots deeper into event architecture and transforms, including an example of what you trying to do, pull my Zenoss Event Management paper from http://www.skills-1st.co.uk/papers/jane/zenoss4-events/ http://www.skills-1st.co.uk/papers/jane/zenoss4-events/ .

Cheers,
Jane
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72844#72844]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Al Davis
2013-04-15 16:43:57 UTC
Permalink
Al Davis [http://community.zenoss.org/people/awdavis214] created the discussion

"Re: Transform variable error"

To view the discussion, visit: http://community.zenoss.org/message/72831#72831

--------------------------------------------------------------
Thanks for helping me get on the right path..  The following worked:

evt.summary = getattr(evt, "tg1000.2.1.2")

--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72831#72831]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...