Method: OpenStack::Connection#req

Defined in:
lib/openstack/connection.rb

#req(method, path, options = {}) ⇒ Object

This is a much more sane way to make a http request to the api. Example: res = conn.req(‘GET’, “/servers/#id”)



179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/openstack/connection.rb', line 179

def req(method, path, options = {})
  server   = options[:server]   || @service_host
  port     = options[:port]     || @service_port
  scheme   = options[:scheme]   || @service_scheme
  headers  = options[:headers]  || {'content-type' => 'application/json'}
  data     = options[:data]
  attempts = options[:attempts] || 0
  path = @service_path + path
  res = csreq(method,server,path,port,scheme,headers,data,attempts)
  if not res.code.match(/^20.$/)
    OpenStack::Exception.raise_exception(res)
  end
  return res
end