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 :updated
|
||||||
attribute :name
|
attribute :name
|
||||||
attribute :state, :aliases => 'status'
|
attribute :state, :aliases => 'status'
|
||||||
|
attribute :timeout
|
||||||
attribute :nodes
|
attribute :nodes
|
||||||
|
|
||||||
def initialize(attributes)
|
def initialize(attributes)
|
||||||
|
@ -214,23 +215,22 @@ module Fog
|
||||||
def create
|
def create
|
||||||
requires :name, :protocol, :port, :virtual_ips, :nodes
|
requires :name, :protocol, :port, :virtual_ips, :nodes
|
||||||
|
|
||||||
if algorithm
|
options = {}
|
||||||
options = { :algorithm => algorithm }
|
options[:algorithm] = algorithm if algorithm
|
||||||
else
|
options[:timeout] = timeout if timeout
|
||||||
options = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
data = service.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options)
|
data = service.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options)
|
||||||
merge_attributes(data.body['loadBalancer'])
|
merge_attributes(data.body['loadBalancer'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
requires :name, :protocol, :port, :algorithm
|
requires :name, :protocol, :port, :algorithm, :timeout
|
||||||
options = {
|
options = {
|
||||||
:name => name,
|
:name => name,
|
||||||
:algorithm => algorithm,
|
:algorithm => algorithm,
|
||||||
:protocol => protocol,
|
:protocol => protocol,
|
||||||
:port => port}
|
:port => port,
|
||||||
|
:timeout => timeout }
|
||||||
service.update_load_balancer(identity, options)
|
service.update_load_balancer(identity, options)
|
||||||
|
|
||||||
#TODO - Should this bubble down to nodes? Without tracking changes this would be very inefficient.
|
#TODO - Should this bubble down to nodes? Without tracking changes this would be very inefficient.
|
||||||
|
|
|
@ -8,7 +8,8 @@ module Fog
|
||||||
'name' => options[:name],
|
'name' => options[:name],
|
||||||
'port' => options[:port],
|
'port' => options[:port],
|
||||||
'protocol' => options[:protocol],
|
'protocol' => options[:protocol],
|
||||||
'algorithm' => options[:algorithm]
|
'algorithm' => options[:algorithm],
|
||||||
|
'timeout' => options[:timeout]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
request(
|
request(
|
||||||
|
|
|
@ -167,8 +167,10 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
||||||
tests('create(...with algorithm...)') do
|
tests('create(...with algorithm...)') do
|
||||||
attributes = LOAD_BALANCER_ATTRIBUTES.clone
|
attributes = LOAD_BALANCER_ATTRIBUTES.clone
|
||||||
attributes[:algorithm] = 'LEAST_CONNECTIONS'
|
attributes[:algorithm] = 'LEAST_CONNECTIONS'
|
||||||
|
attributes[:timeout] = 30
|
||||||
@lb = @service.load_balancers.create attributes
|
@lb = @service.load_balancers.create attributes
|
||||||
returns('LEAST_CONNECTIONS') { @lb.algorithm }
|
returns('LEAST_CONNECTIONS') { @lb.algorithm }
|
||||||
|
returns(30) { @lb.timeout }
|
||||||
|
|
||||||
@lb.wait_for { ready? }
|
@lb.wait_for { ready? }
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ LOAD_BALANCERS_DETAIL_FORMAT = {
|
||||||
'algorithm' => String,
|
'algorithm' => String,
|
||||||
'sourceAddresses' => SOURCE_ADDRESSES,
|
'sourceAddresses' => SOURCE_ADDRESSES,
|
||||||
'status' => String,
|
'status' => String,
|
||||||
|
'timeout' => Integer,
|
||||||
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
||||||
'nodes' => [SINGLE_NODE_FORMAT],
|
'nodes' => [SINGLE_NODE_FORMAT],
|
||||||
'created' => { 'time' => String },
|
'created' => { 'time' => String },
|
||||||
|
@ -147,6 +148,7 @@ LOAD_BALANCER_FORMAT = {
|
||||||
'algorithm' => String,
|
'algorithm' => String,
|
||||||
'sourceAddresses' => SOURCE_ADDRESSES,
|
'sourceAddresses' => SOURCE_ADDRESSES,
|
||||||
'status' => String,
|
'status' => String,
|
||||||
|
'timeout' => Integer,
|
||||||
'cluster' => { 'name' => String },
|
'cluster' => { 'name' => String },
|
||||||
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
'virtualIps' => [VIRTUAL_IP_FORMAT],
|
||||||
'nodes' => [SINGLE_NODE_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
|
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'}],
|
data = @service.create_load_balancer(@lb_name, 'HTTP', 80, [{ :type => 'PUBLIC'}],
|
||||||
[{ :address => '1.1.1.1', :port => 80, :condition => 'ENABLED'}],
|
[{ :address => '1.1.1.1', :port => 80, :condition => 'ENABLED'}],
|
||||||
{ :algorithm => 'LEAST_CONNECTIONS' }).body
|
{ :algorithm => 'LEAST_CONNECTIONS', :timeout => 30 }).body
|
||||||
@lb_id = data['loadBalancer']['id']
|
@lb_id = data['loadBalancer']['id']
|
||||||
returns('LEAST_CONNECTIONS') { data['loadBalancer']['algorithm'] }
|
returns('LEAST_CONNECTIONS') { data['loadBalancer']['algorithm'] }
|
||||||
|
returns(30) { data['loadBalancer']['timeout'] }
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue