Revision 7d1d34a2 docs/index.rst

b/docs/index.rst
6 6
snf-occi's documentation!
7 7
====================================
8 8

  
9
**snf-occi** snf-occi implements the OCCI specification on top of synnefo’s API in order to achieve greater interoperability in common tasks referring cyclades management. This module is a translation bridge between OCCI and the Openstack API and is designed to be as independent as possible from the rest IaaS, providing an OCCI compatibility layer to other services using Openstack API. 
9
**snf-occi** implements the OCCI specification on top of synnefo’s API in order to achieve greater interoperability. This module is a translation bridge between OCCI and the synnefo endpoints.  It is designed to be as independent as possible from the rest IaaS, providing an OCCI compatibility layer. 
10

  
11
**snf-occi** utilizes the API library for the components of the synnefo ecosystem provided by `kamaki <http://www.synnefo.org/docs/kamaki/latest>`_  . It is built on top of kamaki.clients lib in order to communicate with the required synnefo APIs.
10 12

  
11
**snf-occi** is based in modules provided by kamaki cli-tool when dealing with REST API calls to Openstack.
12 13

  
13 14
.. toctree::
14 15
   :maxdepth: 2
......
23 24

  
24 25
The master document for the OCCI specification is at `OCCI Specification <http://occi-wg.org/about/specification/>`_
25 26

  
26
OCCI and Cyclades
27
OCCI and Synnefo
27 28
-----------------
28
The OCCI implementation in Cyclades is going to be based in the OCCI Infrastructure specification, in which common Cloud IaaS components are described. The correspondence between OCCI and Cyclades is as follows:
29
The OCCI implementation for Synnefo is in accordance with the OCCI Infrastructure specification, that describes common Cloud IaaS components. The correspondence between OCCI and Cyclades is as follows:
29 30

  
30 31
+-------------------------+-------------------------+
31 32
|OCCI                     |Cyclades                 |
......
36 37
+-------------------------+-------------------------+
37 38
|Resource Template        |Synnefo flavors          |
38 39
+-------------------------+-------------------------+
39
|Networking               |NA                       |
40
|Network                  |Synnefo networks         |
40 41
+-------------------------+-------------------------+
41 42
|Storage                  |NA                       |
42 43
+-------------------------+-------------------------+
......
46 47
**Note:** Metadata info in synnefo's servers cannot be represented (clearly) using OCCI's components.
47 48

  
48 49

  
49
OCCI requirements
50
------------------
51
Due to OCCI's structure there cannot be straightforward mapping to Cyclades/OpenStack API. The missing elements are networking and storage capabilities using current Cyclades API.
52

  
53 50
OCCI operations
54
****************
51
------------------
55 52

  
56 53
Below you can see the required procedures/operations for OCCI compatibility.
57 54
   
58 55
* Handling the query interface
59 56
   * Query interface must be found under path /-/
60 57
   * Retrieve all registered Kinds, Actions and Mixins
61
   * Add a mixin definition
62
   * Remove a mixin definition
58
   * Add a Mixin definition
59
   * Remove a Mixin definition
63 60

  
64 61
* Operation on paths in the name-space 
65 62
   * Retrieving the state of the name-space hierarchy
