Module: OpenStack::Compute

Defined in:
lib/openstack/compute.rb,
lib/openstack/compute/image.rb,
lib/openstack/compute/flavor.rb,
lib/openstack/compute/server.rb,
lib/openstack/compute/address.rb,
lib/openstack/compute/metadata.rb,
lib/openstack/compute/exception.rb,
lib/openstack/compute/connection.rb,
lib/openstack/compute/personalities.rb,
lib/openstack/compute/authentication.rb

Defined Under Namespace

Modules: Personalities Classes: Address, AddressList, AuthV10, AuthV20, Authentication, Connection, Exception, Flavor, Image, Metadata, Server

Constant Summary collapse

VERSION =
IO.read(File.dirname(__FILE__) + '/../../VERSION')
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

.paginate(options = {}) ⇒ Object



79
80
81
82
83
84
# File 'lib/openstack/compute.rb', line 79

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.



45
46
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
# File 'lib/openstack/compute.rb', line 45

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