Statistics
| Branch: | Tag: | Revision:

root / docs / dev-guide.rst @ 30096a2e

History | View | Annotate | Download (8.3 kB)

1 bc055d09 Constantinos Venetsanopoulos
.. _dev-guide:
2 bc055d09 Constantinos Venetsanopoulos
3 bc055d09 Constantinos Venetsanopoulos
Synnefo Developer's Guide
4 bc055d09 Constantinos Venetsanopoulos
^^^^^^^^^^^^^^^^^^^^^^^^^
5 bc055d09 Constantinos Venetsanopoulos
6 301294a9 Constantinos Venetsanopoulos
This is the complete Synnefo Developer's Guide. Here we document all Synnefo APIs
7 301294a9 Constantinos Venetsanopoulos
to allow external developers write independent tools that interact with Synnefo.
8 bc055d09 Constantinos Venetsanopoulos
9 8f9976c6 Constantinos Venetsanopoulos
IM API (Astakos)
10 8f9976c6 Constantinos Venetsanopoulos
================
11 8f9976c6 Constantinos Venetsanopoulos
12 8f9976c6 Constantinos Venetsanopoulos
This is the Identity Management API:
13 8f9976c6 Constantinos Venetsanopoulos
14 8f9976c6 Constantinos Venetsanopoulos
.. toctree::
15 8f9976c6 Constantinos Venetsanopoulos
   :maxdepth: 2
16 8f9976c6 Constantinos Venetsanopoulos
17 8f9976c6 Constantinos Venetsanopoulos
   IM API <astakos-api-guide>
18 8f9976c6 Constantinos Venetsanopoulos
19 b32b5995 Giorgos Korfiatis
Resource and Quota API (Astakos)
20 b32b5995 Giorgos Korfiatis
================================
21 b32b5995 Giorgos Korfiatis
22 b32b5995 Giorgos Korfiatis
.. toctree::
23 b32b5995 Giorgos Korfiatis
    :maxdepth: 2
24 b32b5995 Giorgos Korfiatis
25 b32b5995 Giorgos Korfiatis
    Resource and Quota API <quota-api-guide.rst>
26 b32b5995 Giorgos Korfiatis
27 bc055d09 Constantinos Venetsanopoulos
Compute API (Cyclades)
28 bc055d09 Constantinos Venetsanopoulos
======================
29 bc055d09 Constantinos Venetsanopoulos
30 bc055d09 Constantinos Venetsanopoulos
This is the Cyclades Compute API:
31 bc055d09 Constantinos Venetsanopoulos
32 bc055d09 Constantinos Venetsanopoulos
.. toctree::
33 bc055d09 Constantinos Venetsanopoulos
   :maxdepth: 2
34 bc055d09 Constantinos Venetsanopoulos
35 bc055d09 Constantinos Venetsanopoulos
   Compute API <cyclades-api-guide>
36 bc055d09 Constantinos Venetsanopoulos
37 bc055d09 Constantinos Venetsanopoulos
Network API (Cyclades)
38 bc055d09 Constantinos Venetsanopoulos
======================
39 bc055d09 Constantinos Venetsanopoulos
40 1837aa54 Giorgos Verigakis
The Network API is currently implemented inside Cyclades. Please consult the
41 1837aa54 Giorgos Verigakis
:ref:`Compute API <cyclades-api-guide>` for more details.
42 1837aa54 Giorgos Verigakis
43 bc055d09 Constantinos Venetsanopoulos
44 bc055d09 Constantinos Venetsanopoulos
Images API (Plankton)
45 bc055d09 Constantinos Venetsanopoulos
=====================
46 bc055d09 Constantinos Venetsanopoulos
47 1837aa54 Giorgos Verigakis
This is the Plankton Image API:
48 1837aa54 Giorgos Verigakis
49 1837aa54 Giorgos Verigakis
.. toctree::
50 1837aa54 Giorgos Verigakis
   :maxdepth: 2
51 1837aa54 Giorgos Verigakis
52 1837aa54 Giorgos Verigakis
   Image API <plankton-api-guide>
