|
1 | | -This directory is a template for the creation of new ZenPacks. When a user creates a new ZenPack via the Zenoss gui this directory is copied, modified and installed in $ZENHOME/ZenPacks. |
| 1 | +# ZenPack Template |
| 2 | +This README describes the structure of the ZenPack template that gets |
| 3 | +automatically created by Zenoss when you add a ZenPack through the web |
| 4 | +interface. |
| 5 | + |
| 6 | +## Files |
| 7 | +At the top-level a ZenPack must have a setup.py. Almost always a MANIFEST.in |
| 8 | +file should exist, and in cases where external dependencies must be built for |
| 9 | +inclusion in the ZenPack, a GNUmakefile. Examples of these files with inline |
| 10 | +comments are included in this template. |
| 11 | + |
| 12 | +Also included in the ZenPackTemplate is a configure.zcml. As more of Zenoss' |
| 13 | +extensibility moves to using ZCA (Zope Component Architecture) this file |
| 14 | +becomes crucial to hooking into various aspects of Zenoss. |
| 15 | + |
| 16 | +## Files and Subdirectories |
| 17 | +The following sections describe the purpose and use for each of the default |
| 18 | +subdirectories. Note that if the described functionality is not of use in your |
| 19 | +ZenPack it is safe to remove any of the default directories. |
| 20 | + |
| 21 | +### src/ |
| 22 | +The src/ top-level directory in ZenPacks is the conventional place to add |
| 23 | +third-party dependencies to your ZenPack. It should only be used as a staging |
| 24 | +area to do any build work necessary for the dependency. |
| 25 | + |
| 26 | +See GNUmakefile (or GNUmakefile.example) for examples of how to have |
| 27 | +your third-party dependencies automatically compiled and installed at the right |
| 28 | +time and into the right location. |
| 29 | + |
| 30 | +### ZenPacks/NAMESPACE/PACKNAME/ |
| 31 | +The following sections describe the directories contained within the |
| 32 | +namespaced ZenPacks/NAMESPACE/PACKNAME/ subdirectories. |
| 33 | + |
| 34 | +#### bin/ |
| 35 | +Any general tools delivered by your ZenPack that would be used by the Zenoss |
| 36 | +administrator at the command line should go into this directory by convention. |
| 37 | +When the ZenPack is installed all files in this directory will be made |
| 38 | +executable. |
| 39 | + |
| 40 | +#### browser/ |
| 41 | +The browser subdirectory should contain all code and configuration that's |
| 42 | +specific to the Zenoss web interface. The provided configure.zcml will |
| 43 | +automatically load the example browser/configure.zcml and register the |
| 44 | +browser/resources/ subdirectory to serve static web content. |
| 45 | + |
| 46 | +#### daemons/ |
| 47 | +All files in the daemons/ subdirectory get special handling. Upon installing |
| 48 | +the ZenPack, the following actions will occur. |
| 49 | + |
| 50 | + 1. The file will be made executable (chmod 0755) |
| 51 | + 2. A symlink to the file will be created in $ZENHOME/bin/ |
| 52 | + 3. An configuration file will be generated at $ZENHOME/etc/DAEMON_NAME.conf |
| 53 | + |
| 54 | +Assuming that you don't have a $ZENHOME/etc/DAEMONS_TXT_ONLY file this daemon |
| 55 | +will also become part of the normal zenoss start and stop processes. |
| 56 | + |
| 57 | +You can find an example daemon control script in daemons/zenexample. For most |
| 58 | +purposes this file can be renamed to the name of the daemon you want to create |
| 59 | +and modified to change the DAEMON_NAME. No other modifications are typically |
| 60 | +needed. Note that this example control script does expect to launch the real |
| 61 | +daemon code which should be located at ../DAEMON_NAME.py. |
| 62 | + |
| 63 | +#### datasources/ |
| 64 | +Any new datasource types you want to add must be added as classes into the |
| 65 | +datasources/ subdirectory. When Zenoss is building the list of available |
| 66 | +datasources it will scan the datasources/ subdirectory for all installed |
| 67 | +ZenPacks. |
| 68 | + |
| 69 | +An example datasource at datasources/ExampleDataSource.py.example. |
| 70 | + |
| 71 | +#### lib/ |
| 72 | +The lib/ directory should be the installation target for any third-party |
| 73 | +libraries that are built by the GNUmakefile. It can also be used as the |
| 74 | +conventional location to drop Python-only libraries that don't require |
| 75 | +any compilation or special installation. |
| 76 | + |
| 77 | +#### libexec/ |
| 78 | +Any scripts executed by COMMAND datasources in your ZenPack go in this |
| 79 | +directory by convention. When the ZenPack is installed all files in this |
| 80 | +directory will be made executable. |
| 81 | + |
| 82 | +#### migrate/ |
| 83 | +ZenPacks can include migrate scripts that allow you to run custom code to |
| 84 | +handle any tasks that are needed to upgrade your ZenPack from one version to |
| 85 | +another. All .py files in this migrate/ subdirectory will be evaluated when the |
| 86 | +ZenPack is installed. |
| 87 | + |
| 88 | +You can find an example migrate script at migrate/ExampleMigration.py. |
| 89 | + |
| 90 | +#### modeler/ |
| 91 | +Any modeler plugins distributed with your ZenPack must be located under the |
| 92 | +plugins/ subdirectory. The directory structure and filenames under plugins/ |
| 93 | +map directly to the plugins' name in the user interface. For example, if you |
| 94 | +wanted to create a modeler plugin called "community.snmp.ExampleMap" you would |
| 95 | +create the following directory structure. |
| 96 | + |
| 97 | +It is recommended that the first portion of the namespace be a short lowercase |
| 98 | +form of your name, or organization's name. Alternatively you can choose to use |
| 99 | +"community" if you plan to publish the ZenPack and are open to outside |
| 100 | +contributions. Zenoss, Inc. will always use "zenoss." The second portion of the |
| 101 | +namespace can be the protocol that is used to collect the data. If you are not |
| 102 | +using a common protocol it is acceptable to skip the second portion of the |
| 103 | +namespace and have something like "community.MongoDB" instead. |
| 104 | + |
| 105 | +plugins/ |
| 106 | + __init__.py |
| 107 | + community/ |
| 108 | + __init__.py |
| 109 | + snmp/ |
| 110 | + __init__.py |
| 111 | + ExampleMap.py |
| 112 | + |
| 113 | +Note that the __init__.py files must exist and should be empty files. Otherwise |
| 114 | +your modeler plugins won't be imported and usable within Zenoss. |
| 115 | + |
| 116 | +#### objects/ |
| 117 | +All .xml files in this objects/ directory will be loaded into the object |
| 118 | +database when the ZenPack installs. All of the objects defined in the XML files |
| 119 | +will be automatically associated with the ZenPack. |
| 120 | + |
| 121 | +When you export the ZenPack from the user interface all objects associated with |
| 122 | +the ZenPack will be exported into a file called "objects.xml" specifically. For |
| 123 | +this reason it is recommended to let Zenoss manage the objects.xml file and to |
| 124 | +never manually create or modify any .xml files in this directory unless you |
| 125 | +know what you're doing. |
| 126 | + |
| 127 | +When a ZenPack is removed, any objects associated with the ZenPack will be |
| 128 | +recursively removed from Zenoss. For example, if you associated the /Server |
| 129 | +device class with your ZenPack and removed the ZenPack, the /Server device |
| 130 | +class, and all devices within it would also be deleted. |
| 131 | + |
| 132 | +When a ZenPack is upgraded, or re-installed on top of itself, all objects in |
| 133 | +the XML files are overlaid on the existing object database. This results in a |
| 134 | +merge of the existing objects and what are defined in the XML files with the |
| 135 | +XML file properties and relationships winning any conflicts. |
| 136 | + |
| 137 | +#### reports/ |
| 138 | +Custom reports will be loaded from this directory when the ZenPack is |
| 139 | +installed. Subdirectories (with the exception of plugins/) will be mapped |
| 140 | +directly to the report folders in the web interface. So if you add a .rpt file |
| 141 | +into a subdirectory named "Performance Reports" you will find your report in |
| 142 | +the Performance Reports folder in the web interface after installing the |
| 143 | +ZenPack. |
| 144 | + |
| 145 | +The plugins/ subdirectory should include any Python plugins your custom reports |
| 146 | +call. So if your .rpt file contains a line such as the following.. |
| 147 | + |
| 148 | +objects python:here.ReportServer.plugin('myplugin', tableState); |
| 149 | + |
| 150 | +There should be a corresponding myplugin.py file in the plugins/ subdirectory. |
| 151 | + |
| 152 | +You can find an example report at Example Reports/Example Report.rpt.example |
| 153 | +that uses a plugin which can be found at plugins/example_plugin.py. |
| 154 | + |
| 155 | +#### services/ |
| 156 | +ZenHub services will be loaded from the services/ directory. These services |
| 157 | +run inside the zenhub daemon and are responsible from all interaction with |
| 158 | +collector daemons. |
| 159 | + |
| 160 | +You can find an example service at services/ExampleConfigService.py. |
| 161 | + |
| 162 | +#### tests/ |
| 163 | +All unit tests for your ZenPack should live in this directory. You can find an |
| 164 | +example test suite at tests/testExample.py. |
0 commit comments