root / README.develop @ 038383b1
History | View | Annotate | Download (5.8 kB)
1 |
DEVELOP.txt - Information on how to setup a development environment. |
---|---|
2 |
|
3 |
Dependencies |
4 |
------------ |
5 |
|
6 |
Synnefo depends on the following Python modules |
7 |
|
8 |
- django 1.2 |
9 |
- django-piston |
10 |
- simplejson |
11 |
- selenium |
12 |
- pyzmq-static |
13 |
- iso8601 |
14 |
|
15 |
also, depending on the database engine of choice, on one of the following: |
16 |
- MySQL-python |
17 |
- psycopg2 |
18 |
|
19 |
Temporary fix - to be removed soon |
20 |
---------------------------------- |
21 |
After going through the installation instructions below, the following fix must |
22 |
be applied. |
23 |
|
24 |
jQuery.ajax POST is not working unless you edit lib/python2.6/site-packages/piston/utils.py. |
25 |
On def content_type change: |
26 |
ctype = self.request.META.get('CONTENT_TYPE', type_formencoded) |
27 |
to |
28 |
ctype = self.request.META.get('CONTENT_TYPE', type_formencoded).split(";")[0] |
29 |
|
30 |
|
31 |
Preparing the development environment |
32 |
------------------------------------- |
33 |
|
34 |
1. Prepare the system |
35 |
The easiest method is to setup a working environment through virtualenv. |
36 |
Alternatively, you can use your system's package manager to install |
37 |
the dependencies (e.g. Macports has them all). |
38 |
|
39 |
*On Snow Leopard, you have to set the following environment variable for |
40 |
pip to compile the dependencies correctly. |
41 |
|
42 |
$export ARCHFLAGS="-arch x86_64" |
43 |
|
44 |
*On Ubuntu, a few more packages must be isntalled before installing the |
45 |
prerequisite Python libraries |
46 |
|
47 |
$sudo aptitude install libcurl3-gnutls libcurl3-gnutls-dev uuid-dev |
48 |
|
49 |
2. Checkout the code and install the Python prerequisites. This assumes |
50 |
that python is already installed on the host. |
51 |
|
52 |
$ sudo easy_install virtualenv |
53 |
$ git clone https://user@code.grnet.gr/git/synnefo synnefo |
54 |
$ virtualenv --python=python2.6 synnefo --no-site-packages |
55 |
... |
56 |
$ cd synnefo |
57 |
$ ./bin/pip install django django-piston pycurl simplejson selenium pyzmq-static |
58 |
|
59 |
3. At this point you should have all required dependencies installed. Now you |
60 |
have to select a database engine. The choices are: postgres, mysql and sqlite. |
61 |
|
62 |
-SQLite |
63 |
The python sqlite driver is available by default with Python so no additional |
64 |
configuration is required. Also, most self-respecting systems have the sqlite |
65 |
library installed by default. |
66 |
|
67 |
-MySQL |
68 |
MySQL must be installed first |
69 |
|
70 |
*Ubuntu - Debian |
71 |
$sudo apt-get install libmysqlclient-dev |
72 |
|
73 |
*MacPorts |
74 |
$sudo port install mysql5 |
75 |
|
76 |
Install the MySQL python library |
77 |
|
78 |
$ bin/pip install MySQL-python |
79 |
|
80 |
Note: On MacOSX with Mysql install from MacPorts the above command will fail |
81 |
complaining that it cannot find the mysql_config command. Do the following and |
82 |
restart the installation |
83 |
|
84 |
$ echo "mysql_config = /opt/local/bin/mysql_config5" >> ./build/MySQL-python/site.cfg |
85 |
|
86 |
Configure a MySQL db/account for synnefo |
87 |
|
88 |
$ mysql -u root -p |
89 |
|
90 |
mysql> create database synnefo; |
91 |
mysql> show databases; |
92 |
mysql> GRANT ALL on synnefo.* TO username IDENTIFIED BY 'password'; |
93 |
|
94 |
-Postgres |
95 |
|
96 |
#Ubuntu - Debian |
97 |
$ sudo apt-get install postgresql-8.4 libpq-dev |
98 |
|
99 |
#MacPorts |
100 |
$ sudo port install postgresql84 |
101 |
|
102 |
Install the postgres Python library |
103 |
|
104 |
$ bin/pip install psycopg2 |
105 |
|
106 |
Configure a postgres db/account for synnefo |
107 |
Become the postgres user, connect to PostgreSQL: |
108 |
$ sudo su - postgres |
109 |
$ psql |
110 |
|
111 |
Run the following commands: |
112 |
DROP DATABASE synnefo; |
113 |
DROP USER username; |
114 |
CREATE USER username WITH PASSWORD 'password'; |
115 |
CREATE DATABASE synnefo; |
116 |
GRANT ALL PRIVILEGES ON DATABASE synnefo TO username; |
117 |
ALTER DATABASE synnefo OWNER TO username; |
118 |
ALTER USER username CREATEDB; |
119 |
|
120 |
The last line enables the newly created user to create own databases. This is |
121 |
needed for Django to create and drop the test_synnefo database for unit |
122 |
testing. |
123 |
|
124 |
4. At this point you should have a working DB. Now configure Django to access it: |
125 |
Copy the default configuration file |
126 |
|
127 |
$ cp settings.py.dist settings.py |
128 |
|
129 |
and then copy/edit according to the database used: |
130 |
|
131 |
-SQLite |
132 |
|
133 |
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' |
134 |
|
135 |
DATABASES = { |
136 |
'default': { |
137 |
'ENGINE': 'django.db.backends.sqlite3', |
138 |
'NAME': PROJECT_PATH + 'synnefo.db' #WARN: This must be an absolute path |
139 |
} |
140 |
} |
141 |
|
142 |
-MySQL |
143 |
DATABASES = { |
144 |
'default': { |
145 |
'ENGINE': 'django.db.backends.mysql', |
146 |
'NAME': 'synnefo', |
147 |
'USER': 'USERNAME' |
148 |
'PASSWORD': 'PASSWORD', |
149 |
'HOST': 'HOST', |
150 |
'PORT': 'PORT', |
151 |
'OPTIONS': { |
152 |
'init_command': 'SET storage_engine=INNODB', |
153 |
} |
154 |
} |
155 |
} |
156 |
|
157 |
-Postgres |
158 |
|
159 |
DATABASES = { |
160 |
'default': { |
161 |
'ENGINE': 'django.db.backends.postgresql_psycopg2', |
162 |
'NAME': 'DATABASE', |
163 |
'USER': 'USERNAME', |
164 |
'PASSWORD': 'PASSWORD', |
165 |
'HOST': 'HOST', |
166 |
'PORT': 'PORT', |
167 |
} |
168 |
} |
169 |
|
170 |
5. Try it out. The following command will attempt to connect to the DB and |
171 |
print out DDL statements. It should not fail. |
172 |
|
173 |
$ ./bin/python manage.py sql db |
174 |
|
175 |
6. Create the DB and (optionally) load test data |
176 |
|
177 |
$ ./bin/python manage.py syncdb |
178 |
$ ./bin/python manage.py loaddata db/fixtures/flavors.json |
179 |
$ ./bin/python manage.py loaddata db/fixtures/images.json |
180 |
|
181 |
The following fictures can be loaded optionally depending on |
182 |
testing requirements: |
183 |
|
184 |
$ ./bin/python manage.py loaddata db/fixtures/vms.json |
185 |
$ ./bin/python manage.py loaddata db/fixtures/initial_data.json |
186 |
$ ./bin/python manage.py loaddata db/fixtures/disks.json |
187 |
|
188 |
7. Set the BACKEND_PREFIX_ID variable to some unique prefix, e.g. your commit |
189 |
username |
190 |
|
191 |
8. Start the system |
192 |
$ ./bin/python db/db_controller.py #DB synch daemon |
193 |
$ ./bin/python manage.py runserver #Django |
194 |
|
195 |
9. (Hopefully) Done |
196 |
|
197 |
UI Testing |
198 |
---------- |
199 |
The functional ui tests require the Selenium server and the synnefo app to |
200 |
be running. |
201 |
|
202 |
$ wget http://selenium.googlecode.com/files/selenium-server-standalone-2.0b2.jar |
203 |
$ java -jar selenium-server-standalone-2.0b2.jar & |
204 |
$ ./bin/python manage.py runserver & |
205 |
$ ./bin/python manage.py test ui |
206 |
|
207 |
Test coverage |
208 |
------------- |
209 |
|
210 |
In order to get code coverage reports you need to install django-test-coverage |
211 |
|
212 |
$ ./bin/pip install django-test-coverage |
213 |
|
214 |
Then edit your settings.py and configure the test runner: |
215 |
|
216 |
TEST_RUNNER = 'django-test-coverage.runner.run_tests' |