53 1837aa54 Giorgos Verigakis
54 bc055d09 Constantinos Venetsanopoulos
55 301294a9 Constantinos Venetsanopoulos
Storage API (Pithos)
56 bc055d09 Constantinos Venetsanopoulos
=====================
57 bc055d09 Constantinos Venetsanopoulos
58 301294a9 Constantinos Venetsanopoulos
This is the Pithos Object Storage API:
59 8f9976c6 Constantinos Venetsanopoulos
60 8f9976c6 Constantinos Venetsanopoulos
.. toctree::
61 8f9976c6 Constantinos Venetsanopoulos
   :maxdepth: 2
62 8f9976c6 Constantinos Venetsanopoulos
63 dad708b4 Antony Chazapis
   Object Storage API <pithos-api-guide>
64 8f9976c6 Constantinos Venetsanopoulos
65 8f9976c6 Constantinos Venetsanopoulos
Implementing new clients
66 8f9976c6 Constantinos Venetsanopoulos
========================
67 8f9976c6 Constantinos Venetsanopoulos
68 8f9976c6 Constantinos Venetsanopoulos
In this section we discuss implementation guidelines, that a developer should
69 8f9976c6 Constantinos Venetsanopoulos
take into account before writing his own client for the above APIs. Before,
70 8f9976c6 Constantinos Venetsanopoulos
starting your client implementation, make sure you have thoroughly read the
71 8f9976c6 Constantinos Venetsanopoulos
corresponding Synnefo API.
72 8f9976c6 Constantinos Venetsanopoulos
73 301294a9 Constantinos Venetsanopoulos
Pithos clients
74 301294a9 Constantinos Venetsanopoulos
--------------
75 8f9976c6 Constantinos Venetsanopoulos
76 8f9976c6 Constantinos Venetsanopoulos
User Experience
77 8f9976c6 Constantinos Venetsanopoulos
~~~~~~~~~~~~~~~
78 8f9976c6 Constantinos Venetsanopoulos
79 8f9976c6 Constantinos Venetsanopoulos
Hopefully this API will allow for a multitude of client implementations, each
80 8f9976c6 Constantinos Venetsanopoulos
supporting a different device or operating system. All clients will be able to
81 8f9976c6 Constantinos Venetsanopoulos
manipulate containers and objects - even software only designed for OOS API
82 8f9976c6 Constantinos Venetsanopoulos
compatibility. But a Pithos interface should not be only about showing
83 8f9976c6 Constantinos Venetsanopoulos
containers and folders. There are some extra user interface elements and
84 8f9976c6 Constantinos Venetsanopoulos
functionalities that should be common to all implementations.
85 8f9976c6 Constantinos Venetsanopoulos
86 8f9976c6 Constantinos Venetsanopoulos
Upon entrance to the service, a user is presented with the following elements -
87 8f9976c6 Constantinos Venetsanopoulos
which can be represented as folders or with other related icons:
88 8f9976c6 Constantinos Venetsanopoulos
89 8f9976c6 Constantinos Venetsanopoulos
 * The ``home`` element, which is used as the default entry point to the user's
90 8f9976c6 Constantinos Venetsanopoulos
   "files". Objects under ``home`` are represented in the usual hierarchical
91 8f9976c6 Constantinos Venetsanopoulos
   organization of folders and files.
92 8f9976c6 Constantinos Venetsanopoulos
 * The ``trash`` element, which contains files that have been marked for
93 8f9976c6 Constantinos Venetsanopoulos
   deletion, but can still be recovered.
94 8f9976c6 Constantinos Venetsanopoulos
 * The ``shared`` element, which contains all objects shared by the user to
95 8f9976c6 Constantinos Venetsanopoulos
   other users of the system.
96 8f9976c6 Constantinos Venetsanopoulos
 * The ``others`` element, which contains all objects that other users share
97 8f9976c6 Constantinos Venetsanopoulos
   with the user.
98 8f9976c6 Constantinos Venetsanopoulos
 * The ``groups`` element, which contains the names of groups the user has
99 8f9976c6 Constantinos Venetsanopoulos
   defined. Each group consists of a user list. Group creation, deletion, and
100 8f9976c6 Constantinos Venetsanopoulos
   manipulation is carried out by actions originating here.
101 8f9976c6 Constantinos Venetsanopoulos
 * The ``history`` element, which allows browsing past instances of ``home``
