By: Andy Hart >> Zenoss is committed to our ZenPack technology and simplifying the development of ZenPacks while simultaneously improving quality using a declarative approach.
In my 20+ years of programming, I’ve learned to automate menial and repeatable tasks. When I was writing C++ code, I developed a simple ‘sed’ script that generated base and derived classes as well as some simple pattern classes like the ‘singleton’ and ‘MVC’ patterns. Why? Because for every class I wrote, I needed the ‘canonical’ behaviors of the language to be implemented. I was rewriting those behaviors when I needed to be working on the real problem, the business model and logic.
If you have written code for ZenPacks, you have faced a similar situation. As you write the code, much of it seems menial and is not focused on the real problem at hand. Furthermore, every line of code you write has a potential for error. If those menial tasks could be removed, then you are able to generate ZenPacks faster and the quality improves with it.
ZenPack Lib, the ZenPack API, does just that! It moves the ZenPack development to a declarative solution. For example, the snippet of code below defines a “NetBotz” device with a temperature sensor with the following YAML:
classes:
NetBotzDevice:
base: [zenpacklib.Device]
label: NetBotz
properties:
temp_sensor_count:
type: int
NetBotzTemperatureSensor:
base: [zenpacklib.Component]
label: Temperature Sensor
properties:
enclosure:
label: Enclosure
port:
label: Port
class_relationships:
NetBotzDevice 1:MC NetBotzTemperatureSensor
device_classes:
/NetBotz:
zProperties:
zPythonClass: ZenPacks.training.NetBotz.NetBotzDevice
zSnmpMonitorIgnore: false
zCollectorPlugins:
- training.snmp.NetBotz
- zenoss.snmp.NewDeviceMap
- zenoss.snmp.DeviceMap
- zenoss.snmp.InterfaceMap
Notice the device class and its properties are defined as well as the components and their properties that they contain. It then defines the relationship between the components and the device class. The code for the business logic is still required. However, the code to build the relationships and define properties, the most error prone and complex aspects of the code, has been made declarative. This simple declarative solution reduces code development by roughly 85%.
Zenoss is committed to our ZenPack technology and simplifying the development of ZenPacks while simultaneously improving quality using a declarative approach.
To learn more about the ZenPack Lib, check out the tutorial. For more information about Zenoss ZenPacks, architecture, and datasheets, visit the Zenoss Resource Center.