Statistics
| Branch: | Tag: | Revision:

root / docs / dev-guide.rst @ 1fbdb3d7

History | View | Annotate | Download (11.2 kB)

1
.. _dev-guide:
2

    
3
Synnefo Developer's Guide
4
^^^^^^^^^^^^^^^^^^^^^^^^^
5

    
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
73
REST APIs, to allow external developers write independent tools that interact
74
with Synnefo.
75

    
76
Synnefo exposes the OpenStack APIs for all its operations. Also, extensions
77
have been written for advanced operations wherever needed, and minor changes
78
for things that were missing or change frequently.
79

    
80
Most Synnefo services have a corresponding OpenStack API:
81

    
82
| Cyclades/Compute Service -> OpenStack Compute API
83
| Cyclades/Network Service -> OpenStack Compute/Network API (not Quantum yet)
84
| Cyclades/Image Service -> OpenStack Glance API
85
| Pithos/Storage Service -> OpenStack Object Store API
86
| Astakos/Identity Service -> Proprietary, moving to OpenStack Keystone API
87
| Astakos/Quota Service -> Proprietary API
88
| Astakos/Resource Service -> Proprietary API
89

    
90
Below, we will describe all Synnefo APIs with conjuction to the OpenStack APIs.
91

    
92

    
93
Identity Service API (Astakos)
94
==============================
95

    
96
Currently, Astakos which is the Identity Management Service of Synnefo, has a
97
proprietary API, but we are moving to the OpenStack Keystone API.
98

    
99
The current Identity Management API is:
100

    
101
.. toctree::
102
   :maxdepth: 2
103

    
104
    Identity API <astakos-api-guide>
105

    
106

    
107
Resource and Quota Service API (Astakos)
108
========================================
109

    
110
.. toctree::
111
    :maxdepth: 2
112

    
113
    Resource and Quota API <quota-api-guide.rst>
114

    
115
Project API
116
===========
117

    
118
.. toctree::
119
    :maxdepth: 2
120

    
121
    Project API <project-api-guide.rst>
122

    
123
Compute Service API (Cyclades)
124
==============================
125

    
126
The Compute part of Cyclades exposes the OpenStack Compute API with minor
127
changes wherever needed.
128

    
129
This is the Cyclades/Compute API:
130

    
131
.. toctree::
132
   :maxdepth: 2
133

    
134
   Compute API <cyclades-api-guide>
135

    
136

    
137
Network Service API (Cyclades)
138
==============================
139

    
140
The Network Service is implemented inside Cyclades. It exposes the part of the
141
OpenStack Compute API that has to do with Networks. The OpenStack Quantum API
142
is not implemented yet.
143

    
144
Please consult the :ref:`Cyclades/Network API <cyclades-api-guide>` for more
145
details.
146

    
147

    
148
Image Service API (Cyclades)
149
============================
150

    
151
The Image Service is implemented inside Cyclades. It exposes the OpenStack
152
Glance API with minor changes wherever needed.
153

    
154
This is the Cyclades/Image API:
155

    
156
.. toctree::
157
   :maxdepth: 2
158

    
159
   Image API <plankton-api-guide>
160

    
161

    
162
Storage Service API (Pithos)
163
============================
164

    
165
Pithos is the Storage Service of Synnefo and it exposes the OpenStack Object
166
Storage API with extensions for advanced operations, e.g., syncing.
167

    
168
This is the Pithos Object Storage API:
169

    
170
.. toctree::
171
   :maxdepth: 2
172

    
173
   Object Storage API <pithos-api-guide>
174

    
175

    
176
Implementing new clients
177
========================
178

    
179
In this section we discuss implementation guidelines, that a developer should
180
take into account before writing his own client for the above APIs. Before,
181
starting your client implementation, make sure you have thoroughly read the
182
corresponding Synnefo API.
183

    
184
Pithos clients
185
--------------
186

    
187
User Experience
188
~~~~~~~~~~~~~~~
189

    
190
Hopefully this API will allow for a multitude of client implementations, each
191
supporting a different device or operating system. All clients will be able to
192
manipulate containers and objects - even software only designed for OOS API
193
compatibility. But a Pithos interface should not be only about showing
194
containers and folders. There are some extra user interface elements and
195
functionalities that should be common to all implementations.
196

    
197
Upon entrance to the service, a user is presented with the following elements -
198
which can be represented as folders or with other related icons:
199

    
200
 * The ``home`` element, which is used as the default entry point to the user's
201
   "files". Objects under ``home`` are represented in the usual hierarchical
202
   organization of folders and files.
203
 * The ``trash`` element, which contains files that have been marked for
204
   deletion, but can still be recovered.
205
 * The ``shared`` element, which contains all objects shared by the user to
206
   other users of the system.
207
 * The ``others`` element, which contains all objects that other users share
208
   with the user.
209
 * The ``groups`` element, which contains the names of groups the user has
210
   defined. Each group consists of a user list. Group creation, deletion, and
211
   manipulation is carried out by actions originating here.
212
 * The ``history`` element, which allows browsing past instances of ``home``
213
   and - optionally - ``trash``.
214

    
215
Objects in Pithos can be:
216

    
217
 * Moved to trash and then deleted.
218
 * Shared with specific permissions.
