Setting Up a Development Environment

Setting Up a Development Environment

This page describes how to setup a working Python development environment that can be used in developing manila on Ubuntu, Fedora or Mac OS X. These instructions assume you’re already familiar with git. Refer to GettingTheCode for additional information.

Following these instructions will allow you to run the manila unit tests. If you want to be able to run manila (i.e., create NFS/CIFS shares), you will also need to install dependent projects: Nova, Neutron, Cinder and Glance. For this purpose ‘devstack’ project can be used (A documented shell script to build complete OpenStack development environments).

Virtual environments

Manila development uses virtualenv to track and manage Python dependencies while in development and testing. This allows you to install all of the Python package dependencies in a virtual environment or “virtualenv” (a special subdirectory of your manila directory), instead of installing the packages at the system level.

Note

Virtualenv is useful for running the unit tests, but is not typically used for full integration testing or production usage.

Linux Systems

Note

This section is tested for manila on Ubuntu and Fedora-based distributions. Feel free to add notes and change according to your experiences or operating system.

Install the prerequisite packages.

  • On Ubuntu/Debian:

    sudo apt-get install python-dev libssl-dev python-pip \
    libmysqlclient-dev libxml2-dev libxslt-dev libpq-dev git \
    git-review libffi-dev gettext graphviz libjpeg-dev
    
  • On Fedora 21/RHEL7/Centos7:

    sudo yum install python-devel openssl-devel python-pip mysql-devel \
    libxml2-devel libxslt-devel postgresql-devel git git-review \
    libffi-devel gettext graphviz gcc libjpeg-turbo-devel \
    python-tox python3-devel python3
    

Note

If using RHEL and yum reports “No package python-pip available” and “No package git-review available”, use the EPEL software repository. Instructions can be found at http://fedoraproject.org/wiki/EPEL/FAQ#howtouse.

  • On Fedora 22 and higher:

    sudo dnf install python-devel openssl-devel python-pip mysql-devel \
    libxml2-devel libxslt-devel postgresql-devel git git-review \
    libffi-devel gettext graphviz gcc libjpeg-turbo-devel \
    python-tox python3-devel python3
    

Note

Additionally, if using Fedora 23, redhat-rpm-config package should be installed so that development virtualenv can be built successfully.

Mac OS X Systems

Install virtualenv:

sudo easy_install virtualenv

Check the version of OpenSSL you have installed:

openssl version

If you have installed OpenSSL 1.0.0a, which can happen when installing a MacPorts package for OpenSSL, you will see an error when running manila.tests.auth_unittest.AuthTestCase.test_209_can_generate_x509.

The stock version of OpenSSL that ships with Mac OS X 10.6 (OpenSSL 0.9.8l) or Mac OS X 10.7 (OpenSSL 0.9.8r) works fine with manila.

Getting the code

Grab the code:

git clone https://github.com/openstack/manila.git
cd manila

Running unit tests

The unit tests will run by default inside a virtualenv in the .venv directory. Run the unit tests by doing:

./run_tests.sh

The first time you run them, you will be asked if you want to create a virtual environment (hit “y”):

No virtual environment found...create one? (Y/n)

See Unit Tests for more details.

Manually installing and using the virtualenv

You can manually install the virtual environment instead of having run_tests.sh do it for you:

python tools/install_venv.py

This will install all of the Python packages listed in the requirements.txt file into your virtualenv. There will also be some additional packages (pip, distribute, greenlet) that are installed by the tools/install_venv.py file into the virtualenv.

If all goes well, you should get a message something like this:

Manila development environment setup is complete.

To activate the manila virtualenv for the extent of your current shell session you can run:

$ source .venv/bin/activate

Or, if you prefer, you can run commands in the virtualenv on a case by case basis by running:

$ tools/with_venv.sh <your command>

Contributing Your Work

Once your work is complete you may wish to contribute it to the project. Add your name and email address to the Authors file, and also to the .mailmap file if you use multiple email addresses. Your contributions can not be merged into trunk unless you are listed in the Authors file. Manila uses the Gerrit code review system. For information on how to submit your branch to Gerrit, see GerritWorkflow.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.