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/identity/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, Identity, Image, 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

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



91
92
93
94
95
96
97
98
99
100
# File 'lib/openstack.rb', line 91

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



81
82
83
84
85
86
# File 'lib/openstack.rb', line 81

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

.symbolize_keys(obj) ⇒ Object

Helper method to recursively symbolize hash keys.



47
48
49
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
# File 'lib/openstack.rb', line 47

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