219
 * Made public (shared with non-Pithos users).
220
 * Restored from previous versions.
221

    
222
Some of these functions are performed by the client software and some by the
223
Pithos server.
224

    
225
In the first version of Pithos, objects could also be assigned custom tags.
226
This is no longer supported. Existing deployments can migrate tags into a
227
specific metadata value, i.e. ``X-Object-Meta-Tags``.
228

    
229
Implementation Guidelines
230
~~~~~~~~~~~~~~~~~~~~~~~~~
231

    
232
Pithos clients should use the ``pithos`` and ``trash`` containers for active
233
and inactive objects respectively. If any of these containers is not found, the
234
client software should create it, without interrupting the user's workflow. The
235
``home`` element corresponds to ``pithos`` and the ``trash`` element to
236
``trash``. Use ``PUT`` with the ``X-Move-From`` header, or ``MOVE`` to transfer
237
objects from one container to the other. Use ``DELETE`` to remove from
238
``pithos`` without trashing, or to remove from ``trash``. When moving objects,
239
detect naming conflicts with the ``If-Match`` or ``If-None-Match`` headers.
240
Such conflicts should be resolved by the user.
241

    
242
Object names should use the ``/`` delimiter to impose a hierarchy of folders
243
and files.
244

    
245
The ``shared`` element should be implemented as a read-only view of the
246
``pithos`` container, using the ``shared`` parameter when listing objects. The
247
``others`` element, should start with a top-level ``GET`` to retrieve the list
248
of accounts accessible to the user. It is suggested that the client software
249
hides the next step of navigation - the container - if it only includes
250
``pithos`` and forwards the user directly to the objects.
251

    
252
Public objects are not included in ``shared`` and ``others`` listings. It is
253
suggested that they are marked in a visually distinctive way in ``pithos``
254
listings (for example using an icon overlay).
255

    
256
A special application menu, or a section in application preferences, should be
257
devoted to managing groups (the ``groups`` element). All group-related actions
258
are implemented at the account level.
259

    
260
Browsing past versions of objects should be available both at the object and
261
the container level. At the object level, a list of past versions can be
262
included in the screen showing details or more information on the object
263
(metadata, permissions, etc.). At the container level, it is suggested that
264
clients use a ``history`` element, which presents to the user a read-only,
265
time-variable view of ``pithos`` contents. This can be accomplished via the
266
``until`` parameter in listings. Optionally, ``history`` may include ``trash``.
267

    
268
Uploading and downloading data
269
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270

    
271
By using hashmaps to upload and download objects the corresponding operations
272
can complete much faster.
273

    
274
In the case of an upload, only the missing blocks will be submitted to the
275
server:
276

    
277
 * Calculate the hash value for each block of the object to be uploaded. Use
278
   the hash algorithm and block size of the destination container.
279
 * Send a hashmap ``PUT`` request for the object.
280

    
281
   * Server responds with status ``201`` (Created):
282

    
283
     * Blocks are already on the server. The object has been created. Done.
284

    
285
   * Server responds with status ``409`` (Conflict):
286

    
287
     * Server's response body contains the hashes of the blocks that do not
288
       exist on the server.
289
     * For each hash value in the server's response (or all hashes together):
290

    
291
       * Send a ``POST`` request to the destination container with the
292
         corresponding data.
293

    
294
 * Repeat hashmap ``PUT``. Fail if the server's response is not ``201``.
295

    
296
Consulting hashmaps when downloading allows for resuming partially transferred
297
objects. The client should retrieve the hashmap from the server and compare it
298
with the hashmap computed from the respective local file. Any missing parts can
299
be downloaded with ``GET`` requests with the additional ``Range`` header.
300

    
301
Syncing
302
~~~~~~~
303

    
304
Consider the following algorithm for synchronizing a local folder with the
305
server. The "state" is the complete object listing, with the corresponding
306
attributes.
307

    
308
.. code-block:: python
309

    
310
  # L: Local State, the last synced state of the object.
311
  # Stored locally (e.g. in an SQLite database)
312

    
313
  # C: Current State, the current local state of the object
314
  # Returned by the filesystem
315

    
316
  # S: Server State, the current server state of the object
317
  # Returned by the server (HTTP request)
318

    
319
  def sync(path):
320
      L = get_local_state(path)   # Database action
321
      C = get_current_state(path) # Filesystem action
322
      S = get_server_state(path)  # Network action
323

    
324
      if C == L:
325
          # No local changes
326
          if S == L:
327
              # No remote changes, nothing to do
328
              return
329
          else:
330
              # Update local state to match that of the server
331
              download(path)
332
              update_local_state(path, S)
333
      else:
334
          # Local changes exist
335
          if S == L:
336
              # No remote changes, update the server and the local state
337
              upload(path)
338
              update_local_state(path, C)
339
          else:
340
              # Both local and server changes exist
341
              if C == S:
342
                  # We were lucky, both did the same
343
                  update_local_state(path, C)
344
              else:
345
                  # Conflicting changes exist
346
                  conflict()
347

    
348

    
349
Notes:
350

    
351
 * States represent file hashes (it is suggested to use Merkle). Deleted or
352
   non-existing files are assumed to have a magic hash (e.g. empty string).