Initial version of this code is based on and refactored from the rackspace/ruby-cloudfiles repo @ github.com/rackspace/ruby-cloudfiles - Copyright (c) 2011, Rackspace US, Inc.
See COPYING for license information
Initial version of this code is based on and refactored from the rackspace/ruby-cloudfiles repo @ github.com/rackspace/ruby-cloudfiles - Copyright (c) 2011, Rackspace US, Inc.
See COPYING for license information
Initial version of this code is based on and refactored from the rackspace/ruby-cloudfiles repo @ github.com/rackspace/ruby-cloudfiles - Copyright (c) 2011, Rackspace US, Inc.
See COPYING for license information
See COPYING for license information.
To begin reviewing the available methods and examples, view the README.rdoc file
Example: os = OpenStack::Connection.create({:username => "herp@derp.com", :api_key=>"password",
:auth_url => "https://region-a.geo-1.identity.cloudsvc.com:35357/v2.0/", :authtenant=>"herp@derp.com-default-tenant", :service_type=>"object-store")
will return a handle to the object-storage service swift. Alternatively, passing :service_type=>"compute" will return a handle to the compute service nova.
Constants that set limits on server creation
e.g. keys = [:limit, :marker] params = {:limit=>2, :marker="marios", :prefix=>"/"} you want url = /container_name?limit=2&marker=marios
# File lib/openstack.rb, line 96 def self.get_query_params(params, keys, url="") set_keys = params.inject([]){|res, (k,v)| res << k if keys.include?(k) and not v.nil?; res } return url if set_keys.empty? url = "#{url}?#{set_keys[0]}=#{params[set_keys[0]]}" set_keys.slice!(0) set_keys.each do |k| url = "#{url}&#{k}=#{params[set_keys[0]]}" end url end
# File lib/openstack.rb, line 86 def self.paginate(options = {}) path_args = [] path_args.push(URI.encode("limit=#{options[:limit]}")) if options[:limit] path_args.push(URI.encode("offset=#{options[:offset]}")) if options[:offset] path_args.join("&") end
Helper method to recursively symbolize hash keys.
# File lib/openstack.rb, line 52 def self.symbolize_keys(obj) case obj when Array obj.inject([]){|res, val| res << case val when Hash, Array symbolize_keys(val) else val end res } when Hash obj.inject({}){|res, (key, val)| nkey = case key when String key.to_sym else key end nval = case val when Hash, Array symbolize_keys(val) else val end res[nkey] = nval res } else obj end end