Plugin File Structure
Version 4 (Anil Gulecha, 01/04/2011 03:03 am)
| 1 | 1 | Plugin File Structure |
|
|---|---|---|---|
| 2 | 1 | ===================== |
|
| 3 | 1 | ||
| 4 | 1 | We will take a look at how a plugin is organized, and what files consist a plugin. |
|
| 5 | 1 | ||
| 6 | 1 | NexentaStor plugins are a collection of debian packages. Typically, a plugin can consist of any plugin that extends the three components of the Nexenta Appliance, namely: **nms** (Nexenta Management Service), **nmc** (Nexenta Management Console), **nmv** (Nexenta Management View). |
|
| 7 | 1 | ||
| 8 | 3 | Anil Gulecha | The best way to write a plugin is to simply use one of the multiple open plugins as reference to write up an empty plugin with all the initial bits in place. Let's the the following two example plugins and discuss their structure to help understand the purpose of various files : *ddclient* and *simple-encryption*. |
| 9 | 1 | ||
| 10 | 3 | Anil Gulecha | ## Package Example: ddclient ## |
| 11 | 1 | ||
| 12 | 2 | Anil Gulecha |  |
| 13 | 2 | Anil Gulecha | |
| 14 | 1 | This image shows the file structure of the ddclient package. You can download this package offline via the commands listed on the [repository page](http://www.nexentastor.org/projects/ddclient/repository). |
|
| 15 | 1 | ||
| 16 | 1 | <ins>**Files**</ins> |
|
| 17 | 2 | Anil Gulecha | |
| 18 | 2 | Anil Gulecha | The main package directory nmc-ddcleint forms all of plugin, i.e, the plugin only has the nmc component. This folder has another directory (*debian*) and 2 perl modules (*Ddclient.pm*, *metafile.pm*) |
| 19 | 2 | Anil Gulecha | |
| 20 | 2 | Anil Gulecha | * *<ins>Ddclient.pm</ins>* - This is the main plugin module, that provides the functionality required. In this particular case, the plugin is basically a wrapper over underlying ddclient facilities. We will go into a line by line explanation later on. |
| 21 | 2 | Anil Gulecha | |
| 22 | 2 | Anil Gulecha | * *<ins>metafile.pm</ins>* - This module is included in all plugin packages. This includes basic plugin information like name, description, plugin group, etc. We will go into a line by line explanation later on. |
| 23 | 2 | Anil Gulecha | |
| 24 | 2 | Anil Gulecha | * *<ins>debian/</ins>* - This directory is present in any debian package, and contains package meta-information (name, dependencies), and build rules (like a Makefile) that builds the packages. This folder can also optionally contain post/pre install/removal scripts if required by your plugin package. |
| 25 | 2 | Anil Gulecha | |
| 26 | 4 | Anil Gulecha | * *<ins>debian/control</ins>* - This file lays out the information official package name, version, dependencies. In this case the package ddclient (which provides the functionality to sync your IP address with dyndns.org and other services) is listed as a dependency. |
| 27 | 2 | Anil Gulecha | |
| 28 | 2 | Anil Gulecha | * *<ins>debian/changelog</ins>* - This is a plain text changelog that maintains a log of what changes were made subsequent versions. An entry is to be added manually for every version of the package released. The 'dch' command makes it easy to edit this file, and maintain the syntax required. |
| 29 | 2 | Anil Gulecha | |
| 30 | 2 | Anil Gulecha | * *<ins>debian/rules</ins>* - This is the main build file. It is a Makefile that lays out the targets *clean*, *deploy-dirs*, *binary-arch* and *binary*. These respectively clean the workspace, install files in temporary directory structure, builds the binary debian package respectively. |
| 31 | 2 | Anil Gulecha | |
| 32 | 1 | * *<ins>debian/copyright</ins>* - This file includes the licensing information about the package. |
|
| 33 | 4 | Anil Gulecha | |
| 34 | 4 | Anil Gulecha | ## Package Example: simple-encryption ## |
| 35 | 4 | Anil Gulecha | |
| 36 | 4 | Anil Gulecha | The simple-encryption plugin is a slightly more complicated plugin than ddclient. It consists of two packages, one each for nmc and nms. The directory contents is shown below. |
| 37 | 4 | Anil Gulecha | |
| 38 | 4 | Anil Gulecha |  |
| 39 | 4 | Anil Gulecha | |
| 40 | 4 | Anil Gulecha | At the top level are the two package directories: *<ins>nmc-simple-encryption</ins>* and *<ins>nms-simple-encryption</ins>*. We will discuss the new files seen here, and skip what we discussed with the ddclient package. |
| 41 | 4 | Anil Gulecha | |
| 42 | 4 | Anil Gulecha | * *<ins>debian/compat</ins>* - This is an optional file that specifies debhelper compatibility. In all probability you will not have to use this. |
| 43 | 4 | Anil Gulecha | |
| 44 | 4 | Anil Gulecha | * *<ins>nmc-simple-encryption/SimpleEncryption.pm</ins>* - This is the nmc module. When installed, it is loaded by the NexentaStor plugin system, which links the functionality provided into nmc. |
| 45 | 4 | Anil Gulecha | |
| 46 | 4 | Anil Gulecha | * *<ins>nms-simple-encryption/SimpleEncryption.pm</ins>* - This is the nms modules. When installed, it is loaded by the NexentaStor plugin system, which links the functionality provided into nms. |