mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|lb] added support for algorithm on create
This commit is contained in:
parent
efa6ee66ce
commit
8b502b7b76
4 changed files with 33 additions and 2 deletions
|
@ -178,7 +178,14 @@ module Fog
|
|||
private
|
||||
def create
|
||||
requires :name, :protocol, :port, :virtual_ips, :nodes
|
||||
data = connection.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash)
|
||||
|
||||
if algorithm
|
||||
options = { :algorithm => algorithm }
|
||||
else
|
||||
options = {}
|
||||
end
|
||||
|
||||
data = connection.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes_hash, options)
|
||||
merge_attributes(data.body['loadBalancer'])
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module Rackspace
|
||||
class LoadBalancers
|
||||
class Real
|
||||
def create_load_balancer(name, protocol, port, virtual_ips, nodes)
|
||||
def create_load_balancer(name, protocol, port, virtual_ips, nodes, options = {})
|
||||
data = {
|
||||
'loadBalancer' => {
|
||||
'name' => name,
|
||||
|
@ -13,6 +13,9 @@ module Fog
|
|||
#Is algorithm allowed on create?
|
||||
}
|
||||
}
|
||||
|
||||
data['loadBalancer']['algorithm'] = options[:algorithm] if options.has_key? :algorithm
|
||||
|
||||
request(
|
||||
:body => MultiJson.encode(data),
|
||||
:expects => 202,
|
||||
|
|
|
@ -127,6 +127,18 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer', ['rackspace']) do
|
|||
@instance.wait_for { ready? }
|
||||
end
|
||||
|
||||
tests('create(...with algorithm...)') do
|
||||
attributes = LOAD_BALANCER_ATTRIBUTES.clone
|
||||
attributes[:algorithm] = 'LEAST_CONNECTIONS'
|
||||
@lb = @service.load_balancers.create attributes
|
||||
returns('LEAST_CONNECTIONS') { @lb.algorithm }
|
||||
|
||||
@lb.wait_for { ready? }
|
||||
|
||||
@lb.destroy
|
||||
end
|
||||
|
||||
|
||||
tests('failure') do
|
||||
@lb = @service.load_balancers.new LOAD_BALANCER_ATTRIBUTES
|
||||
tests('#usage => Requires ID').raises(ArgumentError) do
|
||||
|
|
|
@ -14,6 +14,15 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | load_balancer_tests', ['rackspace'
|
|||
data
|
||||
end
|
||||
|
||||
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 => '10.0.0.1', :port => 80, :condition => 'ENABLED'}],
|
||||
{ :algorithm => 'LEAST_CONNECTIONS' }).body
|
||||
@lb_id = data['loadBalancer']['id']
|
||||
returns('LEAST_CONNECTIONS') { data['loadBalancer']['algorithm'] }
|
||||
data
|
||||
end
|
||||
|
||||
tests("#update_load_balancer(#{@lb_id}) while immutable").raises(Fog::Rackspace::LoadBalancers::ServiceError) do
|
||||
@service.update_load_balancer(@lb_id, { :port => 80 }).body
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue