TECHZEN Zenoss User Community ARCHIVE  

How to add fields to the main /Devices class?

Subject: How to add fields to the main /Devices class?
Author: [Not Specified]
Posted: 2016-06-24 09:39

I have been successful at adding fields to a Device Class I created, but I have some functionnality I want to add at the root /Devices class.

In my tests, I've created a file named Device.py at the root of my ZenPack with the following entry:

= None

_properties = Device._properties + (

{'id': '', 'type': 'int'},

)

How do I do the same for the main /Devices class

Manuel



Subject: Are these zProperties that
Author: Jane Curry
Posted: 2016-07-07 09:33

Are these zProperties that you want to create or some other attribute you want to make available to all devices

If zProperties, then you can add them simply in the __init__.py in the base directory of your ZenPack. Have a look at the sample in https://github.com/ZenossDevGuide/ZenPacks.community.LogMatch/blob/master/ZenPacks/community/LogMatch/__init__.py The lines are commented out but are perfectly good.

If you want a new attribute on all devices, then have a look at the device branch of the same ZenPack -http://github.com/ZenossDevGuide/ZenPacks.community.LogMatch/blob/device/ZenPacks/community/LogMatch/__init__.py . Examples there monkey patch versionTag and versionDate attributes on to Device.

Cheers,

Jane

Email: jane.curry@skills-1st.co.uk    Web: https://www.skills-1st.co.uk



< Previous
Help for a new user
  Next
ZenPack Developers' Guide - input on chapter 3 please
>