......
88 85

  
89 86

  
90 87
OCCI client/server library
91
==========================
88
---------------------------
92 89

  
93
pyssf is a collection of OCCI python modules. It aims to provide a high-level interface for the integration of OCCI to other new or existing applications. 
90
**pyssf** is a collection of OCCI python modules. It aims at providing a high-level interface for the integration of OCCI to other new or existing applications. 
94 91

  
95
Features:
96
---------
92
**Features:**
97 93

  
98
* It includes a REST API service with the OCCI specifications already implemented
99
* It only requires a custom backend and registry to interact with Cyclades
100 94

  
101
Current progress
102
=================
103
By now we have considered implementing only the **Compute** backend of the OCCI to Cyclades/Openstack API bridge and we are planning to extend it for **networking** and **storage** capabilities.
95
* It includes the implementation of a REST API service with the OCCI specifications already implemented
96
* It only requires a custom backend and registry to interact with synnefo main components (e.g., Cyclades, Astakos. etc.)
104 97

  
105
Installation
98
snf-occi Installation
99
======================
100

  
101
Requirements
106 102
-------------
107 103

  
108 104
First, you need to install the required dependencies which can be found here:
109 105

  
110
* `pyssf <https://pypi.python.org/pypi/pyssf>`_
111
* `kamaki <https://code.grnet.gr/projects/kamaki>`_  
106
* `pyssf at pypi <https://pypi.python.org/pypi/pyssf>`_
107
* `Kamaki repository  <https://code.grnet.gr/projects/kamaki>`_  (Detailed description for installation of kamaki can be found in this `Guide <http://www.synnefo.org/docs/kamaki/latest/installation.html>`_).
108

  
109
Moreover, some additional packages need to be installed::
110

  
111
$ apt-get install python-pip
112
$ pip install webob
113
$ apt-get install python-dev
114
$ pip install eventlet
115
$ apt-get install python-m2crypto
116
$ apt-get install python-pastedeploy
117
$ apt-get install libvomsapi1
118

  
119

  
120
Installation
121
-------------
122

  
123
Upon the completion of the previous steps, you can install **snf-occi** API translation server by cloning our latest source code:
124

  
125
* `snf-occi Repository <https://code.grnet.gr/git/snf-occi>`_ 
126

  
127
**NOTE**: Before running setup.py, you have to edit the config.py in order to setup the following information:
128

  
129
* Server related settings, e.g.,  API server port, hostname and core architecture
130
* Endpoints for the ComputeClient and AstakosClient 
131
* Enable / Disable VOMS authentication
132
* Paths to directories containing certificates and configuration files that enable the process for VOMS authentication
133

  
134

  
135

  
136
Finally, the installation of snf-occi is done with the following steps::
137

  
138
$ python setup.py build
139
$ python setup.py install
140

  
141

  
142
In case that VOMS authentication mode is disabled, then the snf-occi server can be started by typing **snf-occi**.
143

  
144

  
145
Enabling VOMS authentication
146
============================
147

  
148

  
149
VOMS Requirements
150
------------------
151

  
152
* Installation of **EUgridPMA** certificates, which must be located on the standard location **/etc/grid-security/certificates**: 
153

  
154
::
155

  
156
$ wget -q -O - https://dist.eugridpma.info/distribution/igtf/current/GPG-KEY-EUGridPMA-RPM-3 | sudo apt-key add -
157
$ echo "deb http://repository.egi.eu/sw/production/cas/1/current egi-igtf core" > /etc/apt/sources.list.d/egi-cas.list (as root)
158
$ sudo apt-get update
159
$ sudo apt-get install ca-policy-egi-core
160

  
161
* Installation of the **fetch-crl** package:
162

  
163
::
164

  
165
$ sudo apt-get install fetch-crl
166
$ sudo fetch-crl
167

  
168
Moreover, a valid certificate issued by a valid CA is required for the server hosting snf-occi. The certificates of valid CAs are located in **/etc/grid-security/certificates/**. The server certificate and key file need to be located in **/etc/ssl** (if the directories with the certificate and key files differ, then the paths to these directories must be appropriately set in the **snfOCCI/config.py**). 
169

  
170
::
171

  
172
$ ls /etc/ssl/certs/server.crt
173
$ ls /e	tc/ssl/private/server.key
174

  
175

  
176
Apache Installation and Configuration
177
------------------------------------------------
178
To enable VOMS authentication in snf-occi, the existence of a working Apache installation is a prerequisite. The installation and configuration process is as follows:
179

  
180
* Installation of Apache WSGI with mod_ssl enabled::
181

  
182
	$ sudo apt-get install apache2 libapache2-mod-wsgi
183
	$ sudo a2enmod ssl
184
	$ sudo a2enmod headers
185

  
186
* Create a user synnefo and configure Apache::
187

  
188
	$ sudo adduser synnefo
189
	
190
Assuming that the snf-occi server has the FQDM nodeX.example.com, then the following configurations are required:
191

  
192

  
193
* In **/etc/apache2/sites-enabled/snf_VOMS** add::
194

  
195
	WSGIDaemonProcess snf_voms user=synnefo group=nogroup processes=3 threads=10
196
	Listen 8888
