zenpack development with jane curry
TRANSCRIPT
ZENPACK DEVELOPMENT FROM A [email protected] ZENMISTRESS
© 2016 All Rights [email protected] #GALAXZ16
© 2016 All Rights [email protected] #GALAXZ16
400+ pages (lots of screenshots) Architecture Zenoss core code Stuff for rookies
Stuff for the initiated
Stuff for seasoned ZenPackers
Stuff for gurus
All code samples on GitHub
ZENPACK DEVELOPERS' GUIDE
© 2016 All Rights [email protected] #GALAXZ16
Create a Simple ZenPack through GUI (Zenoss 4) or “zenpack create” CLI (Zenoss 5) ZenPack will be in development mode ie. you can add stuff through the GUI
LOTS of “Add to ZenPack” menus templates, event classes, MIBs, device classes, processes*, IP services*, Windows
services*, commands NOT device instances, triggers, notifcations
Don't forget to “Export ZenPack” Creates egg file Writes objects/objects.xml
Install ZenPack in development mode for testing; install egg version in production “zenpack --remove” deletes all objects in the ZenPack
including instances of such objects
ROOKIE HELP
© 2016 All Rights [email protected] #GALAXZ16
eggs are magic! unzip ZenPacks.community.LogMatch-1.0.2-py2.7.egg
ZenPacks community
LogMatchobjectsobjects.xmlmodeler/plugins
Exporting the ZenPack from the GUI creates the egg
ROOKIE HELP
© 2016 All Rights [email protected] #GALAXZ16
Several examples for creating new Zenoss device class and new components zenpacklib is your friend and can create:
Object class for device, object class for components, attributes for each, relationships for each, new zProperties, performance templates
No Python code; no JavaScript Actually, there is - but it is auto-generated and held in memory
zenpacklib does not create modeler plugins Must be written in Python under modeler/plugins Start from someone else's code and modify Must understand exactly what zenpacklib auto-generates
Define relationship names explicitly (don't let them default)
HELP FOR THE INITIATED
© 2016 All Rights [email protected] #GALAXZ16
Name relationships explicitly in zenpack.yamlUserGroupDevice: relationships: userGroups: # down to UserGroup component label: userGroupsUserGroup: relationships: userGroupDevice: # back to the containing device label: userGroupDevice users: # down to User sub-component label: usersUser: relationships: primaryUserGroup: # back to the containing primary UserGroup label: primaryUserGroup class_relationships: - UserGroupDevice(userGroups) 1:MC UserGroup(userGroupDevice) - UserGroup(users) 1:MC User(primaryUserGroup)
HELP FOR THE INITIATED
© 2016 All Rights [email protected] #GALAXZ16
© 2016 All Rights [email protected] #GALAXZ16
You MUST have a test environment understand the minimum daemon recycle requirements subset of daemons active
Complex sample ZenPacks using SNMP, COMMAND and Python Example to convert a COMMAND ZenPack to use PythonCollector
Twisted Example to convert from traditional coded ZenPack to zenpacklib Several examples of creating new datasources Sample to include event classes, triggers and notifications in ZenPack ZenPacks.community.MenuExamples Use try...except Python construct to trap errors and report back “nicely” Testing, debugging, “Where do things go wrong?” sections
HELP FOR SEASONED ZENPACKERS
© 2016 All Rights [email protected] #GALAXZ16
Searching for something in Zenoss core codecd $ZENHOME/Productsgrep xyzzy `find . -name “*.py”`
zendmd and ZMI are your friends!d = find('zen42.class.example.org')for k, v in d.__dict__.items(): print k, v
_lastChange 1462446603.82 local attributetest1 <RRDTemplate at test1> local templatecSite Taplow ) custom propertiescRigHost [] )versionTag 5.5 ) device attributessnmpContact Jane Curry ) aggregatingPools <ToManyContRelationship at aggregatingPools> ToManyCont relationshipcomponentSearch <ZCatalog at componentSearch>
HELP FOR SEASONED ZENPACKERS
© 2016 All Rights [email protected] #GALAXZ16
© 2016 All Rights [email protected] #GALAXZ16
Dev Guide has whole sections for gurus, plus comments in-line Zenoss architecture Zenoss base code
Object classes under $ZENHOME/Products/ZenModel and their inheritance Relationship diagrams Details of core modeler plugin classes and datasource classes
Monkey patching zenpacklib example of renderer and object methods Python Twisted library
code must be non-blocking; must return Twisted Deferred Python datasource plugins - what happens in collectors vs zenhub?
judicious config_key methods Understanding detailed logs
GURU HELP
© 2016 All Rights [email protected] #GALAXZ16
Taken 5 years to get this far! Needs help from YOU! Samples on GitHub
https://github.com/ZenossDevGuide Samples deliberately have very minimal setup requirements
Sometimes rather contorted; some definitely not production strength All have README.rst Some ZenPack repositories have multiple branches
Sample “lead reviewers” required Especially anyone with Zenoss 5 experience
Dev Guide “lead reviewers” required for sections Open discussion on ZenPack Dev forum - http://www.zenoss.org/forums/zenpack-development Come and chat in the Community Area in Griffin Hall
ZENPACK DEVELOPERS' GUIDE - NEXT STEPS
© 2016 All Rights [email protected] #GALAXZ16