Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

How To Add A zProperty

VERSION 1 
Created on: Sep 14, 2009 11:16 AM by Noel Brockett - Last Modified:  Apr 20, 2010 4:01 PM by Matt Ray

Instructions for creating a new zProperty for Devices or Events

Adding a zProperty to an Event

EventClass

In EventClass.py...

 

...
def buildZProperties(self):
    edict = self.getDmdRoot("Events")
    ...
    edict._setProperty("zNewProperty", "default value")
    edict._setProperty("zNewIntegerProperty", -1, type="int")
    edict._setProperty("zNewFloatProperties", 10.01, type="float")
    edict._setProperty("zNewListProperty", ["default value", "another default value"], type="lines")
    edict._setProperty("zNewBooleanProperty", False, type="boolean")
    ...
...

 

Adding a new property to the EventClass is as easy adding a new line to the buildZProperties method. You need to set a new property at the "Events" level.

Adding a zProperty to an Device

DeviceClass

In DeviceClass.py

 

...
def buildDeviceTreeProperties(self):
    devs = self.getDmdRoot("Devices")
    ...
    devs._setProperty("zNewProperty", "default value")
    devs._setProperty("zNewIntegerProperty", -1, type="int")
    devs._setProperty("zNewFloatProperties", 10.01, type="float")
    devs._setProperty("zNewListProperty", ["default value", "another default value"], type="lines")
    devs._setProperty("zNewBooleanProperty", False, type="boolean")
    ...
...

 

Adding a new property to the DeviceClass is as easy adding a new line to the buildDeviceTreeProperties method. You need to set a new property at the "Devices" level.

Migrating the zProperty Code

Create a new file in $ZENHOME/Products/ZenModel/migrate/zNewProperty.py

 

__doc__='''

Add zNewProperty to !DeviceClass.

$Id:$
'''
import Migrate

class zNewProperty(Migrate.Step):
    version = Migrate.Version(1, 1, 0)

    def cutover(self, dmd):
        if not dmd.Devices.hasProperty("zNewProperty"):
            dmd.Devices._setProperty("zNewProperty", "default value here")

zNewProperty()

 

When a zenmigrate is executed, this code will create the new zProperty for all Devices. Do not forget to update the Migrate.Version to your current working version. For more information on migrating: The specified document was not found.

Comments (0)