102 8f9976c6 Constantinos Venetsanopoulos
   and - optionally - ``trash``.
103 8f9976c6 Constantinos Venetsanopoulos
104 8f9976c6 Constantinos Venetsanopoulos
Objects in Pithos+ can be:
105 8f9976c6 Constantinos Venetsanopoulos
106 8f9976c6 Constantinos Venetsanopoulos
 * Moved to trash and then deleted.
107 8f9976c6 Constantinos Venetsanopoulos
 * Shared with specific permissions.
108 8f9976c6 Constantinos Venetsanopoulos
 * Made public (shared with non-Pithos+ users).
109 8f9976c6 Constantinos Venetsanopoulos
 * Restored from previous versions.
110 8f9976c6 Constantinos Venetsanopoulos
111 8f9976c6 Constantinos Venetsanopoulos
Some of these functions are performed by the client software and some by the
112 8f9976c6 Constantinos Venetsanopoulos
Pithos+ server.
113 8f9976c6 Constantinos Venetsanopoulos
114 8f9976c6 Constantinos Venetsanopoulos
In the first version of Pithos, objects could also be assigned custom tags.
115 8f9976c6 Constantinos Venetsanopoulos
This is no longer supported. Existing deployments can migrate tags into a
116 8f9976c6 Constantinos Venetsanopoulos
specific metadata value, i.e. ``X-Object-Meta-Tags``.
117 8f9976c6 Constantinos Venetsanopoulos
118 8f9976c6 Constantinos Venetsanopoulos
Implementation Guidelines
119 8f9976c6 Constantinos Venetsanopoulos
~~~~~~~~~~~~~~~~~~~~~~~~~
120 8f9976c6 Constantinos Venetsanopoulos
121 8f9976c6 Constantinos Venetsanopoulos
Pithos+ clients should use the ``pithos`` and ``trash`` containers for active
122 8f9976c6 Constantinos Venetsanopoulos
and inactive objects respectively. If any of these containers is not found, the
123 8f9976c6 Constantinos Venetsanopoulos
client software should create it, without interrupting the user's workflow. The
124 8f9976c6 Constantinos Venetsanopoulos
``home`` element corresponds to ``pithos`` and the ``trash`` element to
125 8f9976c6 Constantinos Venetsanopoulos
``trash``. Use ``PUT`` with the ``X-Move-From`` header, or ``MOVE`` to transfer
126 8f9976c6 Constantinos Venetsanopoulos
objects from one container to the other. Use ``DELETE`` to remove from
127 8f9976c6 Constantinos Venetsanopoulos
``pithos`` without trashing, or to remove from ``trash``. When moving objects,
128 8f9976c6 Constantinos Venetsanopoulos
detect naming conflicts with the ``If-Match`` or ``If-None-Match`` headers.
129 8f9976c6 Constantinos Venetsanopoulos
Such conflicts should be resolved by the user.
130 8f9976c6 Constantinos Venetsanopoulos
131 8f9976c6 Constantinos Venetsanopoulos
Object names should use the ``/`` delimiter to impose a hierarchy of folders
132 8f9976c6 Constantinos Venetsanopoulos
and files.
133 8f9976c6 Constantinos Venetsanopoulos
134 8f9976c6 Constantinos Venetsanopoulos
The ``shared`` element should be implemented as a read-only view of the
135 8f9976c6 Constantinos Venetsanopoulos
``pithos`` container, using the ``shared`` parameter when listing objects. The
136 8f9976c6 Constantinos Venetsanopoulos
``others`` element, should start with a top-level ``GET`` to retrieve the list
137 8f9976c6 Constantinos Venetsanopoulos
of accounts accessible to the user. It is suggested that the client software
138 8f9976c6 Constantinos Venetsanopoulos
hides the next step of navigation - the container - if it only includes
139 8f9976c6 Constantinos Venetsanopoulos
``pithos`` and forwards the user directly to the objects.
140 8f9976c6 Constantinos Venetsanopoulos
141 8f9976c6 Constantinos Venetsanopoulos
Public objects are not included in ``shared`` and ``others`` listings. It is
142 8f9976c6 Constantinos Venetsanopoulos
suggested that they are marked in a visually distinctive way in ``pithos``
143 8f9976c6 Constantinos Venetsanopoulos
listings (for example using an icon overlay).
144 8f9976c6 Constantinos Venetsanopoulos
145 8f9976c6 Constantinos Venetsanopoulos
A special application menu, or a section in application preferences, should be
146 8f9976c6 Constantinos Venetsanopoulos
devoted to managing groups (the ``groups`` element). All group-related actions
147 8f9976c6 Constantinos Venetsanopoulos
are implemented at the account level.
148 8f9976c6 Constantinos Venetsanopoulos
149 8f9976c6 Constantinos Venetsanopoulos
Browsing past versions of objects should be available both at the object and
150 8f9976c6 Constantinos Venetsanopoulos
the container level. At the object level, a list of past versions can be
151 8f9976c6 Constantinos Venetsanopoulos
included in the screen showing details or more information on the object
152 8f9976c6 Constantinos Venetsanopoulos
(metadata, permissions, etc.). At the container level, it is suggested that
153 8f9976c6 Constantinos Venetsanopoulos
clients use a ``history`` element, which presents to the user a read-only,
154 8f9976c6 Constantinos Venetsanopoulos
time-variable view of ``pithos`` contents. This can be accomplished via the
155 8f9976c6 Constantinos Venetsanopoulos
``until`` parameter in listings. Optionally, ``history`` may include ``trash``.
156 8f9976c6 Constantinos Venetsanopoulos
157 8f9976c6 Constantinos Venetsanopoulos
Uploading and downloading data
158 8f9976c6 Constantinos Venetsanopoulos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159 8f9976c6 Constantinos Venetsanopoulos
160 8f9976c6 Constantinos Venetsanopoulos
By using hashmaps to upload and download objects the corresponding operations
161 8f9976c6 Constantinos Venetsanopoulos
can complete much faster.
162 8f9976c6 Constantinos Venetsanopoulos
163 8f9976c6 Constantinos Venetsanopoulos
In the case of an upload, only the missing blocks will be submitted to the
164 8f9976c6 Constantinos Venetsanopoulos
server:
165 8f9976c6 Constantinos Venetsanopoulos
166 8f9976c6 Constantinos Venetsanopoulos
 * Calculate the hash value for each block of the object to be uploaded. Use
