Statistics
| Branch: | Tag: | Revision:

root / docs / dev-guide.rst @ d29f0371

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