Method: OpenStack::Compute::Connection#limits

Defined in:
lib/openstack/compute/connection.rb

#limitsObject

Returns the current state of the programatic API limits. Each account has certain limits on the number of resources allowed in the account, and a rate of API operations.

The operation returns a hash. The :absolute hash key reveals the account resource limits, including the maxmimum amount of total RAM that can be allocated (combined among all servers), the maximum members of an IP group, and the maximum number of IP groups that can be created.

The :rate hash key returns an array of hashes indicating the limits on the number of operations that can be performed in a given amount of time. An entry in this array looks like:

{:regex=>"^/servers", :value=>50, :verb=>"POST", :remaining=>50, :unit=>"DAY", :resetTime=>1272399820, :URI=>"/servers*"}

This indicates that you can only run 50 POST operations against URLs in the /servers URI space per day, we have not run any operations today (50 remaining), and gives the Unix time that the limits reset.

Another example is:

{:regex=>".*", :value=>10, :verb=>"PUT", :remaining=>10, :unit=>"MINUTE", :resetTime=>1272399820, :URI=>"*"}

This says that you can run 10 PUT operations on all possible URLs per minute, and also gives the number remaining and the time that the limit resets.

Use this information as you’re building your applications to put in relevant pauses if you approach your API limitations.



209
210
211
212
213
# File 'lib/openstack/compute/connection.rb', line 209

def limits
  response = @connection.csreq("GET",@connection.service_host,"#{@connection.service_path}/limits",@connection.service_port,@connection.service_scheme)
  OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
  OpenStack.symbolize_keys(JSON.parse(response.body)['limits'])
end