197
	<VirtualHost _default_:8888>
198
  	  LogLevel warn
199
  	  ErrorLog ${APACHE_LOG_DIR}/error.log
200
	  CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
201

  
202
	  RequestHeader set X-Forwarded-Protocol "https" 
203
  
204
	  SSLEngine on
205
	  SSLCertificateFile    /etc/ssl/certs/server.crt
206
	  SSLCertificateKeyFile /etc/ssl/private/server.key
207

  
208
	  SSLCACertificatePath /etc/grid-security/certificates
209
	  SSLCARevocationPath /etc/grid-security/certificates
210
	  SSLVerifyClient optional
211
	  SSLVerifyDepth 20
212
	  SSLProtocol all -SSLv2
213
	  SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
214
	  SSLOptions +StdEnvVars +ExportCertData
215
	  WSGIScriptAlias /main /usr/lib/cgi-bin/snf_voms/main
216
	  WSGIProcessGroup snf_voms
217
	  WSGIPassAuthorization On
218
	  WSGIScriptAlias / /usr/lib/cgi-bin/snf_voms/main
219
	</VirtualHost>
220

  
221
	Listen 5000 
222
	<VirtualHost _default_:5000>
223
	  LogLevel warn
224
	  ErrorLog ${APACHE_LOG_DIR}/error.log
225
	  CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
226

  
227
	  SSLEngine on
228
	  SSLCertificateFile    /etc/ssl/certs/server.crt
229
	  SSLCertificateKeyFile /etc/ssl/private/server.key
230

  
231
	  SSLCACertificatePath /etc/grid-security/certificates
232
	  SSLCARevocationPath /etc/grid-security/certificates
233
	  SSLVerifyClient optional
234
	  SSLVerifyDepth 20
235
	  SSLProtocol all -SSLv2
236
	  SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
237
	  SSLOptions +StdEnvVars +ExportCertData
238

  
239
	  WSGIScriptAlias /main /usr/lib/cgi-bin/snf_voms/main_auth
240
	  WSGIScriptAlias /main /usr/lib/cgi-bin/snf_voms/main_auth
241
	  WSGIProcessGroup snf_voms
242
	</VirtualHost>
243

  
244

  
245
* In **/etc/apache2/httpd.conf** add::
246
	ServerName nodeX.example.com
247

  
248

  
249
* In **/etc/apache2/conf.d/wsgi-snf_voms.conf** add::
250

  
251
	WSGIScriptAlias /main /var/www/cgi-bin/snf_voms/main
252
	WSGIScriptAlias /main /usr/lib/cgi-bin/snf_voms/main_auth
253

  
254
	<Location "/main">
255
 	  SSLRequireSSL
256
 	  Authtype none
257
	</Location>
258

  
259
* To support VOMS authentication, snf-occi must be executed as a WSGI application. To achive this goal, the respective scripts included in the snf-occi repository need to be placed in the appropriate directories. In more detail, you have to copy the following scripts located in the **snfOCCI/httpd** directory in the appropriate directory and create the following links ::
260

  
261
	$ mkdir /usr/lib/cgi-bin/snf_voms
262
	$ cp snf-occi/snfOCCI/httpd/snf_voms.py /usr/lib/cgi-bin/snf_voms/snf_voms.py
263
	$ ln /usr/lib/cgi-bin/snf_voms/snf_voms.py /usr/lib/cgi-bin/snf_voms/main
264
	$ cp snf-occi/snfOCCI/httpd/snf_voms_auth.py /usr/lib/cgi-bin/snf_voms/snf_voms_auth.py
265
	$ ln /usr/lib/cgi-bin/snf_voms/snf_voms_auth.py /usr/lib/cgi-bin/snf_voms/main_auth
266
	$ cp snf-occi/snfOCCI/snf_voms_auth-paste.ini /home/synneo/snf_voms_auth-paste.ini
267
	$ cp snf-occi/snfOCCI/snf_voms-paste.ini /home/synnefo/snf_voms-paste.ini 
268

  
269

  
270

  
271
* In **/etc/apache2/envvars** add::
272

  
273
	export OPENSSL_ALLOW_PROXY_CERTS=1
