Statistics
| Branch: | Tag: | Revision:

root / docs / dev-guide.rst @ 114b028e

History | View | Annotate | Download (11.1 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

    
116
Compute Service API (Cyclades)
117
==============================
118

    
119
The Compute part of Cyclades exposes the OpenStack Compute API with minor
120
changes wherever needed.
121

    
122
This is the Cyclades/Compute API:
123

    
124
.. toctree::
125
   :maxdepth: 2
126

    
127
   Compute API <cyclades-api-guide>
128

    
129

    
130
Network Service API (Cyclades)
131
==============================
132

    
133
The Network Service is implemented inside Cyclades. It exposes the part of the
134
OpenStack Compute API that has to do with Networks. The OpenStack Quantum API
135
is not implemented yet.
136

    
137
Please consult the :ref:`Cyclades/Network API <cyclades-api-guide>` for more
138
details.
139

    
140

    
141
Image Service API (Cyclades)
142
============================
143

    
144
The Image Service is implemented inside Cyclades. It exposes the OpenStack
145
Glance API with minor changes wherever needed.
146

    
147
This is the Cyclades/Image API:
148

    
149
.. toctree::
150
   :maxdepth: 2
151

    
152
   Image API <plankton-api-guide>
153

    
154

    
155
Storage Service API (Pithos)
156
============================
157

    
158
Pithos is the Storage Service of Synnefo and it exposes the OpenStack Object
159
Storage API with extensions for advanced operations, e.g., syncing.
160

    
161
This is the Pithos Object Storage API:
162

    
163
.. toctree::
164
   :maxdepth: 2
165

    
166
   Object Storage API <pithos-api-guide>
167

    
168

    
169
Implementing new clients
170
========================
171

    
172
In this section we discuss implementation guidelines, that a developer should
173
take into account before writing his own client for the above APIs. Before,
174
starting your client implementation, make sure you have thoroughly read the
175
corresponding Synnefo API.
176

    
177
Pithos clients
178
--------------
179

    
180
User Experience
181
~~~~~~~~~~~~~~~
182

    
183
Hopefully this API will allow for a multitude of client implementations, each
184
supporting a different device or operating system. All clients will be able to
185
manipulate containers and objects - even software only designed for OOS API
186
compatibility. But a Pithos interface should not be only about showing
187
containers and folders. There are some extra user interface elements and
188
functionalities that should be common to all implementations.
189

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

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

    
208
Objects in Pithos can be:
209

    
210
 * Moved to trash and then deleted.
211
 * Shared with specific permissions.
212
 * Made public (shared with non-Pithos users).
213
 * Restored from previous versions.
214

    
215
Some of these functions are performed by the client software and some by the
216
Pithos server.
217

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

    
222
Implementation Guidelines
223
~~~~~~~~~~~~~~~~~~~~~~~~~
224

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

    
235
Object names should use the ``/`` delimiter to impose a hierarchy of folders
236
and files.
237

    
238
The ``shared`` element should be implemented as a read-only view of the
239
``pithos`` container, using the ``shared`` parameter when listing objects. The
240
``others`` element, should start with a top-level ``GET`` to retrieve the list
241
of accounts accessible to the user. It is suggested that the client software
242
hides the next step of navigation - the container - if it only includes
243
``pithos`` and forwards the user directly to the objects.
244

    
245
Public objects are not included in ``shared`` and ``others`` listings. It is
246
suggested that they are marked in a visually distinctive way in ``pithos``
247
listings (for example using an icon overlay).
248

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

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

    
261
Uploading and downloading data
262
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263

    
264
By using hashmaps to upload and download objects the corresponding operations
265
can complete much faster.
266

    
267
In the case of an upload, only the missing blocks will be submitted to the
268
server:
269

    
270
 * Calculate the hash value for each block of the object to be uploaded. Use
271
   the hash algorithm and block size of the destination container.
272
 * Send a hashmap ``PUT`` request for the object.
273

    
274
   * Server responds with status ``201`` (Created):
275

    
276
     * Blocks are already on the server. The object has been created. Done.
277

    
278
   * Server responds with status ``409`` (Conflict):
279

    
280
     * Server's response body contains the hashes of the blocks that do not
281
       exist on the server.
282
     * For each hash value in the server's response (or all hashes together):
283

    
284
       * Send a ``POST`` request to the destination container with the
285
         corresponding data.
286

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

    
289
Consulting hashmaps when downloading allows for resuming partially transferred
290
objects. The client should retrieve the hashmap from the server and compare it
291
with the hashmap computed from the respective local file. Any missing parts can
292
be downloaded with ``GET`` requests with the additional ``Range`` header.
293

    
294
Syncing
295
~~~~~~~
296

    
297
Consider the following algorithm for synchronizing a local folder with the
298
server. The "state" is the complete object listing, with the corresponding
299
attributes.
300

    
301
.. code-block:: python
302

    
303
  # L: Local State, the last synced state of the object.
304
  # Stored locally (e.g. in an SQLite database)
305

    
306
  # C: Current State, the current local state of the object
307
  # Returned by the filesystem
308

    
309
  # S: Server State, the current server state of the object
310
  # Returned by the server (HTTP request)
311

    
312
  def sync(path):
313
      L = get_local_state(path)   # Database action
314
      C = get_current_state(path) # Filesystem action
315
      S = get_server_state(path)  # Network action
316

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

    
341

    
342
Notes:
343

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