mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Rackspace LB: Connection throttling requests
This commit is contained in:
parent
c0ab4bb2b4
commit
0e172998a8
6 changed files with 106 additions and 0 deletions
|
@ -77,6 +77,9 @@ module Fog
|
|||
request :get_session_persistence
|
||||
request :set_session_persistence
|
||||
request :remove_session_persistence
|
||||
request :get_connection_throttling
|
||||
request :remove_connection_throttling
|
||||
request :set_connection_throttling
|
||||
|
||||
class Real
|
||||
def initialize(options={})
|
||||
|
|
15
lib/fog/rackspace/requests/get_connection_throttling.rb
Normal file
15
lib/fog/rackspace/requests/get_connection_throttling.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def get_connection_throttling(load_balancer_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:path => "loadbalancers/#{load_balancer_id}/connectionthrottle",
|
||||
:method => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
lib/fog/rackspace/requests/remove_connection_throttling.rb
Normal file
15
lib/fog/rackspace/requests/remove_connection_throttling.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def remove_connection_throttling(load_balancer_id)
|
||||
request(
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/connectionthrottle",
|
||||
:method => 'DELETE'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
lib/fog/rackspace/requests/set_connection_throttling.rb
Normal file
22
lib/fog/rackspace/requests/set_connection_throttling.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def set_connection_throttling(load_balancer_id, max_connections, min_connections, max_connection_rate, rate_interval)
|
||||
data = {
|
||||
'maxConnections' => max_connections,
|
||||
'minConnections' => min_connections,
|
||||
'maxConnectionRate' => max_connection_rate,
|
||||
'rateInterval' => rate_interval
|
||||
}
|
||||
request(
|
||||
:body => data.to_json,
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/connectionthrottle",
|
||||
:method => 'PUT'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
43
tests/rackspace/requests/connection_throttling_tests.rb
Normal file
43
tests/rackspace/requests/connection_throttling_tests.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | connection_throttling', ['rackspace']) do
|
||||
|
||||
@service = Fog::Rackspace::LoadBalancer.new
|
||||
@lb = @service.load_balancers.create({
|
||||
:name => ('fog' + Time.now.to_i.to_s),
|
||||
:protocol => 'HTTP',
|
||||
:port => 80,
|
||||
:virtual_ips => [{ :type => 'PUBLIC'}],
|
||||
:nodes => [{ :address => '10.0.0.1', :port => 80, :condition => 'ENABLED'}]
|
||||
})
|
||||
|
||||
tests('success') do
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_connection_throttling(#{@lb.id}, 10, 10, 10, 30)").succeeds do
|
||||
@service.set_connection_throttling(@lb.id, 10, 10, 10, 30)
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_connection_throttling(#{@lb.id})").formats(CONNECTION_THROTTLING_FORMAT) do
|
||||
@service.get_connection_throttling(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_connection_throttling()").succeeds do
|
||||
@service.remove_connection_throttling(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_connection_throttling(#{@lb.id}, -1, -1, -1, -1)").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_connection_throttling(@lb.id, -1, -1, -1, -1)
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
|
@ -8,6 +8,14 @@ CONNECTION_LOGGING_FORMAT = {
|
|||
'enabled' => Fog::Boolean
|
||||
}
|
||||
}
|
||||
CONNECTION_THROTTLING_FORMAT = {
|
||||
'connectionThrottle' => {
|
||||
'maxConnections' => Fog::Nullable::Integer,
|
||||
'minConnections' => Fog::Nullable::Integer,
|
||||
'maxConnectionRate' => Fog::Nullable::Integer,
|
||||
'rateInterval' => Fog::Nullable::Integer
|
||||
}
|
||||
}
|
||||
SESSION_PERSISTENCE_FORMAT = {
|
||||
'sessionPersistence' => {
|
||||
'persistenceType' => Fog::Nullable::String
|
||||
|
|
Loading…
Reference in a new issue