~yolanda.robla/nova/precise-security

« back to all changes in this revision

Viewing changes to doc/source/devref/development.environment.rst

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-02 10:56:30 UTC
  • mto: (79.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20111202105630-tjly1gpmdh533s0q
Tags: upstream-2012.1~e2~20111202.11641
ImportĀ upstreamĀ versionĀ 2012.1~e2~20111202.11641

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
Setting Up a Development Environment
19
19
====================================
20
20
 
21
 
This page describes how to setup a working Python development environment that can be used in developing on OpenStack on Ubuntu or Mac OSX. These instructions assume you're already familiar with git. Refer to http://wiki.openstack.org/GettingTheCode for additional information.
 
21
This page describes how to setup a working Python development environment that
 
22
can be used in developing nova on Ubuntu, Fedora or Mac OS X. These
 
23
instructions assume you're already familiar with git. Refer to
 
24
http://wiki.openstack.org/GettingTheCode for additional information.
 
25
 
 
26
Following these instructions will allow you to run the nova unit tests. If you
 
27
want to be able to run nova (i.e., launch VM instances), you will also need to
 
28
install libvirt and at least one of the `supported
 
29
hypervisors`<http://wiki.openstack.org/HypervisorSupportMatrix>_. Running
 
30
nova is currently only supported on Linux, although you can run
 
31
the unit tests on Mac OS X. See :doc:`quickstart` for how to get a working
 
32
version of OpenStack Compute running as quickly as possible.
 
33
 
 
34
Virtual environments
 
35
--------------------
 
36
 
 
37
Nova development uses `virtualenv <http://pypi.python.org/pypi/virtualenv>`_
 
38
to track and manage Python dependencies while in development and testing. This
 
39
allows you to install all of the Python package dependencies in a virtual
 
40
environment or `virtualenv` (a special subdirectory of your nova directory),
 
41
instead of installing the packages at the system level.
 
42
 
 
43
Virtualenv is useful for running the unit tests, but is not typically used
 
44
for full integration testing or production usage.
22
45
 
23
46
Linux Systems
24
47
-------------
25
48
 
26
 
Note: This section is tested for Nova on Ubuntu 10.10-64. Feel free to add notes and change according to your experiences or operating system.
27
 
 
28
 
Bring down the Nova source with git, then:
29
 
::
30
 
  cd <your_src_dir>/nova
31
 
  sudo apt-get install python-dev swig libssl-dev python-pip
32
 
  sudo easy_install nose
33
 
  pip install virtualenv
 
49
Note: This section is tested for Nova on Ubuntu (10.10-64) and
 
50
Fedora-based (RHEL 6.1) distributions. Feel free to add notes and change
 
51
according to your experiences or operating system.
 
52
 
 
53
Install the prerequisite packages.
 
54
 
 
55
On Ubuntu::
 
56
 
 
57
  sudo apt-get install python-dev swig libssl-dev python-pip git-core
 
58
 
 
59
On Fedora-based distributions (e.g., Fedora/RHEL/CentOS/Scientific Linux)::
 
60
 
 
61
  sudo yum install python-devel swig openssl-devel python-pip git
 
62
 
 
63
 
 
64
Mac OS X Systems
 
65
----------------
 
66
 
 
67
Install swig, which is needed to build the M2Crypto Python package. If you are
 
68
using the `homebrew <http://mxcl.github.com/homebrew/>`_, package manager,
 
69
install swig by doing::
 
70
 
 
71
    brew install swig
 
72
 
 
73
Install virtualenv::
 
74
 
 
75
    sudo easy_install virtualenv
 
76
 
 
77
Check the version of OpenSSL you have installed::
 
78
 
 
79
    openssl version
 
80
 
 
81
If you have installed OpenSSL 1.0.0a, which can happen when installing a
 
82
MacPorts package for OpenSSL, you will see an error when running
 
83
``nova.tests.auth_unittest.AuthTestCase.test_209_can_generate_x509``.
 
84
 
 
85
The stock version of OpenSSL that ships with Mac OS X 10.6 (OpenSSL 0.9.8l)
 
86
or Mac OS X 10.7 (OpenSSL 0.9.8r) works fine with nova.
 
87
 
 
88
 
 
89
Getting the code
 
90
----------------
 
91
Grab the code from GitHub::
 
92
 
 
93
    git clone https://github.com/openstack/nova.git
 
94
    cd nova
 
95
 
 
96
 
 
97
Running unit tests
 
98
------------------
 
99
The unit tests will run by default inside a virtualenv in the ``.nova-venv``
 
100
directory. Run the unit tests by doing::
 
101
 
 
102
    ./run_tests.sh
 
103
 
 
104
The first time you run them, you will be asked if you want to create a virtual
 
105
environment (hit "y")::
 
106
 
 
107
    No virtual environment found...create one? (Y/n)
 
108
 
 
109
See :doc:`unit_tests` for more details.
 
110
 
 
111
.. _virtualenv:
 
112
 
 
113
Manually installing and using the virtualenv
 
114
--------------------------------------------
 
115
 
 
116
You can manually install the virtual environment instead of having
 
117
``run_tests.sh`` do it for you::
 
118
 
34
119
  python tools/install_venv.py
35
120
 
36
 
If all goes well, you should get a message something like this:
37
 
::
 
121
This will install all of the Python packages listed in the
 
122
``tools/pip-requires`` file into your virtualenv. There will also be some
 
123
additional packages (pip, distribute, greenlet, M2Crypto) that are installed
 
124
by the ``tools/install_venv.py`` file into the virutalenv.
 
125
 
 
126
If all goes well, you should get a message something like this::
 
127
 
38
128
  Nova development environment setup is complete.
39
129
 
40
 
Nova development uses virtualenv to track and manage Python dependencies while in development and testing. Virtual env gives you an independent Python environment.
41
 
 
42
130
To activate the Nova virtualenv for the extent of your current shell session
43
 
 you can run::
44
 
 
45
 
     $ source .nova-venv/bin/activate 
46
 
 
47
 
 Or, if you prefer, you can run commands in the virtualenv on a case by case
48
 
 basis by running::
 
131
you can run::
 
132
 
 
133
     $ source .nova-venv/bin/activate
 
134
 
 
135
Or, if you prefer, you can run commands in the virtualenv on a case by case
 
136
basis by running::
49
137
 
50
138
     $ tools/with_venv.sh <your command>
51
139
 
52
 
 Also, make test will automatically use the virtualenv.
53
 
 
54
 
If you don't want to create a virtualenv every time you branch you can reuse a single virtualenv for all branches.
55
 
 
56
 
 #. If you don't have a nova/ directory containing trunk/ and other branches, do so now.
57
 
 #. Go into nova/trunk and install a virtualenv.
58
 
 #. Move it up a level: mv nova/trunk/.nova-venv nova/.nova-venv.
59
 
 #. Symlink the ../nova/.nova-venv directory from your branch:: 
60
 
 
61
 
    ~/openstack/nova/my_branch$ ln -s ../.nova-venv .nova-venv
62
 
 
63
 
This works with run_tests.sh and nosetests -w nova/tests/api
64
 
 
65
 
MacOSX Systems
66
 
--------------
67
 
 
68
 
First, install Virtual Env, which creates an isolated "standalone" Python environment.::
69
 
 
70
 
    sudo easy_install virtualenv
71
 
 
72
 
 
73
 
Here's how to setup the code initially::
74
 
 
75
 
    git clone https://github.com/openstack/nova.git
76
 
    cd nova
77
 
    python tools/install_venv.py
78
 
    source .nova_venv/bin/activate
79
 
    pip install pep8 # submitting patch so that Nova has pep8 and pylint in PIP requirements file
80
 
    pip install pylint
81
 
 
82
 
If you have installed OpenSSL 1.0.0a on MacOS, which can happen when installing a MacPorts package for OpenSSL, you will see an error when running nova.tests.auth_unittest.AuthTestCase.test_209_can_generate_x509. The version that functions correctly is OpenSSL 0.9.8l 5, installed with MacOS 10.6 as a base element. 
83
 
 
84
 
Here's how to get the latest code::
85
 
 
86
 
  cd nova
87
 
  git pull # get the latest stuff...
88
 
  source .nova_venv/bin/activate
89
 
  ./run_tests.sh
90
 
 
91
 
Then you can do cleaning work or hack hack hack with a branched named cleaning.  
92
 
 
93
140
Contributing Your Work
94
141
----------------------
95
142
 
96
 
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. Nova uses the Gerrit code review system. For information on how to submit your branch to Gerrit, see http://wiki.openstack.org/GerritWorkflow 
 
143
Once your work is complete you may wish to contribute it to the project.  Add
 
144
your name and email address to the `Authors` file, and also to the `.mailmap`
 
145
file if you use multiple email addresses. Your contributions can not be merged
 
146
into trunk unless you are listed in the Authors file. Nova uses the Gerrit
 
147
code review system. For information on how to submit your branch to Gerrit,
 
148
see http://wiki.openstack.org/GerritWorkflow