Federated Cloud APIs and SDKs

From EGIWiki
Revision as of 15:58, 15 January 2016 by Vlegoll (talk | contribs) (Keystone VOMS authentication: typo)
Jump to: navigation, search
Overview For users For resource providers Infrastructure status Site-specific configuration Architecture

This page includes pointers for application development on the EGI Federated Cloud


OCCI is the standard API for accessing the EGI Federated Cloud resources.


The Open Cloud Computing Interface (OCCI) is a RESTful Protocol and API designed to facilitate interoperable access to, and query of, cloud-based resources across multiple resource providers and heterogeneous environments. The formal specification is maintained and actively worked on by OGF’s OCCI-WG.

EGI Federated Cloud uses v1.1 of OCCI's specification, which is defined in three documents:

  • OCCI Core that describes the formal definition of the OCCI core model,
  • OCCI HTTP Rendering defines how to interact with the OCCI Core Model using the RESTful OCCI API
  • OCCI Infrastructure contains the definition of the OCCI Infrastructure extension for the IaaS domain

The OCCI Infrastructure is further extended with two new mixins for contextualization in EGI Federated Cloud:

term scheme attributes
user_data http://schemas.openstack.org/compute/instance# org.openstack.compute.user_data: string that holds base64 encoded data to be available at the VM upon instantiation
public_key http://schemas.openstack.org/instance/credentials# org.openstack.credentials.publickey.name: string with the name of the public key (optional)
org.openstack.credentials.publickey.data: string with the public key

The upcoming v1.2 of OCCI will be also supported on EGI resources.


SDKs helps you to create applications that use the EGI Federated Cloud in the language of your choice. If your language or use case is not supported by the following SDKs, you can use directly the API. Requests for new SDKs are welcomed.


jOCCI is an independent OCCI implementation by the authors of rOCCI. It satisfies the demand for a Java library, replacing the previous alternative based on JRuby. Currently in development, it is available as source from Github.


rOCCI framework implements the OCCI class structure in Ruby, which allows developers to work with OCCI concepts natively. rOCCI-api takes care of transporting OCCI messages, currently supporting HTTP as transport protocol. rOCCI-api handles EGI Fedederated Cloud authentication on behalf of the developer.


rOCCI offers a Command-Line Interface to interact with OCCI compliant servers with support to EGI Federated Cloud authentication and extensions to the standard (contextualization). HOWTO 11 contains detailed instructions on how to install and use it.


OpenStack sites of the EGI Federated Cloud can provide access through the native OpenStack API.


OpenStack API documentation is available at OpenStack developer pages. EGI Federated Cloud supports the usage of the Compute (nova) v2.1 API. Using the nova API requires a valid token first, that can be obtained as described below.



OpenStackClient (aka OSC) can be used as SDK. Check below how to install the plugin for VOMS authentication.


OpenStackClient (aka OSC) is a command-line client for OpenStack that brings the command set for Compute, Identity, Image, Object Store and Volume APIs together in a single shell with a uniform command structure. A VOMS authentication plugin is available for this CLI, you can install it with pip:

pip install openstack-voms-auth-type

For using VOMS authentication you need to specify params --os-auth-type with v2voms and --os-x509-user-proxy with the location of your proxy:

openstack --os-auth-type v2voms --os-x509-user-proxy /tmp/x509up_u1001

A complete command line for getting the list of VMs on a site follows (os_auth_url and os_project_name needs to be adjusted for each endpoint):

openstack --os-auth-type v2voms --os-x509-user-proxy  /tmp/x509up_u1001 \
          --os-auth-url https://keystone.ifca.es:5000/v2.0 \
          --os-project-name VO:fedcloud.egi.eu  \
          server list

In order to get the proper value for the project name, if you have installed the voms plugin you can use the following command line:

keystone_tenants --os-auth-url <keystone_url> \
                 --os-auth-type v2voms \
                 --os-x509-user-proxy /tmp/x509up_u1001

Keystone URL depends on the resource provider and is published in GOCDB

CA Certificates

If you get SSL errors when using the OpenStack CLI, this is probably due to missing CA certificates (or badly configured). This can be avoided by using the --insecure options to the command but this is not recommended. requests is the python library used by the client to connect to the different endpoints and this library uses a CA certificates bundle. Depending on how you have installed the requests library this bundle will be located in different places, check with the following command:

python -m requests.certs

If the output of that command is /etc/ssl/certs/ca-certificates.crt (Debian derivatives) or /etc/pki/tls/certs/ca-bundle.crt (RH derivatives) you are using system requests library which uses the default's bundle. If the output is similar to /usr/local/lib/python2.7/dist-packages/requests/cacert.pem, then you are using internal requests bundle. The procedure for adding the CAs for each of these cases is described below. If you don't have the CA certificates installed in your machine, you can get them from UMD EGI Core Trust Anchor Distribution.

System requests library (debian/ubuntu)

cd /usr/local/share/ca-certificates
for f in /etc/grid-security/certificates/*.pem ; do ln -s $f $(basename $f .pem).crt; done

System requests library (RH derivatives)

cd /etc/pki/ca-trust/source/anchors
ln -s /etc/grid-security/certificates/*.pem .
update-ca-trust extract

Requests internal bundle

cat /etc/grid-security/certificates/*.pem >> $(python -m requests.certs)


EGI Federated Cloud uses X.509 proxy certificates with VOMS extensions, but each provider in the federation has its own mechanisms to accept those credentials. To avoid dealing with the differences in authentication for each provider we recommend using the SDKs and CLIs described above that automatically handle the differences. The current mechanisms to get access to the services are:

rOCCI server (OpenNebula)
rOCCI expects that the connection is done with the user proxy as client-side certificate. rOCCI will authenticate/authorize the client with that certificate.
OCCI-OS/ooi/snf-occi (OpenStack/Synnefo)
These systems expect that a valid token is sent to the endpoint in the X-Auth-Token header, if no valid token is found, the endpoint should return in the WWW-Authenticate header the URI of the Keystone service used to obtain the tokens in the folowing form: WWW-Authenticate: Keystone uri=<KEYSTONE URI> where <KEYSTONE URI> is the location of the server (e.g. https://keystone.ifca.es:5000/). Keystone supports several authentication methods, see next section on how to get a token with a proxy certificate with Keystone.

Keystone VOMS authentication

Keystone-VOMS supports getting tokens with X.509 proxy certificates with proxy extensions. In order to get an unscoped token, you must POST a JSON request to /v2.0/tokens of your Keystone server with the proxy as client-side certificate and with the following body:

    "auth": {
        "voms": "true"

Response from server is documented at Keystone API v2 Authenticate. Unscoped tokens allow discovery of the supported tenants for the user (check Keystone API v2, list tenants) but not the usage of other OpenStack services. For that you will need to get a scoped one by submitting a POST with the following JSON document:

    "auth": {
        "voms": "true",
        "tenantName": "TenantForTheVo",

See an example of the complete authentication process at the Keystone-VOMS documentation