1
0
Fork 0
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:
Brian Hartsock 2011-07-27 17:06:24 -04:00
parent 14a3aab7a5
commit c0ab4bb2b4
6 changed files with 98 additions and 0 deletions

View file

@ -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={})

View 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

View 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

View 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

View file

@ -8,6 +8,11 @@ CONNECTION_LOGGING_FORMAT = {
'enabled' => Fog::Boolean
}
}
SESSION_PERSISTENCE_FORMAT = {
'sessionPersistence' => {
'persistenceType' => Fog::Nullable::String
}
}
ACCESS_LIST_FORMAT = {
'accessList' => [

View 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