Statistics
| Branch: | Tag: | Revision:

root / docs / dev-guide.rst @ 2556cf45

History | View | Annotate | Download (9.9 kB)

1
.. _dev-guide:
2

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

    
6
This is the complete Synnefo Developer's Guide. Here, we document all Synnefo
7
REST APIs, to allow external developers write independent tools that interact
8
with Synnefo.
9

    
10
Synnefo exposes the OpenStack APIs for all its operations. Also, extensions
11
have been written for advanced operations wherever needed, and minor changes
12
for things that were missing or change frequently.
13

    
14
Most Synnefo services have a corresponding OpenStack API:
15

    
16
| Cyclades/Compute Service -> OpenStack Compute API
17
| Cyclades/Network Service -> OpenStack Compute/Network API (not Quantum yet)
18
| Cyclades/Image Service -> OpenStack Glance API
19
| Pithos/Storage Service -> OpenStack Object Store API
20
| Astakos/Identity Service -> Proprietary, moving to OpenStack Keystone API
21
| Astakos/Quota Service -> Proprietary API
22
| Astakos/Resource Service -> Proprietary API
23

    
24
Below, we will describe all Synnefo APIs with conjuction to the OpenStack APIs.
25

    
26

    
27
Identity Service API (Astakos)
28
==============================
29

    
30
Currently, Astakos which is the Identity Management Service of Synnefo, has a
31
proprietary API, but we are moving to the OpenStack Keystone API.
32

    
33
The current Identity Management API is:
34

    
35
.. toctree::
36
   :maxdepth: 2
37

    
38
    Identity API <astakos-api-guide>
39

    
40

    
41
Resource and Quota Service API (Astakos)
42
========================================
43

    
44
.. toctree::
45
    :maxdepth: 2
46

    
47
    Resource and Quota API <quota-api-guide.rst>
48

    
49
Project API
50
===========
51

    
52
.. toctree::
53
    :maxdepth: 2
54

    
55
    Project API <project-api-guide.rst>
56

    
57
Compute Service API (Cyclades)
58
==============================
59

    
60
The Compute part of Cyclades exposes the OpenStack Compute API with minor
61
changes wherever needed.
62

    
63
This is the Cyclades/Compute API:
64

    
65
.. toctree::
66
   :maxdepth: 2
67

    
68
   Compute API <cyclades-api-guide>
69

    
70

    
71
Network Service API (Cyclades)
72
==============================
73

    
74
The Network Service is implemented inside Cyclades. It exposes the part of the
75
OpenStack Compute API that has to do with Networks. The OpenStack Quantum API
76
is not implemented yet.
77

    
78
Please consult the :ref:`Cyclades/Network API <cyclades-api-guide>` for more
79
details.
80

    
81

    
82
Image Service API (Cyclades)
83
============================
84

    
85
The Image Service is implemented inside Cyclades. It exposes the OpenStack
86
Glance API with minor changes wherever needed.
87

    
88
This is the Cyclades/Image API:
89

    
90
.. toctree::
91
   :maxdepth: 2
92

    
93
   Image API <plankton-api-guide>
94

    
95

    
96
Storage Service API (Pithos)
97
============================
98

    
99
Pithos is the Storage Service of Synnefo and it exposes the OpenStack Object
100
Storage API with extensions for advanced operations, e.g., syncing.
101

    
102
This is the Pithos Object Storage API:
103

    
104
.. toctree::
105
   :maxdepth: 2
106

    
107
   Object Storage API <pithos-api-guide>
108

    
109

    
110
Implementing new clients
111
========================
112

    
113
In this section we discuss implementation guidelines, that a developer should
114
take into account before writing his own client for the above APIs. Before,
115
starting your client implementation, make sure you have thoroughly read the
116
corresponding Synnefo API.
117

    
118
Pithos clients
119
--------------
120

    
121
User Experience
122
~~~~~~~~~~~~~~~
123

    
124
Hopefully this API will allow for a multitude of client implementations, each
125
supporting a different device or operating system. All clients will be able to
126
manipulate containers and objects - even software only designed for OOS API
127
compatibility. But a Pithos interface should not be only about showing
128
containers and folders. There are some extra user interface elements and
129
functionalities that should be common to all implementations.
130

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

    
134
 * The ``home`` element, which is used as the default entry point to the user's
135
   "files". Objects under ``home`` are represented in the usual hierarchical
136
   organization of folders and files.
137
 * The ``trash`` element, which contains files that have been marked for
138
   deletion, but can still be recovered.
139
 * The ``shared`` element, which contains all objects shared by the user to
140
   other users of the system.
141
 * The ``others`` element, which contains all objects that other users share
