Revision bfda2342
b/docs/dev-guide.rst | ||
---|---|---|
3 | 3 |
Synnefo Developer's Guide |
4 | 4 |
^^^^^^^^^^^^^^^^^^^^^^^^^ |
5 | 5 |
|
6 |
This is the complete Synnefo Developer's Guide. Here, we document all Synnefo |
|
6 |
This is the complete Synnefo Developer's Guide. |
|
7 |
|
|
8 |
Environment set up |
|
9 |
================== |
|
10 |
|
|
11 |
First of all you have to set up a developing environment for Synnefo. |
|
12 |
|
|
13 |
**1. Create a new Squeeze VM** |
|
14 |
|
|
15 |
**2. Build your own Synnefo installation** |
|
16 |
|
|
17 |
Follow the instructions `here <http://www.synnefo.org/docs/synnefo/latest/quick-install-guide.html>`_ |
|
18 |
to build Synnefo on a single node using ``snf-deploy``. |
|
19 |
|
|
20 |
**3. Install GitPython** |
|
21 |
|
|
22 |
.. code-block:: console |
|
23 |
|
|
24 |
# pip install gitpython |
|
25 |
|
|
26 |
**4. Install devflow** |
|
27 |
|
|
28 |
Devflow is a tool to manage versions, helps implement the git flow development process, |
|
29 |
and builds Python and Debian packages. You will need it to create your code's version. |
|
30 |
|
|
31 |
.. code-block:: console |
|
32 |
|
|
33 |
# pip install devflow |
|
34 |
|
|
35 |
**5. Get Synnefo code** |
|
36 |
|
|
37 |
First you need to install git |
|
38 |
|
|
39 |
.. code-block:: console |
|
40 |
|
|
41 |
# apt-get install git |
|
42 |
|
|
43 |
And now get the Synnefo code from the official Synnefo repository |
|
44 |
|
|
45 |
.. code-block:: console |
|
46 |
|
|
47 |
$ git clone https://code.grnet.gr/git/synnefo |
|
48 |
|
|
49 |
Make sure you did the previous as a regular user. Otherwise you will have problems |
|
50 |
with file permissions when deploying. |
|
51 |
|
|
52 |
**6. Code and deploy** |
|
53 |
|
|
54 |
1. Configure the version |
|
55 |
|
|
56 |
.. code-block:: console |
|
57 |
|
|
58 |
$ devflow-update-version |
|
59 |
|
|
60 |
2. Code |
|
61 |
3. In every component you change run |
|
62 |
|
|
63 |
.. code-block:: console |
|
64 |
|
|
65 |
# python setup.py develop |
|
66 |
|
|
67 |
4. Refresh the web page and see your changes |
|
68 |
|
|
69 |
Synnefo REST APIs |
|
70 |
================= |
|
71 |
|
|
72 |
Here, we document all Synnefo |
|
7 | 73 |
REST APIs, to allow external developers write independent tools that interact |
8 | 74 |
with Synnefo. |
9 | 75 |
|
... | ... | |
231 | 297 |
Consider the following algorithm for synchronizing a local folder with the |
232 | 298 |
server. The "state" is the complete object listing, with the corresponding |
233 | 299 |
attributes. |
234 |
|
|
300 |
|
|
235 | 301 |
.. code-block:: python |
236 | 302 |
|
237 | 303 |
# L: Local State, the last synced state of the object. |
238 | 304 |
# Stored locally (e.g. in an SQLite database) |
239 |
|
|
305 |
|
|
240 | 306 |
# C: Current State, the current local state of the object |
241 | 307 |
# Returned by the filesystem |
242 |
|
|
308 |
|
|
243 | 309 |
# S: Server State, the current server state of the object |
244 | 310 |
# Returned by the server (HTTP request) |
245 |
|
|
311 |
|
|
246 | 312 |
def sync(path): |
247 | 313 |
L = get_local_state(path) # Database action |
248 | 314 |
C = get_current_state(path) # Filesystem action |
249 | 315 |
S = get_server_state(path) # Network action |
250 |
|
|
316 |
|
|
251 | 317 |
if C == L: |
252 | 318 |
# No local changes |
253 | 319 |
if S == L: |
... | ... | |
271 | 337 |
else: |
272 | 338 |
# Conflicting changes exist |
273 | 339 |
conflict() |
274 |
|
|
340 |
|
|
275 | 341 |
|
276 | 342 |
Notes: |
277 | 343 |
|
Also available in: Unified diff