mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Rackspace LB: Added session persistence requests
This commit is contained in:
parent
14a3aab7a5
commit
c0ab4bb2b4
6 changed files with 98 additions and 0 deletions
|
@ -74,6 +74,9 @@ module Fog
|
|||
request :list_access_rules
|
||||
request :delete_access_rule
|
||||
request :delete_all_access_rules
|
||||
request :get_session_persistence
|
||||
request :set_session_persistence
|
||||
request :remove_session_persistence
|
||||
|
||||
class Real
|
||||
def initialize(options={})
|
||||
|
|
15
lib/fog/rackspace/requests/get_session_persistence.rb
Normal file
15
lib/fog/rackspace/requests/get_session_persistence.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def get_session_persistence(load_balancer_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:path => "loadbalancers/#{load_balancer_id}/sessionpersistence",
|
||||
:method => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
lib/fog/rackspace/requests/remove_session_persistence.rb
Normal file
15
lib/fog/rackspace/requests/remove_session_persistence.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def remove_session_persistence(load_balancer_id)
|
||||
request(
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/sessionpersistence",
|
||||
:method => 'DELETE'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/rackspace/requests/set_session_persistence.rb
Normal file
21
lib/fog/rackspace/requests/set_session_persistence.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancer
|
||||
class Real
|
||||
def set_session_persistence(load_balancer_id, persistence_type)
|
||||
data = {
|
||||
'sessionPersistence' => {
|
||||
'persistenceType' => persistence_type
|
||||
}
|
||||
}
|
||||
request(
|
||||
:body => data.to_json,
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/sessionpersistence",
|
||||
:method => 'PUT'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,6 +8,11 @@ CONNECTION_LOGGING_FORMAT = {
|
|||
'enabled' => Fog::Boolean
|
||||
}
|
||||
}
|
||||
SESSION_PERSISTENCE_FORMAT = {
|
||||
'sessionPersistence' => {
|
||||
'persistenceType' => Fog::Nullable::String
|
||||
}
|
||||
}
|
||||
|
||||
ACCESS_LIST_FORMAT = {
|
||||
'accessList' => [
|
||||
|
|
39
tests/rackspace/requests/session_persistence_tests.rb
Normal file
39
tests/rackspace/requests/session_persistence_tests.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancer | session_persistence', ['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("#set_session_persistence(#{@lb.id}, 'HTTP_COOKIE')").succeeds do
|
||||
@service.set_session_persistence(@lb.id, 'HTTP_COOKIE')
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_session_persistence{@lb.id})").formats(SESSION_PERSISTENCE_FORMAT) do
|
||||
data = @service.get_session_persistence(@lb.id).body
|
||||
returns('HTTP_COOKIE') { data['sessionPersistence']['persistenceType'] }
|
||||
data
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#remove_session_persistence()").succeeds do
|
||||
@service.remove_session_persistence(@lb.id)
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_session_persistence(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancer::BadRequest) do
|
||||
@service.set_session_persistence(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
@lb.destroy
|
||||
end
|
Loading…
Reference in a new issue