167 8f9976c6 Constantinos Venetsanopoulos
   the hash algorithm and block size of the destination container.
168 8f9976c6 Constantinos Venetsanopoulos
 * Send a hashmap ``PUT`` request for the object.
169 8f9976c6 Constantinos Venetsanopoulos
170 8f9976c6 Constantinos Venetsanopoulos
   * Server responds with status ``201`` (Created):
171 8f9976c6 Constantinos Venetsanopoulos
172 8f9976c6 Constantinos Venetsanopoulos
     * Blocks are already on the server. The object has been created. Done.
173 8f9976c6 Constantinos Venetsanopoulos
174 8f9976c6 Constantinos Venetsanopoulos
   * Server responds with status ``409`` (Conflict):
175 8f9976c6 Constantinos Venetsanopoulos
176 8f9976c6 Constantinos Venetsanopoulos
     * Server's response body contains the hashes of the blocks that do not
177 8f9976c6 Constantinos Venetsanopoulos
       exist on the server.
178 8f9976c6 Constantinos Venetsanopoulos
     * For each hash value in the server's response (or all hashes together):
179 8f9976c6 Constantinos Venetsanopoulos
180 8f9976c6 Constantinos Venetsanopoulos
       * Send a ``POST`` request to the destination container with the
181 8f9976c6 Constantinos Venetsanopoulos
         corresponding data.
182 8f9976c6 Constantinos Venetsanopoulos
183 8f9976c6 Constantinos Venetsanopoulos
 * Repeat hashmap ``PUT``. Fail if the server's response is not ``201``.
