Search code examples
rubyfog

Ruby Fog gem usage


I'm mucking about with the Fog gem and have figured out how to get started:

1.9.3-p545 :008 > c = Fog::Compute::Ecloud.new({
1.9.3-p545 :009 >       :base_path => '/cloudapi/spec',
1.9.3-p545 :010 >       ecloud_authentication_method: 'basic_auth',
1.9.3-p545 :011 >       ecloud_username: 'user@terremark.com',
1.9.3-p545 :012 >       ecloud_password: 'password'
1.9.3-p545 :013?>     })
[fog][WARNING] Unrecognized arguments: base_path
 => #<Fog::Compute::Ecloud::Real:25681720 @base_path="/cloudapi/spec" @connections={} @connection_options={} @host="https://services.enterprisecloud.terremark.com" @persistent=false @version="2013-06-01" @authentication_method=:basic_auth @access_key=nil @private_key=nil @username="user@terremark.com" @password="password"> 

I don't know what to do after this, though. How do I get the object to do anything useful? I'm new to Ruby so a lot of the code in the Fog Ecloud source doesn't make sense to me.

I've tried using different methods, but each tends to result in an error.

Can someone provide an example and explanation indicating where I need to go from here?


Solution

  • It looks like you have found a bug!

    Fog is giving you this error because base_url is not present in the recognizes line.

    I went ahead and fixed it for you. If you are using bundler you can use the latest master by updating your Gemfile to include the following

    gem 'fog', :git => 'https://github.com/fog/fog.git'

    Or alternatively you can just patch it in your code by executing the following code prior to using fog

    require 'fog'
    module Fog
      module Compute
        class Ecloud < Fog::Service
          recognizes :ecloud_username, :ecloud_password, :ecloud_version,
                     :ecloud_access_key, :ecloud_private_key,
                     :ecloud_authentication_method, :base_path 
        end
      end
    end
    

    For information about how to use fog, I would recommend reading the following page.