mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1438 from luizfar/add_content_caching_to_load_balancer
adding support for rackspace loadbalancer content caching
This commit is contained in:
commit
a5650fd17e
7 changed files with 102 additions and 1 deletions
|
@ -50,6 +50,8 @@ module Fog
|
|||
request :list_algorithms
|
||||
request :get_connection_logging
|
||||
request :set_connection_logging
|
||||
request :get_content_caching
|
||||
request :set_content_caching
|
||||
request :create_access_rule
|
||||
request :list_access_rules
|
||||
request :delete_access_rule
|
||||
|
|
|
@ -87,6 +87,23 @@ module Fog
|
|||
virtual_ips.load(new_virtual_ips)
|
||||
end
|
||||
|
||||
def enable_content_caching
|
||||
requires :identity
|
||||
connection.set_content_caching identity, true
|
||||
true
|
||||
end
|
||||
|
||||
def disable_content_caching
|
||||
requires :identity
|
||||
connection.set_content_caching identity, false
|
||||
true
|
||||
end
|
||||
|
||||
def content_caching
|
||||
requires :identity
|
||||
connection.get_content_caching(identity).body['contentCaching']['enabled']
|
||||
end
|
||||
|
||||
def enable_connection_logging
|
||||
requires :identity
|
||||
connection.set_connection_logging identity, true
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def get_content_caching(load_balancer_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:path => "loadbalancers/#{load_balancer_id}/contentcaching",
|
||||
:method => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def set_content_caching(load_balancer_id, value)
|
||||
data = {
|
||||
'contentCaching' => {
|
||||
'enabled' => value.to_s
|
||||
}
|
||||
}
|
||||
request(
|
||||
:body => Fog::JSON.encode(data),
|
||||
:expects => [200, 202],
|
||||
:path => "loadbalancers/#{load_balancer_id}/contentcaching",
|
||||
:method => 'PUT'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -36,6 +36,23 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
|||
returns(false) { @instance.connection_logging }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#enable_content_caching').succeeds do
|
||||
@instance.enable_content_caching
|
||||
returns(true) { @instance.content_caching }
|
||||
end
|
||||
|
||||
tests('#enable_content_caching after reload').succeeds do
|
||||
@instance.reload
|
||||
returns(true) { @instance.content_caching }
|
||||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
tests('#disable_content_caching').succeeds do
|
||||
@instance.disable_content_caching
|
||||
returns(false) { @instance.content_caching }
|
||||
end
|
||||
|
||||
tests('#usage').succeeds do
|
||||
@instance.usage
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancers | content_caching', ['rackspace']) do
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
tests("#get_content_caching(#{@lb.id})").formats(CONTENT_CACHING_FORMAT) do
|
||||
@service.get_content_caching(@lb.id).body
|
||||
end
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
tests("#set_content_caching(#{@lb.id}, true)").succeeds do
|
||||
@service.set_content_caching(@lb.id, true)
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
tests("#set_content_caching(#{@lb.id}, 'aaa')").raises(Fog::Rackspace::LoadBalancers::InternalServerError) do
|
||||
@service.set_content_caching(@lb.id, 'aaa')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -78,7 +78,11 @@ SESSION_PERSISTENCE_FORMAT = {
|
|||
'persistenceType' => Fog::Nullable::String
|
||||
}
|
||||
}
|
||||
|
||||
CONTENT_CACHING_FORMAT = {
|
||||
'contentCaching' => {
|
||||
'enabled' => Fog::Boolean
|
||||
}
|
||||
}
|
||||
ACCESS_LIST_FORMAT = {
|
||||
'accessList' => [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue