mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2088 from rebelagentm/lb_stats
[Rackspace|Load Balancers] Added get_stats and mock for create_load_balancer
This commit is contained in:
commit
f5688e61c7
7 changed files with 76 additions and 0 deletions
|
@ -73,6 +73,7 @@ module Fog
|
|||
request :get_error_page
|
||||
request :set_error_page
|
||||
request :remove_error_page
|
||||
request :get_stats
|
||||
|
||||
module Shared
|
||||
|
||||
|
|
|
@ -196,6 +196,11 @@ module Fog
|
|||
service.get_load_balancer_usage(identity, options).body
|
||||
end
|
||||
|
||||
def stats
|
||||
requires :identity
|
||||
service.get_stats(identity).body
|
||||
end
|
||||
|
||||
def error_page
|
||||
requires :identity
|
||||
service.get_error_page(identity).body['errorpage']['content']
|
||||
|
|
|
@ -24,6 +24,18 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_load_balancer(name, protocol, port, virtual_ips, nodes, options = {})
|
||||
data = {"loadBalancer"=>{"name"=>name, "id"=>uniq_id, "protocol"=>protocol, "port"=>port, "algorithm"=>"RANDOM", "status"=>"BUILD",
|
||||
"cluster"=>{"name"=>"ztm-n13.dfw1.lbaas.rackspace.net"}, "timeout"=>30, "created"=>{"time"=>"2013-08-20T20:52:44Z"},
|
||||
"updated"=>{"time"=>"2013-08-20T20:52:44Z"}, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
|
||||
data["virtual_ips"] = virtual_ips.collect {|n| {"virtualIps"=>[{"address"=>"192.237.192.152", "id"=>uniq_id, "type"=>n[:type], "ipVersion"=>"IPV4"}, {"address"=>"2001:4800:7901:0000:ba81:a6a5:0000:0002", "id"=>9153169, "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=>"2001:4800:7901::13/64", "ipv4Servicenet"=>"10.189.254.5", "ipv4Public"=>"166.78.44.5"}}
|
||||
data["nodes"] = nodes.collect {|n| {"address"=>n[:address], "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n[:port], "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}
|
||||
data = Excon::Response.new(:body => data, :status => 202)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
31
lib/fog/rackspace/requests/load_balancers/get_stats.rb
Normal file
31
lib/fog/rackspace/requests/load_balancers/get_stats.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def get_stats(load_balancer_id)
|
||||
|
||||
request(
|
||||
:expects => 200,
|
||||
:path => "loadbalancers/#{load_balancer_id}/stats",
|
||||
:method => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_stats(load_balancer_id)
|
||||
mock_data = {
|
||||
'connectTimeOut' => 0,
|
||||
'connectError' => 1,
|
||||
'connectFailure' => 2,
|
||||
'dataTimedOut' => 3,
|
||||
'keepAliveTimedOut' => 4,
|
||||
'maxConn' => 5
|
||||
}
|
||||
|
||||
Excon::Response.new(:body => mock_data, :status => 200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,6 +20,11 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
|||
end
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
|
||||
tests('#stats').succeeds do
|
||||
@instance.stats
|
||||
end
|
||||
|
||||
tests('#enable_connection_logging').succeeds do
|
||||
@instance.enable_connection_logging
|
||||
returns(true) { @instance.connection_logging }
|
||||
|
|
13
tests/rackspace/requests/load_balancers/get_stats_tests.rb
Normal file
13
tests/rackspace/requests/load_balancers/get_stats_tests.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer_get_stats', ['rackspace']) do
|
||||
|
||||
given_a_load_balancer_service do
|
||||
given_a_load_balancer do
|
||||
tests('success') do
|
||||
@lb.wait_for { ready? }
|
||||
tests("#get_stats(#{@lb.id})").formats(LOAD_BALANCER_STATS_FORMAT) do
|
||||
@service.get_stats(@lb.id).body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -32,6 +32,15 @@ LOAD_BALANCER_USAGE_FORMAT = {
|
|||
]
|
||||
}
|
||||
|
||||
LOAD_BALANCER_STATS_FORMAT = {
|
||||
'connectTimeOut' => Integer,
|
||||
'connectError' => Integer,
|
||||
'connectFailure' => Integer,
|
||||
'dataTimedOut' => Integer,
|
||||
'keepAliveTimedOut' => Integer,
|
||||
'maxConn' => Integer
|
||||
}
|
||||
|
||||
SSL_TERMINATION_FORMAT = {
|
||||
'sslTermination' => {
|
||||
'certificate' => String,
|
||||
|
|
Loading…
Add table
Reference in a new issue