diff --git a/lib/fog/rackspace/models/load_balancers/load_balancer.rb b/lib/fog/rackspace/models/load_balancers/load_balancer.rb index c50fec505..20a883891 100644 --- a/lib/fog/rackspace/models/load_balancers/load_balancer.rb +++ b/lib/fog/rackspace/models/load_balancers/load_balancer.rb @@ -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. diff --git a/lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb b/lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb index 9819745aa..2c1ac54d2 100644 --- a/lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb +++ b/lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb @@ -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( diff --git a/tests/rackspace/models/load_balancers/load_balancer_tests.rb b/tests/rackspace/models/load_balancers/load_balancer_tests.rb index 645fb719d..3ee31266d 100644 --- a/tests/rackspace/models/load_balancers/load_balancer_tests.rb +++ b/tests/rackspace/models/load_balancers/load_balancer_tests.rb @@ -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? } diff --git a/tests/rackspace/requests/load_balancers/helper.rb b/tests/rackspace/requests/load_balancers/helper.rb index ffeb54eb7..7f79f9250 100644 --- a/tests/rackspace/requests/load_balancers/helper.rb +++ b/tests/rackspace/requests/load_balancers/helper.rb @@ -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], diff --git a/tests/rackspace/requests/load_balancers/load_balancer_tests.rb b/tests/rackspace/requests/load_balancers/load_balancer_tests.rb index d912aafca..525a3cee9 100644 --- a/tests/rackspace/requests/load_balancers/load_balancer_tests.rb +++ b/tests/rackspace/requests/load_balancers/load_balancer_tests.rb @@ -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