mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1830 from decklin/rs-lb-timeout
[rackspace|lb] Add support for timeout attribute
This commit is contained in:
commit
c204dbda76
5 changed files with 15 additions and 9 deletions
|
@ -26,6 +26,7 @@ module Fog
|
|||
attribute :updated
|
||||
attribute :name
|
||||
attribute :state, :aliases => 'status'
|
||||
attribute :timeout
|
||||
attribute :nodes
|
||||
|
||||
def initialize(attributes)
|
||||
|
@ -214,23 +215,22 @@ module Fog
|
|||
def create
|
||||
requires :name, :protocol, :port, :virtual_ips, :nodes
|
||||
|
||||
if algorithm
|
||||
options = { :algorithm => algorithm }
|
||||
else
|
||||
options = {}
|
||||
end
|
||||
options = {}
|
||||
options[:algorithm] = algorithm if algorithm
|
||||
options[:timeout] = timeout if timeout
|
||||
|
||||
data = service.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options)
|
||||
merge_attributes(data.body['loadBalancer'])
|
||||
end
|
||||
|
||||
def update
|
||||
requires :name, :protocol, :port, :algorithm
|
||||
requires :name, :protocol, :port, :algorithm, :timeout
|
||||
options = {
|
||||
:name => name,
|
||||
:algorithm => algorithm,
|
||||
:protocol => protocol,
|
||||
:port => port}
|
||||
:port => port,
|
||||
:timeout => timeout }
|
||||
service.update_load_balancer(identity, options)
|
||||
|
||||
#TODO - Should this bubble down to nodes? Without tracking changes this would be very inefficient.
|
||||
|
|
|
@ -8,7 +8,8 @@ module Fog
|
|||
'name' => options[:name],
|
||||
'port' => options[:port],
|
||||
'protocol' => options[:protocol],
|
||||
'algorithm' => options[:algorithm]
|
||||
'algorithm' => options[:algorithm],
|
||||
'timeout' => options[:timeout]
|
||||
}
|
||||
}
|
||||
request(
|
||||
|
|
|
@ -167,8 +167,10 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
|||
tests('create(...with algorithm...)') do
|
||||
attributes = LOAD_BALANCER_ATTRIBUTES.clone
|
||||
attributes[:algorithm] = 'LEAST_CONNECTIONS'
|
||||
attributes[:timeout] = 30
|
||||
@lb = @service.load_balancers.create attributes
|
||||
returns('LEAST_CONNECTIONS') { @lb.algorithm }
|
||||
returns(30) { @lb.timeout }
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ LOAD_BALANCERS_DETAIL_FORMAT = {
|
|||
'algorithm' => String,
|
||||
'sourceAddresses' => SOURCE_ADDRESSES,
|
||||
'status' => String,
|
||||
'timeout' => Integer,
|
||||
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
||||
'nodes' => [SINGLE_NODE_FORMAT],
|
||||
'created' => { 'time' => String },
|
||||
|
@ -147,6 +148,7 @@ LOAD_BALANCER_FORMAT = {
|
|||
'algorithm' => String,
|
||||
'sourceAddresses' => SOURCE_ADDRESSES,
|
||||
'status' => String,
|
||||
'timeout' => Integer,
|
||||
'cluster' => { 'name' => String },
|
||||
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
||||
'nodes' => [SINGLE_NODE_FORMAT],
|
||||
|
|
|
@ -17,9 +17,10 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer_tests', ['rackspace'
|
|||
tests("#create_load_balancer(#{@lb_name}, 'HTTP', 80,...with algorithm)").formats(LOAD_BALANCER_FORMAT) do
|
||||
data = @service.create_load_balancer(@lb_name, 'HTTP', 80, [{ :type => 'PUBLIC'}],
|
||||
[{ :address => '1.1.1.1', :port => 80, :condition => 'ENABLED'}],
|
||||
{ :algorithm => 'LEAST_CONNECTIONS' }).body
|
||||
{ :algorithm => 'LEAST_CONNECTIONS', :timeout => 30 }).body
|
||||
@lb_id = data['loadBalancer']['id']
|
||||
returns('LEAST_CONNECTIONS') { data['loadBalancer']['algorithm'] }
|
||||
returns(30) { data['loadBalancer']['timeout'] }
|
||||
data
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue