Using Fog with Ruby

Michael Holt maholt at
Mon Apr 8 17:44:50 EDT 2013

There is an Nginx server acting as a proxy in front of Riak CS.

There is not a problem listing all the users with but usage ( with the same configuration has an Access Denied error.

Michael Holt

From: Tom Santero [mailto:tsantero at]
Sent: Monday, April 08, 2013 5:41 PM
To: Michael Holt
Cc: riak-users at
Subject: Re: Using Fog with Ruby

Hi Michael,

You have port 80 listed in configuration, default port is 8080.

On Mon, Apr 8, 2013 at 5:35 PM, Michael Holt <maholt at<mailto:maholt at>> wrote:

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

riak-users mailing list
riak-users at<mailto:riak-users at>

Technical Evangelist
Basho Technologies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list