142
   with the user.
143
 * The ``groups`` element, which contains the names of groups the user has
144
   defined. Each group consists of a user list. Group creation, deletion, and
145
   manipulation is carried out by actions originating here.
146
 * The ``history`` element, which allows browsing past instances of ``home``
147
   and - optionally - ``trash``.
148

    
149
Objects in Pithos can be:
150

    
151
 * Moved to trash and then deleted.
152
 * Shared with specific permissions.
153
 * Made public (shared with non-Pithos users).
154
 * Restored from previous versions.
155

    
156
Some of these functions are performed by the client software and some by the
157
Pithos server.
158

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

    
163
Implementation Guidelines
164
~~~~~~~~~~~~~~~~~~~~~~~~~
165

    
166
Pithos clients should use the ``pithos`` and ``trash`` containers for active
167
and inactive objects respectively. If any of these containers is not found, the
168
client software should create it, without interrupting the user's workflow. The
169
``home`` element corresponds to ``pithos`` and the ``trash`` element to
170
``trash``. Use ``PUT`` with the ``X-Move-From`` header, or ``MOVE`` to transfer
171
objects from one container to the other. Use ``DELETE`` to remove from
172
``pithos`` without trashing, or to remove from ``trash``. When moving objects,
173
detect naming conflicts with the ``If-Match`` or ``If-None-Match`` headers.
174
Such conflicts should be resolved by the user.
175

    
176
Object names should use the ``/`` delimiter to impose a hierarchy of folders
177
and files.
178

    
179
The ``shared`` element should be implemented as a read-only view of the
180
``pithos`` container, using the ``shared`` parameter when listing objects. The
181
``others`` element, should start with a top-level ``GET`` to retrieve the list
182
of accounts accessible to the user. It is suggested that the client software
183
hides the next step of navigation - the container - if it only includes
184
``pithos`` and forwards the user directly to the objects.
185

    
186
Public objects are not included in ``shared`` and ``others`` listings. It is
187
suggested that they are marked in a visually distinctive way in ``pithos``
188
listings (for example using an icon overlay).
189

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

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

    
202
Uploading and downloading data
203
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204

    
205
By using hashmaps to upload and download objects the corresponding operations
206
can complete much faster.
207

    
208
In the case of an upload, only the missing blocks will be submitted to the
209
server:
210

    
211
 * Calculate the hash value for each block of the object to be uploaded. Use
212
   the hash algorithm and block size of the destination container.
213
 * Send a hashmap ``PUT`` request for the object.
214

    
215
   * Server responds with status ``201`` (Created):
216

    
217
     * Blocks are already on the server. The object has been created. Done.
218

    
219
   * Server responds with status ``409`` (Conflict):
220

    
221
     * Server's response body contains the hashes of the blocks that do not
222
       exist on the server.
223
     * For each hash value in the server's response (or all hashes together):
224

    
225
       * Send a ``POST`` request to the destination container with the
226
         corresponding data.
227

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

    
230
Consulting hashmaps when downloading allows for resuming partially transferred
231
objects. The client should retrieve the hashmap from the server and compare it
232
with the hashmap computed from the respective local file. Any missing parts can
233
be downloaded with ``GET`` requests with the additional ``Range`` header.
234

    
235
Syncing
236
~~~~~~~
237

    
238
Consider the following algorithm for synchronizing a local folder with the
239
server. The "state" is the complete object listing, with the corresponding
240
attributes.
241
 
242
.. code-block:: python
243

    
244
  # L: Local State, the last synced state of the object.
245
  # Stored locally (e.g. in an SQLite database)
246
  
247
  # C: Current State, the current local state of the object
248
  # Returned by the filesystem
249
  
250
  # S: Server State, the current server state of the object
251
  # Returned by the server (HTTP request)
252
  
253
  def sync(path):
254
      L = get_local_state(path)   # Database action
255
      C = get_current_state(path) # Filesystem action
256
      S = get_server_state(path)  # Network action
257
  
258
      if C == L:
259
          # No local changes
260
          if S == L:
261
              # No remote changes, nothing to do
262
              return
263
          else:
264
              # Update local state to match that of the server
265
              download(path)
266
              update_local_state(path, S)
267
      else:
268
          # Local changes exist
269
          if S == L:
270
              # No remote changes, update the server and the local state
271
              upload(path)
272
              update_local_state(path, C)
273
          else:
274
              # Both local and server changes exist
275
              if C == S:
276
                  # We were lucky, both did the same
277
                  update_local_state(path, C)
278
              else:
279
                  # Conflicting changes exist
280
                  conflict()
281
  
282

    
283
Notes:
284

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