Using Fog with Ruby

Michael Holt maholt at
Mon Apr 8 17:35:02 EDT 2013

I have a small script that I am trying to set up that can read usage stats in Ruby Fog. The script is largely pieced together from examples from the Basho site and Fog github project. The script is below.

The issue I am running into is the following error:



                <Message>Access Denied</Message>




The list user (users = provisioning.list_users.body) works. The key and secret is for the admin user.

Why would I get an Access Denied for the admin user?

--------------RUBY CODE-------------

require 'rubygems'

require 'fog'

def show_usage(usage, key)

        utilization = usage.get_usage(  "/usage/#{key}",

                        :types          => [:access, :storage]


        objects = 0

        bytes = 0

        # Retrieve Storage information

        utilization.body['Storage']['Samples'][0].each do |k,v|

                # Sum the # of objects and bytes stored from each user bucket for per tenant totals

                if v.is_a?(Hash) # To ignore StartTime & EndTime

                        objects += v['Objects']

                        bytes   += v['Bytes']



        puts "  showUsage objects:       #{objects}"

        puts "  showUsage bytes:         #{bytes}"


configuration = {

  :riakcs_access_key_id     => "OJIPWXM698VYGEMGZLIV",

  :riakcs_secret_access_key => "fTbOq8WIBiHrUnHxBgRLDIOyo4yK2Qysrx3vjA==",

  :host                     => 'localhost',

  :port                     => 80,

  :scheme                   => "http"


Excon.defaults[:ssl_verify_peer] = false

# Requests for User Provision and Usage information

provisioning =

usage        =

users = provisioning.list_users.body

# The following block of code displays all available information for every user

users.each do | user |

  utilization = usage.get_usage("/usage/#{user['key_id']}/bx/20130401T000000Z/20130430T235959Z", :types => [:access, :storage])

  puts "§=================================================================================§"

  puts "  name:         #{user['name']}"

  puts "  display_name: #{user['display_name']}"

  puts "  email:        #{user['email']}"

  puts "  id:           #{user['id']}"

  puts "  key_id:       #{user['key_id']}"

  puts "  key_secret:   #{user['key_secret']}"

  puts "  status:       #{user['status']}"

  show_usage usage, user['key_id']


puts "§=================================================================================§"


Michael Holt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list