Module: OpenStack
- Defined in:
- lib/openstack.rb,
lib/openstack/version.rb,
lib/openstack/connection.rb,
lib/openstack/network/port.rb,
lib/openstack/compute/image.rb,
lib/openstack/volume/volume.rb,
lib/openstack/compute/flavor.rb,
lib/openstack/compute/server.rb,
lib/openstack/network/router.rb,
lib/openstack/network/subnet.rb,
lib/openstack/compute/address.rb,
lib/openstack/network/network.rb,
lib/openstack/swift/container.rb,
lib/openstack/volume/snapshot.rb,
lib/openstack/compute/metadata.rb,
lib/openstack/image/connection.rb,
lib/openstack/swift/connection.rb,
lib/openstack/volume/connection.rb,
lib/openstack/compute/connection.rb,
lib/openstack/network/connection.rb,
lib/openstack/swift/storage_object.rb,
lib/openstack/compute/personalities.rb
Overview
Initial version of this code is based on and refactored from the rackspace/ruby-cloudfiles repo @ github.com/rackspace/ruby-cloudfiles - Copyright © 2011, Rackspace US, Inc. See COPYING for license information
Defined Under Namespace
Modules: Compute, Image, Network, Swift, Volume Classes: AuthV10, AuthV20, Authentication, Connection, Exception
Constant Summary collapse
- MAX_PERSONALITY_ITEMS =
Constants that set limits on server creation
5
- MAX_PERSONALITY_FILE_SIZE =
10240
- MAX_SERVER_PATH_LENGTH =
255
- VERSION =
'1.1.2'
Class Method Summary collapse
-
.get_query_params(params, keys, url = "") ⇒ Object
e.g.
- .paginate(options = {}) ⇒ Object
-
.symbolize_keys(obj) ⇒ Object
Helper method to recursively symbolize hash keys.
Class Method Details
.get_query_params(params, keys, url = "") ⇒ Object
e.g. keys = [:limit, :marker] params = :marker=“marios”, :prefix=>“/” you want url = /container_name?limit=2&marker=marios
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/openstack.rb', line 104 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 |
.paginate(options = {}) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/openstack.rb', line 94 def self.paginate( = {}) path_args = [] path_args.push(URI.encode("limit=#{[:limit]}")) if [:limit] path_args.push(URI.encode("offset=#{[:offset]}")) if [:offset] path_args.join("&") end |
.symbolize_keys(obj) ⇒ Object
Helper method to recursively symbolize hash keys.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/openstack.rb', line 60 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 |