274

  
275

  
276
Configure VO Membership Information
277
------------------------------------
278

  
279
In order to support VOMS authentication, some configuration information is required. This information is provided in the following files. For example, to allow the access for members of the fedcloud.egi.eu VO, the following configuration files need to be present in the directory **/etc/snf** :
280

  
281
* In **/etc/snf/voms.json** add::
282

  
283
	{
284
    	  "fedcloud.egi.eu": 
285
          {
286
            "tenant": "EGI_FCTF"
287
          }
288
        }
289

  
290
Moreover, the vomsdir information and the vomses file need to be created and altered respectively for each allowed VO (see also `Fedcloud-tf:CLI Environment <https://wiki.egi.eu/wiki/Fedcloud-tf:CLI_Environment>`_). For example, the respective folders and files for the **fedcloud.egi.eu** VO are created in the following two steps:
291

  
292
* Creation of the vomsdir information::
112 293

  
113
Then you can install **snf-occi** API translation server by cloning our latest source code:
294
	$ mkdir -p /etc/grid-security/vomsdir/fedcloud.egi.eu
295
	$ cat > /etc/grid-security/vomsdir/fedcloud.egi.eu/voms1.egee.cesnet.cz.lsc <<EOF 
296
	/DC=org/DC=terena/DC=tcs/OU=Domain Control Validated/CN=voms1.egee.cesnet.cz 
297
	/C=NL/O=TERENA/CN=TERENA eScience SSL CA 
298
	EOF
299
	$ cat > /etc/grid-security/vomsdir/fedcloud.egi.eu/voms2.egee.cesnet.cz.lsc <<EOF 
300
	/DC=org/DC=terena/DC=tcs/OU=Domain Control Validated /CN=voms2.grid.cesnet.cz
301
	/C=NL/O=TERENA/CN=TERENA eScience SSL CA
302
	EOF
114 303

  
115
* `snf-occi <https://code.grnet.gr/projects/snf-occi>`_ 
116 304

  
117
**NOTE**: Before running setup.py you have to edit the **config.py** setting up:
305
* Creation / Extension of the vomses file::
118 306

  
119
* API Server port
120
* VM hostname naming pattern (FQDN providing the id of each compute resource)
121
* VM core architecture
307
	$ cat >> /etc/vomses <<EOF
308
	"fedcloud.egi.eu" "voms1.egee.cesnet.cz" "15002" "/DC=org/DC=terena/DC=tcs/OU=Domain Control Validated/CN=voms1.egee.cesnet.cz" "fedcloud.egi.eu" "24"
309
	"fedcloud.egi.eu" "voms2.grid.cesnet.cz" "15002" "/DC=org/DC=terena/DC=tcs/OU=Domain Control Validated /CN=voms2.grid.cesnet.cz" "fedcloud.egi.eu" "24"
310
	EOF
122 311

  
123
Finally you can start the API translation server by running **snf-occi**
312
Upon the completion of all configuration actions, start (or restart) the Apache server:
124 313

  
125
Examples:
126
---------
127
For the examples below we assume server is running on localhost (port 8888) and authentication token is $AUTH. For the HTTP requests we are using **curl**.
314
$  sudo service apache2 start
315

  
316

  
317
Usage Scenarios
318
================
319

  
320
For the examples below, we assume that the snf-occi server is running on  <snf-occi_host> (port 8888) and authentication token is $AUTH. For the HTTPS requests we are using **curl**.
321

  
322
The user must have a valid authentication token in order to interact with the snf-occi endpoint. In case that the VOMS authentication is enabled, then the user can provide his/her proxy certificate in order to obtain a valid authentication token. 
323

  
324
* A user participating in a specific VO must have a valid VOMS proxy. To obtain a proxy certificate type the command (More information about the setup of a FedCloud command-line environment in order to obtain a proxy certificate can be found at `Fedcloud-tf:CLI Environment <https://wiki.egi.eu/wiki/Fedcloud-tf:CLI_Environment>`_.)::
325
	
326
	$ voms-proxy-init -voms fedcloud.egi.eu -rfc
