mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[AWS|ELB] use ['Policies']['Proper'] as the canonical mock policy store
This commit is contained in:
parent
647f9950f7
commit
5937cb64d8
4 changed files with 14 additions and 12 deletions
|
@ -35,8 +35,6 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
load_balancer['Policies']['AppCookieStickinessPolicies'] << { 'CookieName' => cookie_name, 'PolicyName' => policy_name }
|
||||
|
||||
create_load_balancer_policy(lb_name, policy_name, 'AppCookieStickinessPolicyType', {'CookieName' => cookie_name})
|
||||
|
||||
response.body = {
|
||||
|
|
|
@ -37,8 +37,6 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
load_balancer['Policies']['LBCookieStickinessPolicies'] << { 'CookieExpirationPeriod' => cookie_expiration_period, 'PolicyName' => policy_name }
|
||||
|
||||
create_load_balancer_policy(lb_name, policy_name, 'LBCookieStickinessPolicyType', {'CookieExpirationPeriod' => cookie_expiration_period})
|
||||
|
||||
response.body = {
|
||||
|
|
|
@ -55,13 +55,6 @@ module Fog
|
|||
{"AttributeName" => key, "AttributeValue" => value.to_s}
|
||||
end
|
||||
|
||||
# Update other policies
|
||||
if %w[PublicKeyPolicyType ProxyProtocolPolicyType].include?(type_name)
|
||||
unless load_balancer['Policies']['OtherPolicies'].include?(name)
|
||||
load_balancer['Policies']['OtherPolicies'] << name
|
||||
end
|
||||
end
|
||||
|
||||
load_balancer['Policies']['Proper'] << {
|
||||
'PolicyAttributeDescriptions' => attributes,
|
||||
'PolicyName' => name,
|
||||
|
|
|
@ -105,7 +105,20 @@ module Fog
|
|||
'DescribeLoadBalancersResult' => {
|
||||
'LoadBalancerDescriptions' => load_balancers.map do |lb|
|
||||
lb['Instances'] = lb['Instances'].map { |i| i['InstanceId'] }
|
||||
lb['Policies'] = lb['Policies'].reject { |name, policies| name == 'Proper' }
|
||||
lb['Policies'] = lb['Policies']['Proper'].inject({'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [], 'OtherPolicies' => []}) { |m, policy|
|
||||
case policy['PolicyTypeName']
|
||||
when 'AppCookieStickinessPolicyType'
|
||||
cookie_name = policy['PolicyAttributeDescriptions'].detect{|h| h['AttributeName'] == 'CookieName'}['AttributeValue']
|
||||
m['AppCookieStickinessPolicies'] << { 'CookieName' => cookie_name, 'PolicyName' => policy['PolicyName'] }
|
||||
when 'LBCookieStickinessPolicyType'
|
||||
cookie_expiration_period = policy['PolicyAttributeDescriptions'].detect{|h| h['AttributeName'] == 'CookieExpirationPeriod'}['AttributeValue']
|
||||
m['LBCookieStickinessPolicies'] << { 'CookieExpirationPeriod' => cookie_expiration_period, 'PolicyName' => policy['PolicyName'] }
|
||||
else
|
||||
m['OtherPolicies'] << policy['PolicyName']
|
||||
end
|
||||
m
|
||||
}
|
||||
|
||||
lb['BackendServerDescriptions'] = lb.delete('BackendServerDescriptionsRemote')
|
||||
lb
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue