Jan 21, 2008 8:56 AM
Search for event transform statements?
-
Like (0)
We've been customizing our event class mappings quite a bit. I remember putting a particular Python expression on the Transform (on the event class, drop-down arrow menu | More| Transform) page of an event class, but I can't remember which one.
Is there any way to find the event classes for which we've supplied transform expressions, or search for a particular expression?
>>> for ec in dmd.Events.getSubOrganizers():
... if ec.transform:
... print ec.getOrganizerName()
I am looking to inspect hundreds of mapping transforms for specific text. Extending Chet's solution above: for ec in dmd.Events.getSubOrganizers(): if( ec.transform and ( ec.transform.find( 'TEXT-TO-FIND' ) >=0 ) ): print ec.getOrganizerName() This is great for finding forgotten transforms defined on Event Classes, but what about transforms defined in Event Class Mappings? In zendmd, you can inspect a single mapping transform directly at (e.g.): dmd.Events.Event.Class.Path.instances.mappingName.transform but I have been playing with zendmd for a while and I am stuck on how to iterate down this far and check ALL mappings for ALL event classes. I'm probably missing something that is obvious to a Python guru (which I am not) and I am guessing that I am working a problem that has been solved already. Does anyone in the community have a code fragment that can do what I am trying to do? Thanks, --Mark
Try this:
for subclass in dmd.Events.getSubEventClasses():
if subclass.transform:
print subclass.getOrganizerName() + ':\n\n'
print subclass.transform + '\n\n'
It will print all the EventClass transforms except the one for Events itself, which I figure you can get on your own.
Persistence pays off, I figured this out:
#
# Print all event class mappings (not event classes) that have transforms with specific text in them:
#
for ec in dmd.Events.getSubEventClasses():
for mapping in ec.instances():
if mapping.transform and mapping.transform.find('TEXT-TO-FIND')>=0:
print mapping.absolute_url_path()
Thanks for your suggestion, phongi! --Mark S
phonegi wrote:
Try this:
for subclass in dmd.Events.getSubEventClasses():
if subclass.transform:
print subclass.getOrganizerName() + ':\n\n'
print subclass.transform + '\n\n'
It will print all the EventClass transforms except the one for Events itself, which I figure you can get on your own.
How would you be able to use this in getting a dump of every transform on the server? I have been attempting to use this to retrieve everything, and it is not going well.. Grin..
OK, here try this attached file. It will print ALL the transforms from a given starting point, just login as zenoss and execute
python printTransforms.py [path]
use the following for info:
python printTransforms -h
or
python printTransforms --help
Is this the same as the report in the Event Transforms Report ZenPack?
Matt Ray wrote:
Is this the same as the report in the Event Transforms Report ZenPack?
Somehow the word Doh! comes to mind.. I totally forgot about that ZenPack... Yes, that is exactly what I needed.
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||