184 8f9976c6 Constantinos Venetsanopoulos
185 8f9976c6 Constantinos Venetsanopoulos
Consulting hashmaps when downloading allows for resuming partially transferred
186 8f9976c6 Constantinos Venetsanopoulos
objects. The client should retrieve the hashmap from the server and compare it
187 8f9976c6 Constantinos Venetsanopoulos
with the hashmap computed from the respective local file. Any missing parts can
188 8f9976c6 Constantinos Venetsanopoulos
be downloaded with ``GET`` requests with the additional ``Range`` header.
189 8f9976c6 Constantinos Venetsanopoulos
190 8f9976c6 Constantinos Venetsanopoulos
Syncing
191 8f9976c6 Constantinos Venetsanopoulos
~~~~~~~
192 8f9976c6 Constantinos Venetsanopoulos
193 8f9976c6 Constantinos Venetsanopoulos
Consider the following algorithm for synchronizing a local folder with the
194 8f9976c6 Constantinos Venetsanopoulos
server. The "state" is the complete object listing, with the corresponding
195 8f9976c6 Constantinos Venetsanopoulos
attributes.
196 8f9976c6 Constantinos Venetsanopoulos
 
197 30aae6bf Giorgos Verigakis
.. code-block:: python
198 30aae6bf Giorgos Verigakis
199 30aae6bf Giorgos Verigakis
  # L: Local State, the last synced state of the object.
200 30aae6bf Giorgos Verigakis
  # Stored locally (e.g. in an SQLite database)
201 30aae6bf Giorgos Verigakis
  
202 30aae6bf Giorgos Verigakis
  # C: Current State, the current local state of the object
203 30aae6bf Giorgos Verigakis
  # Returned by the filesystem
204 30aae6bf Giorgos Verigakis
  
205 30aae6bf Giorgos Verigakis
  # S: Server State, the current server state of the object
206 30aae6bf Giorgos Verigakis
  # Returned by the server (HTTP request)
207 30aae6bf Giorgos Verigakis
  
208 30aae6bf Giorgos Verigakis
  def sync(path):
209 30aae6bf Giorgos Verigakis
      L = get_local_state(path)   # Database action
210 30aae6bf Giorgos Verigakis
      C = get_current_state(path) # Filesystem action
211 30aae6bf Giorgos Verigakis
      S = get_server_state(path)  # Network action
212 30aae6bf Giorgos Verigakis
  
213 30aae6bf Giorgos Verigakis
      if C == L:
214 30aae6bf Giorgos Verigakis
          # No local changes
215 30aae6bf Giorgos Verigakis
          if S == L:
216 30aae6bf Giorgos Verigakis
              # No remote changes, nothing to do
217 30aae6bf Giorgos Verigakis
              return
218 30aae6bf Giorgos Verigakis
          else:
219 30aae6bf Giorgos Verigakis
              # Update local state to match that of the server
220 30aae6bf Giorgos Verigakis
              download(path)
221 30aae6bf Giorgos Verigakis
              update_local_state(path, S)
222 8f9976c6 Constantinos Venetsanopoulos
      else:
223 30aae6bf Giorgos Verigakis
          # Local changes exist
224 30aae6bf Giorgos Verigakis
          if S == L:
225 30aae6bf Giorgos Verigakis
              # No remote changes, update the server and the local state
226 30aae6bf Giorgos Verigakis
              upload(path)
227 30aae6bf Giorgos Verigakis
              update_local_state(path, C)
228 8f9976c6 Constantinos Venetsanopoulos
          else:
229 30aae6bf Giorgos Verigakis
              # Both local and server changes exist
230 30aae6bf Giorgos Verigakis
              if C == S:
231 30aae6bf Giorgos Verigakis
                  # We were lucky, both did the same
232 30aae6bf Giorgos Verigakis
                  update_local_state(path, C)
233 30aae6bf Giorgos Verigakis
              else:
234 30aae6bf Giorgos Verigakis
                  # Conflicting changes exist
235 30aae6bf Giorgos Verigakis
                  conflict()
236 30aae6bf Giorgos Verigakis
  
237 8f9976c6 Constantinos Venetsanopoulos
238 8f9976c6 Constantinos Venetsanopoulos
Notes:
239 8f9976c6 Constantinos Venetsanopoulos
240 8f9976c6 Constantinos Venetsanopoulos
 * States represent file hashes (it is suggested to use Merkle). Deleted or
241 8f9976c6 Constantinos Venetsanopoulos
   non-existing files are assumed to have a magic hash (e.g. empty string).