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

[AWS|ELB] mocks emulate AWS behavior

when setting a policy for the backend server a subsequent describe is
required to update the local state with the current BackendServerDescriptions
This commit is contained in:
Michael Hale 2013-08-01 16:09:13 -04:00
parent 6ca9fd7a70
commit 57cb4d7900
3 changed files with 9 additions and 4 deletions

View file

@ -87,6 +87,10 @@ module Fog
self.data[:load_balancers][lb_name] = {
'AvailabilityZones' => availability_zones,
'BackendServerDescriptions' => [],
# Hack to facilitate not updating the local data structure
# (BackendServerDescriptions) until we do a subsequent
# describe as that is how AWS behaves.
'BackendServerDescriptionsRemote' => [],
'Subnets' => options[:subnet_ids] || [],
'Scheme' => options[:scheme].nil? ? 'internet-facing' : options[:scheme],
'SecurityGroups' => options[:security_groups].nil? ? [] : options[:security_groups],

View file

@ -106,6 +106,7 @@ module Fog
'LoadBalancerDescriptions' => load_balancers.map do |lb|
lb['Instances'] = lb['Instances'].map { |i| i['InstanceId'] }
lb['Policies'] = lb['Policies'].reject { |name, policies| name == 'Proper' }
lb['BackendServerDescriptions'] = lb.delete('BackendServerDescriptionsRemote')
lb
end
}

View file

@ -42,12 +42,12 @@ module Fog
end
end
# Update backend policies
description = load_balancer['BackendServerDescriptions'].find{|d| d["InstancePort"] == instance_port } || {}
# Update backend policies:
description = load_balancer['BackendServerDescriptionsRemote'].find{|d| d["InstancePort"] == instance_port } || {}
description["InstancePort"] = instance_port
description["PolicyNames"] = policy_names
load_balancer['BackendServerDescriptions'].delete_if{|d| d["InstancePort"] == instance_port }
load_balancer['BackendServerDescriptions'] << description
load_balancer['BackendServerDescriptionsRemote'].delete_if{|d| d["InstancePort"] == instance_port }
load_balancer['BackendServerDescriptionsRemote'] << description
Excon::Response.new.tap do |response|
response.status = 200