Module: OpenStack
- Defined in:
- lib/openstack/swift/container.rb,
lib/openstack.rb,
lib/openstack/connection.rb,
lib/openstack/network/port.rb,
lib/openstack/compute/image.rb,
lib/openstack/identity/user.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/identity/tenant.rb,
lib/openstack/network/network.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/network/qos_policy.rb,
lib/openstack/identity/connection.rb,
lib/openstack/metering/connection.rb,
lib/openstack/swift/storage_object.rb,
lib/openstack/compute/personalities.rb,
lib/openstack/identity/connection_v2.rb,
lib/openstack/identity/connection_v3.rb,
lib/openstack/network/qos_bandwidth_limit_rule.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, Identity, Image, Metering, Network, Swift, Volume Classes: AuthV10, AuthV20, AuthV30, 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
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
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/openstack.rb', line 94 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
84 85 86 87 88 89 |
# File 'lib/openstack.rb', line 84 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.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/openstack.rb', line 50 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 |