327

  
328

  
329
* Retrieve an authentication token (hence referring as $AUTH) from the snf-occi server, assuming that the proxy certificate is the file $X509_USER_PROXY (e.g., /tmp/x509up_u1000) and <snf-occi_host> is the hostname of server hosting snf-occi::
330

  
331
	$ curl --capath /etc/grid-security/certificates --cert $X509_USER_PROXY -d '{"auth":{"voms": true, "tenantName": "fedcloud.egi.eu"}}' -v -X GET https://<snf-occi_host>:5000/main/v2.0/tokens 
128 332

  
129 333
* Retrieve all registered Kinds, Actions and Mixins:
130 334

  
131 335
  ::
132 336

  
133
    curl -v -X GET localhost:8888/-/ -H 'Auth-Token: $AUTH'
337
	$ curl --capath /etc/grid-security/certificates -X GET https://<snf-occi_host>:8888/-/ -H 'X-Auth-Token:$AUTH'
338

  
134 339

  
135
* Create a new VM described by the flavor 'C2R2048D20' and using the image 'Debian'
340
* List all VMs::
341

  
342
	$ curl --capath /etc/grid-security/certificates -X GET https://<snf-occi_host>:8888/compute/ -H 'X-Auth-Token:$AUTH'
343
	
344

  
345
* Create a new VM using the the flavor 'c1r1024d5rdb' and the image 'ubuntu_server'
136 346

  
137 347
  ::
138 348
 
139
    curl -v -X POST localhost:8888/compute/ 
140
    -H 'Category: compute; scheme=http://schemas.ogf.org/occi/infrastructure#;  class="kind";' 
141
    -H 'X-OCCI-Attribute: occi.core.title = newVM' -H 'Category: C2R2048D20; scheme=http://schemas.ogf.org/occi/infrastructure#; ' 
142
    -H 'Category: Debian; scheme=http://schemas.ogf.org/occi/infrastructure#;' -H 'Auth-Token: $AUTH' 
143
    -H 'Content-type: text/occi'
349
	$ curl --capath /etc/grid-security/certificates -X POST https://<snf-occi_host>:8888/compute/ -H 'Category: compute; scheme=http://schemas.ogf.org/occi/infrastructure#;  class="kind";' -H 'X-OCCI-Attribute: occi.core.title = newVM' -H 'Category: c1r1024d5drbd; scheme=http://schemas.ogf.org/occi/resource_tpl#; ' -H 'Category: ubuntu_server; scheme=http://schemas.ogf.org/occi/os_tpl#;' -H 'X-Auth-Token:$AUTH'  -H 'Content-type: text/occi'
144 350

  
145
* Retrieve all the details of th VM with identifier $ID
146 351

  
147
  ::
352
* Retrieve all the details of th VM with identifier $ID::
148 353

  
149
    curl -v -X GET localhost:8888/compute/$ID -H 'Auth-Token: $AUTH'
354
	$ curl --capath /etc/grid-security/certificates -X GET https://<snf-occi_host>:8888/compute/$ID -H 'X-Auth-Token: $AUTH'
150 355

  
151
* Delete the VM with identifier $ID
152 356

  
153
  ::
357

  
358
* Delete the VM with identifier $ID::
154 359
  
155
    curl -v -X DELETE localhost:8888/compute/$ID -H 'Auth-Token: $AUTH'
360
	$ curl --capath /etc/grid-security/certificates -X DELETE https://<snf-occi_host>:8888/compute/$ID -H 'X-Auth-Token: $AUTH'
361

  
156 362

  
363
Moreover, the `rOCCI cli <https://github.com/gwdg/rOCCI-cli>`_ can be used directly from shell defining the following parameters:
157 364

  
365
	* -- endpoint https://<snf-occi_host>:8888 
366
	* --auth x509
367
	* -- voms
368
	* --user-cred $X509_USER_PROXY
369

  
370

  
371
Future Directions
372
-----------------
373

  
374
The snf-occi server is constantly evolving and being enhanced with more new features in order to support more advanced functionalities. For instance, some upcoming features are:
375

  
376
* VM Contextualization 
377
* Network Management
378
* Data Management
379
* VM Image Management
380

  
381
 
158 382
Indices and tables
159 383
==================
160 384

  
161 385
* :ref:`genindex`
162 386
* :ref:`search`
163

  

Also available in: Unified diff