For a project involving Zenoss Core 4 and a HaaS solution maintained by another team, we needed a module to interact with the Zenoss JSON API to get the list of events for specific devices. Browsing around I found this python-zenoss module to work with the Zenoss JSON API. However I was experiencing some issues when installing it, so I decided to create my own Python package to provide a different way to interact with the Zenoss JSON API according to our specific needs.
The package would be installed locally using pip, and all its functionality should be easily accessible using from and import commands in Python.
To start working in our package we will create a base directory. The directory's name will resemble our package's name. For naming, we should following these guidelines:
All lowercase
Underscore-separated or no word separators at all (don’t use hyphens)
Debian packaging is a nice way to organize our software so that it can be installed and uninstalled with more ease. In this post we will go through the basics of creating a simple Debian package in Ubuntu 14.04 LTS.
Package Source & Structure
We will first create our working space for our package along with the necessary basic structure needed. For this example, we will create a directory for our package source, using the package title and 3 digit versioning in the directory's title:
mkdir mypackage-1.0.0
Inside our package, we will need a directory where we will hold the control files that give the Debian package the desired behavior:
cd mypackage-1.0.0
mkdir DEBIAN
touch DEBIAN/control
This control file will describe our package to the Debian package manager (dpkg). Inside, we can specify information about the package such as version, architecture, dependencies, maintainer, etc, as shown below:
Package: mypackage
Version: 1.0-0
Section: base
Priority: optional
Architecture: all
Depends: python2.7
Maintainer: Andres Alvarez <myemail@gmail.com>
Description: A new and improved C++ Compiler
With this basic setup, we now have a basic working package that can be handled by the Debian package manager, albeit, with no contents.