API: Difference between revisions

From Grid5000
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 2: Line 2:
{{Maintainer|Cyril Rohr}}
{{Maintainer|Cyril Rohr}}


== Purpose of this document ==
== Current State ==
Define the main characteristics of the Grid5000 API.
An early prototype of the upcoming API is available at: http://wsdev3.irisa.fr. Not stable, only a subset of sites are included (grenoble, bordeaux, rennes, sophia).  


== Definitions ==
Enhancements are planned on a regular basis. Backwards-compatibility is not assured. Servers might be down at any time. Please refer to this page to get the main entry-point of the API as it may change.
;Grid5000 (G5K) : an infrastructure distributed in 9 sites around France, for research in large-scale parallel and distributed systems.
;Site : a location, geographically remarkable, hosting one or more resources at the disposal of G5K principals.
;Experiment : a scientific project that tries to solve non-trivial issues, with regard to parallel and distributed systems, by using the Grid5000 platform as a testbed. A principal conducts an experiment by executing a set of jobs (with possible dependencies between them ?) on a set of resources hosted on one or more sites, which have been allocated for its sole usage for a certain period of time.
;Job : a discrete unit of work that uses one or more resources of a certain site to execute a specified program during a certain period of time.
;Resource : general denomination of a component of G5K: computing or networking asset.
;Principal : a physical person or a computing program having been granted an access to G5K.
;Program : an original piece of code containing all the instructions required for its correct execution, on a few or any kind of resources.


== Functional Requirements ==
The API is totally distributed. That is, the data is pulled from local datasets (OAR2) without the need for a centralized database.
* Experiment management (job submission, experiment supervision and control) should be supported by the API.
* Resource management (description, allocation, manipulation, supervision) should be supported by the API.
* Deployment management (description of environment images, bulk deployment on resources) should be supported by the API.
* Data management (reporting) should be supported by the API.
* Site management should be supported by the API.
* User management should be supported by the API.
* Authentication and authorization should be supported by the API.
* Asynchronous notification (email) should be supported by the API.


* User-Data synchronization should be supported by the API ?
== Available Resources ==


== Non-functional Requirements ==
; GET /sites [html | json]
* Asynchronous operations should be supported by the API.
list of sites (cached for 1 hour)
* Bulk operations should be supported by the API.
; GET /nodes [html | json]
* Auditing, logging and accounting should not be exposed.
list of all nodes (cached for 90 seconds)
* QoS does not require explicit support on API level.
; GET /sites/{site_uid} [html | json]
* Transactions do not require explicit support on API level.
site's details
* The exception handling of the API should allow for application level error recovery strategies.
; GET /sites/{site_uid}/nodes [html | json]
* Tracking of API usage should be supported by the API.
list of site's nodes (cached for 90 seconds)
* Data replication between sites should be facilitated by the API.
; GET /sites/{site_uid}/clusters [html | json]
list of site's clusters (cached for 1 hour)


== Resources addressable by the API ==
== Getting Started ==
Site, Job, Resource, User, Environment, Deployment, Notification
=== Ruby client ===
Put this code in a g5k-client.rb file:
  require 'rubygems'
  require 'rest_client' # sudo gem install rest-client
  require 'json' # sudo gem install json


The complete document can be seen at http://docs.google.com/Doc?id=dctwqtzh_41g64qxtfd
  api = RestClient::Resource.new('http://wsdev3.irisa.fr')
  begin
    # get the list of sites
    response = api['/sites'].get(:accept => 'application/json') # or api['/sites.json'].get
    sites = JSON.parse response
    sites.each do |site|
      puts "------------------ #{site['uid']} ------------------"
      puts "Clusters = [#{site['clusters'].map{|cluster| cluster['uid']}.join(", ")}]"
      # get the site's nodes. we use the URI contained in the response to locate and get new information.
      nodes = JSON.parse api["#{site['uri']}/nodes"].get(:accept => 'application/json')
      puts "Dead nodes = [#{nodes.select{|node| node['state'] == 'dead'}.collect{|node| node['uid']}.join(", ")}]"
    end
  rescue RestClient::ResourceNotFound
    puts 'Resource not found.'
  rescue RestClient::RequestTimeout
    puts 'Timeout.'
  rescue RestClient::Unauthorized
    puts 'Unauthorized.'
  rescue RestClient::RequestFailed
    puts 'Request failed.'
  rescue RestClient::ServerBrokeConnection
    puts 'Connection broken.'
  rescue Exception => e
    puts e.message
  end
 
Run with:
  ruby g5k-client.rb
 
== Planned ==
* choice: do we settle on using a REST architectural style ?
* XML format
* experiment submission

Revision as of 14:49, 19 November 2008


Current State

An early prototype of the upcoming API is available at: http://wsdev3.irisa.fr. Not stable, only a subset of sites are included (grenoble, bordeaux, rennes, sophia).

Enhancements are planned on a regular basis. Backwards-compatibility is not assured. Servers might be down at any time. Please refer to this page to get the main entry-point of the API as it may change.

The API is totally distributed. That is, the data is pulled from local datasets (OAR2) without the need for a centralized database.

Available Resources

GET /sites [html | json]

list of sites (cached for 1 hour)

GET /nodes [html | json]

list of all nodes (cached for 90 seconds)

GET /sites/{site_uid} [html | json]

site's details

GET /sites/{site_uid}/nodes [html | json]

list of site's nodes (cached for 90 seconds)

GET /sites/{site_uid}/clusters [html | json]

list of site's clusters (cached for 1 hour)

Getting Started

Ruby client

Put this code in a g5k-client.rb file:

 require 'rubygems'
 require 'rest_client' # sudo gem install rest-client
 require 'json' # sudo gem install json
 api = RestClient::Resource.new('http://wsdev3.irisa.fr')
 begin
   # get the list of sites
   response = api['/sites'].get(:accept => 'application/json') # or api['/sites.json'].get
   sites = JSON.parse response
   sites.each do |site|
     puts "------------------ #{site['uid']} ------------------"
     puts "Clusters = [#{site['clusters'].map{|cluster| cluster['uid']}.join(", ")}]"
     # get the site's nodes. we use the URI contained in the response to locate and get new information.
     nodes = JSON.parse api["#{site['uri']}/nodes"].get(:accept => 'application/json')
     puts "Dead nodes = [#{nodes.select{|node| node['state'] == 'dead'}.collect{|node| node['uid']}.join(", ")}]"
   end
 rescue RestClient::ResourceNotFound
   puts 'Resource not found.'
 rescue RestClient::RequestTimeout
   puts 'Timeout.'
 rescue RestClient::Unauthorized
   puts 'Unauthorized.'
 rescue RestClient::RequestFailed
   puts 'Request failed.'
 rescue RestClient::ServerBrokeConnection 
   puts 'Connection broken.' 
 rescue Exception => e
   puts e.message
 end

Run with:

 ruby g5k-client.rb

Planned

  • choice: do we settle on using a REST architectural style ?
  • XML format
  • experiment submission