Developer's Guide

  • Docs Home
  • Community Home

3. ZenPack Structure and Contents

This section describes the files and directory structures that make up most ZenPacks. A more detailed source of information about Python Eggs, entry points and other technical details of building eggs is found here.

Note

The $ZENHOME/Products/ZenModel/ZenPackTemplate directory contains the template files and directories used when Zenoss creates a ZenPack. If you decide to change these files, note that these changes will not be preserved across upgrades.

A ZenPack has the concept of a namespace, so that multiple people or organizations can create similar ZenPack names without their code colliding with each other. In this example, the name of the ZenPack is ZenPacks.pkg.zpid, where pkg is the package name and zpid is the ZenPack id.

In the $ZENHOME/ZenPacks/ directory, you will find the directory ZenPacks.pkg.zpid with the following contents (abbreviated for clarity):

build1
build/bdist.linux-i686
build/lib
build/lib/ZenPacks
...
dist2
dist/ZenPacks.pkg.zpid-version_id-py2.4.egg
INSTALL.txt
README.txt
setup.py3
ZenPacks4
ZenPacks/__init__.py
ZenPacks/pkg
ZenPacks/pkg/__init__.py
ZenPacks/pkg/zpid5
ZenPacks/pkg/zpid/__init__.py6
ZenPacks/pkg/zpid/daemons7
ZenPacks/pkg/zpid/datasources8
ZenPacks/pkg/zpid/datasources/__init__.py
ZenPacks/pkg/zpid/lib9
ZenPacks/pkg/zpid/lib/__init__.py
ZenPacks/pkg/zpid/libexec10
ZenPacks/pkg/zpid/migrate11
ZenPacks/pkg/zpid/migrate/__init__.py
ZenPacks/pkg/zpid/modeler12
ZenPacks/pkg/zpid/modeler/__init__.py
ZenPacks/pkg/zpid/modeler/plugins
ZenPacks/pkg/zpid/modeler/plugins/__init__.py
ZenPacks/pkg/zpid/objects13
ZenPacks/pkg/zpid/objects/objects.xml
ZenPacks/pkg/zpid/parsers14
ZenPacks/pkg/zpid/parsers/__init__.py
ZenPacks/pkg/zpid/reports15
ZenPacks/pkg/zpid/services(16)
ZenPacks/pkg/zpid/services/__init__.py
ZenPacks/pkg/zpid/skins(17)
ZenPacks/pkg/zpid/skins/ZenPacks.pkg.zpid
ZenPacks.pkg.zpid.egg-info(18)
ZenPacks.pkg.zpid.egg-info/entry_points.txt
ZenPacks.pkg.zpid.egg-info/namespace_packages.txt
ZenPacks.pkg.zpid.egg-info/not-zip-safe
ZenPacks.pkg.zpid.egg-info/PKG-INFO
ZenPacks.pkg.zpid.egg-info/SOURCES.txt
ZenPacks.pkg.zpid.egg-info/top_level.txt

1

This directory is created by Python when the ZenPack is exported to an egg file or when it is installed from source. This directory can safely be deleted at any time if you wish and need not be kept within any version control system.

2

This directory is created when the ZenPack is exported to an egg file. The egg file is initially created within here then copied to the $ZENHOME/export directory. This directory can safely be deleted at any time if you wish and need not be kept within any version control system.

3

This file contains parameters for use by setuptools and distutils in creating eggs and doing source installs. Zenoss creates an appropriate setup.py when a ZenPack is created. ZenPack developers should usually edit this information through the ZenPack edit page within Zenoss rather than directly in the setup.py file.

Any time a ZenPack is saved or exported via the GUI Zenoss will modify certain values at the top of the setup.py file. The lines that Zenoss modifies are clearly commented and segregated at the top of the file. If you wish to make changes to setup.py you can safely do so as long as you leave those lines intact.

4

This directory mirrors the dotted name structure of your ZenPack name. For example, if your ZenPack name is ZenPacks.MyCompany.MyZenPack then this directory will contain a directory named MyCompany which will contain a MyZenPack directory. This last directory with the same name as the last part of your ZenPack name is where most of the ZenPack code resides. The structure of that directory is very similar to that of previous non-egg ZenPacks.

5

This is the directory whose name is that of the last part of your dotted ZenPack name.

6

This file contains any code that needs to be executed when the ZenPack is loaded. Zenoss loads all installed ZenPacks on startup. Typically this file contains a few lines that will register a skins directory if the ZenPack provides one. Also, if this class contains a class named ZenPack then on installation Zenoss will create an instance of that class rather than the base ZenPack class in the object database.

7

See below for more details on providing daemons in ZenPacks.

8

See below for more details on providing data source classes in ZenPacks.

9

This directory is intended to hold any 3rd party modules or other code your ZenPack depends on. A module named Foo in this directory would be imported with

import ZenPacks.MyCompany.MyZenPack.lib.Foo

10

This directory is intended to hold plugins, such as Nagios-style or Cacti-style plugins.

11

See below for more details on migrating between versions of your ZenPack.

12

See below for more details on providing modeler plugins in ZenPacks.

13

Database objects such as Device Classes and Performance Templates that are added to the ZenPack via the GUI are exported to an objects.xml file in this directory. When the ZenPack is installed on another system those objects will be copied into that object database.

14

This directory contains any command parsers provided by the ZenPack. See the section that discusses new platform command parsers for more details.

15

This directory contains any report plugins provided by the ZenPack.

(16)

Zenoss daemons usually communicate with zenhub to retrieve their configuration, send events, and write performance data. If a ZenPack provides a daemon then it typically will also provide a ZenHub service for that daemon. See the section on ZenHub for further details.

(17)

This directory contains any skins directories that should be added to Zope. Note that this contains directories of skins, not the skin files themselves. If you include skins directories make sure that the __init__.py file in the directory above skins is registering this directory. (The default __init__.py file provided in new ZenPacks does this for you.)

(18)

This directory contains files which describe the egg meta-data. This is created when the egg file is generated or the ZenPack is installed from source. This directory can safely be deleted at any time if you wish and need not be kept within any version control system.

This file is updated every time a ZenPack is edited and saved. ZenPack developers should normally not edit this file manually.