1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

rebasing with master

This commit is contained in:
Kyle Rames 2014-06-23 10:00:12 -05:00
commit e9160bc6ad
2 changed files with 10 additions and 13 deletions

View file

@ -85,11 +85,13 @@ module Fog
end
def virtual_ips
@virtual_ips ||= begin
Fog::Rackspace::LoadBalancers::VirtualIps.new({
if @virtual_ips.nil?
@virtual_ips = Fog::Rackspace::LoadBalancers::VirtualIps.new({
:service => service,
:load_balancer => self})
@virtual_ips.clear unless persisted?
end
@virtual_ips
end
def virtual_ips=(new_virtual_ips=[])
@ -231,7 +233,7 @@ module Fog
options[:algorithm] = algorithm if algorithm
options[:timeout] = timeout if timeout
data = service.create_load_balancer(name, protocol, port, virtual_ips_hash, nodes, options)
data = service.create_load_balancer(name, protocol, port, virtual_ips, nodes, options)
merge_attributes(data.body['loadBalancer'])
end
@ -249,12 +251,6 @@ module Fog
# For now, individual nodes will have to be saved individually after saving an LB
end
def virtual_ips_hash
virtual_ips.map do |virtual_ip|
{ :type => virtual_ip.type }
end
end
def connection_logging=(new_value)
if !new_value.nil? and new_value.is_a?(Hash)
attributes[:connection_logging] = case new_value['enabled']

View file

@ -28,10 +28,11 @@ module Fog
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"=>"my-cluster.rackspace.net"}, "timeout"=>30, "created"=>{"time"=> MockData.zulu_time},
"updated"=>{"time"=>MockData.zulu_time }, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
data["virtual_ips"] = virtual_ips.map {|n| {"virtualIps"=>[{"address"=> MockData.ipv4_address, "id"=>uniq_id, "type"=>n[:type], "ipVersion"=>"IPV4"}, {"address"=> MockData.ipv6_address, "id"=> Fog::Mock.random_numbers(4), "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=> MockData.ipv6_address, "ipv4Servicenet"=>MockData.ipv4_address, "ipv4Public"=>MockData.ipv4_address}}
data["nodes"] = nodes.map {|n| {"address"=>n.address, "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n.port, "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}}
"cluster"=>{"name"=>"my-cluster.rackspace.net"}, "timeout"=>30, "created"=>{"time"=> MockData.zulu_time},
"updated"=>{"time"=>MockData.zulu_time }, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
data["virtual_ips"] = virtual_ips.map {|n| {"virtualIps"=>[{"address"=> MockData.ipv4_address, "id"=>uniq_id, "type"=> n.type, "ipVersion"=>"IPV4"}, {"address"=> MockData.ipv6_address, "id"=> Fog::Mock.random_numbers(4), "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=> MockData.ipv6_address, "ipv4Servicenet"=>MockData.ipv4_address, "ipv4Public"=>MockData.ipv4_address}}
data["nodes"] = nodes.map {|n| {"address"=>n.address, "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n.port, "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}}
Excon::Response.new(:body => data, :status => 202)
end
end