This section describes how to setup a working Python development environment that you can use in developing Zaqar on Ubuntu or Fedora. These instructions assume that you are familiar with Git. Refer to GettingTheCode for additional information.
Use virtualenv to track and manage Python dependencies for developing and testing Zaqar. Using virtualenv enables you to install Python dependencies in an isolated virtual environment, instead of installing the packages at the system level.
Note
Virtualenv is useful for development purposes, but is not typically used for full integration testing or production usage. If you want to learn about production best practices, check out the OpenStack Operations Guide.
Note
This section is tested for Zaqar on Ubuntu 14.04 (Trusty) and Fedora-based (RHEL 6.1) distributions. Feel free to add notes and change according to your experiences or operating system. Learn more about contributing to Zaqar documentation in the Write the Docs! wiki.
Install the prerequisite packages.
On Ubuntu:
$ sudo apt-get install gcc python-pip libxml2-dev libxslt1-dev python-dev zlib1g-dev
On Fedora-based distributions (e.g., Fedora/RHEL/CentOS):
$ sudo yum install gcc python-pip libxml2-devel libxslt-devel python-devel
You also need to have MongoDB installed and running.
On Ubuntu, follow the instructions in the MongoDB on Ubuntu Installation Guide.
On Fedora-based distributions, follow the instructions in the MongoDB on Red Hat Enterprise, CentOS, Fedora, or Amazon Linux Installation Guide.
From your home folder create the ~/.zaqar folder. This directory holds the configuration files for Zaqar:
$ mkdir ~/.zaqar
Generate the sample configuration file zaqar/etc/zaqar.conf.sample:
$ pip install tox
$ cd zaqar
$ tox -e genconfig
Copy the Zaqar configuration samples to the directory ~/.zaqar/:
$ cp etc/zaqar.conf.sample ~/.zaqar/zaqar.conf
$ cp etc/logging.conf.sample ~/.zaqar/logging.conf
Find the [drivers] section in ~/.zaqar/zaqar.conf and specify mongodb as the message store:
message_store = mongodb
management_store = mongodb
Find the [drivers:message_store:mongodb] section and modify the URI to point to your local mongod instance:
uri = mongodb://$MONGODB_HOST:$MONGODB_PORT # default = mongodb://localhost:27017
For logging, find the [handler_file] section in ~/.zaqar/logging.conf and modify as desired:
args=('zaqar.log', 'w')
Install virtualenv by running:
$ pip install virtualenv
Create and activate a virtual environment:
$ virtualenv zaqarenv
$ source zaqarenv/bin/activate
Install Zaqar:
$ pip install -e .
Install the required Python binding for MongoDB:
$ pip install pymongo
Start the Zaqar server:
$ zaqar-server -v
Verify Zaqar is running by creating a queue:
$ curl -i -X PUT http://localhost:8888/v1/queues/samplequeue -H "Content-type: application/json"
Get ready to code!
Note
You can run the Zaqar server in the foreground by passing the –nodaemon flag:
$ zaqar-server -v --nodaemon
With this method you get immediate visual feedback and it is easier to kill and restart the process.
If you do so, you have to run the cURL test (step 5) in a separate terminal.
If you want to use Zaqar in an integrated OpenStack developing environment, you can add it to your DevStack deployment.
To do this, you first need to add the following setting to your local.conf:
enable_plugin zaqar https://github.com/openstack/zaqar
Then run the stack.sh script as usual.
After running the DevStack script, you can start the Zaqar server and test it by following steps 5 and 6 from the previous section.
See Running tests for details.
Once your work is complete, you may wish to contribute it to the project. Zaqar uses the Gerrit code review system. For information on how to submit your branch to Gerrit, see GerritWorkflow.