Sha256: 0a81b29174a490831c4eab0625c40d47991efe865a4011774487e4b6e0b2d5d7

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

require 'rubygems'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'pp'

require File.dirname(__FILE__)+'/../lib/restfully'

logger = Logger.new(STDOUT)
logger.level = Logger::INFO

# Restfully.adapter = Restfully::HTTP::RestClientAdapter
# Restfully.adapter = Patron::Session
RestClient.log = 'stdout'
Restfully::Session.new('https://localhost:3443/sid', 'root_path' => '/grid5000', 'logger' => logger) do |grid, session|
  grid_stats = {'hardware' => {}, 'system' => {}}
  grid.sites.each do |site_uid, site|
    site_stats = site.status.inject({'hardware' => {}, 'system' => {}}) {|accu, (node_uid, node_status)|
      accu['hardware'][node_status['hardware_state']] = (accu['hardware'][node_status['hardware_state']] || 0) + 1
      accu['system'][node_status['system_state']] = (accu['system'][node_status['system_state']] || 0) + 1
      accu
    }
    grid_stats['hardware'].merge!(site_stats['hardware']) { |key,oldval,newval| oldval+newval }
    grid_stats['system'].merge!(site_stats['system']) { |key,oldval,newval| oldval+newval }
    p [site_uid, site_stats]
  end
  p [:total, grid_stats]
  puts "Getting status of a few nodes in rennes:"
  pp grid.sites['rennes'].status(:query => {:only => ['paradent-1', 'paradent-10', 'paramount-3']})
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
crohr-restfully-0.2.1 examples/grid5000.rb
crohr-restfully-0.2.2 examples/grid5000.rb
restfully-0.2.3 examples/grid5000.rb
restfully-0.2.2 examples/grid5000.rb
restfully-0.2.1 examples/grid5000.rb