mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge remote branch 'ktheory/aws_elb_requests'
This commit is contained in:
commit
a0377c1952
5 changed files with 108 additions and 0 deletions
|
@ -6,14 +6,22 @@ module Fog
|
|||
recognizes :region, :host, :path, :port, :scheme, :persistent
|
||||
|
||||
request_path 'fog/aws/requests/elb'
|
||||
request :configure_health_check
|
||||
#request :create_app_cookie_stickiness_policy
|
||||
#request :create_db_cookie_stickiness_policy
|
||||
request :create_load_balancer
|
||||
#request :create_load_balancer_listeners
|
||||
request :delete_load_balancer
|
||||
#request :delete_load_balancer_listeners
|
||||
#request :delete_load_balancer_policy
|
||||
request :deregister_instances_from_load_balancer
|
||||
request :describe_instance_health
|
||||
request :describe_load_balancers
|
||||
request :disable_availability_zones_for_load_balancer
|
||||
request :enable_availability_zones_for_load_balancer
|
||||
request :register_instances_with_load_balancer
|
||||
#request :set_load_balancer_listener_ssl_certificate
|
||||
#request :set_load_balancer_policies_of_listener
|
||||
|
||||
class Mock
|
||||
|
||||
|
|
37
lib/fog/aws/parsers/elb/configure_health_check.rb
Normal file
37
lib/fog/aws/parsers/elb/configure_health_check.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module ELB
|
||||
|
||||
class ConfigureHealthCheck < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@health_check = {}
|
||||
@response = { 'ConfigureHealthCheckResult' => {}, 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'Target'
|
||||
@health_check[name] = @value
|
||||
when 'Interval', 'Timeout', 'UnhealthyThreshold', 'HealthyThreshold'
|
||||
@health_check[name] = @value.to_i
|
||||
|
||||
when 'HealthCheck'
|
||||
@response['ConfigureHealthCheckResult'][name] = @health_check
|
||||
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/fog/aws/requests/elb/configure_health_check.rb
Normal file
41
lib/fog/aws/requests/elb/configure_health_check.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/configure_health_check'
|
||||
|
||||
# Enables the client to define an application healthcheck for the instances.
|
||||
# See http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/index.html?API_ConfigureHealthCheck.html
|
||||
#
|
||||
# ==== Parameters
|
||||
# * lb_name<~String> - Name of the ELB
|
||||
# * health_check<~Hash> - A hash of parameters describing the health check
|
||||
# * 'HealthyThreshold'<~Integer> - Specifies the number of consecutive
|
||||
# health probe successes required before moving the instance to the Healthy state.
|
||||
# * 'Interval'<~Integer> - Specifies the approximate interval, in seconds,
|
||||
# between health checks of an individual instance.
|
||||
# * 'Target'<~String> - Specifies the instance being checked.
|
||||
# The protocol is either TCP or HTTP. The range of valid ports is one (1) through 65535.
|
||||
# * 'Timeout'<~Integer> - Specifies the amount of time, in seconds,
|
||||
# during which no response means a failed health probe.
|
||||
# * 'UnhealthyThreshold'<~Integer> - Specifies the number of consecutive
|
||||
# health probe failures required before moving the instance to the Unhealthy state.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def configure_health_check(lb_name, health_check)
|
||||
params = {'LoadBalancerName' => lb_name}
|
||||
health_check.each {|key, value| params["HealthCheck.#{key}"] = value }
|
||||
|
||||
request({
|
||||
'Action' => 'ConfigureHealthCheck',
|
||||
:parser => Fog::Parsers::AWS::ELB::ConfigureHealthCheck.new
|
||||
}.merge!(params))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -25,6 +25,16 @@ class AWS
|
|||
'DescribeLoadBalancersResult' => {'LoadBalancerDescriptions' => [LOAD_BALANCER]}
|
||||
})
|
||||
|
||||
CONFIGURE_HEALTH_CHECK = BASIC.merge({
|
||||
'ConfigureHealthCheckResult' => {'HealthCheck' => {
|
||||
'Target' => String,
|
||||
'Interval' => Integer,
|
||||
'Timeout' => Integer,
|
||||
'UnhealthyThreshold' => Integer,
|
||||
'HealthyThreshold' => Integer
|
||||
}}
|
||||
})
|
||||
|
||||
DELETE_LOAD_BALANCER = BASIC.merge({
|
||||
'DeleteLoadBalancerResult' => NilClass
|
||||
})
|
||||
|
|
|
@ -14,6 +14,18 @@ Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do
|
|||
AWS[:elb].describe_load_balancers.body
|
||||
end
|
||||
|
||||
tests("#configure_health_check").formats(AWS::ELB::Formats::CONFIGURE_HEALTH_CHECK) do
|
||||
health_check = {
|
||||
'Target' => 'HTTP:80/index.html',
|
||||
'Interval' => 10,
|
||||
'Timeout' => 5,
|
||||
'UnhealthyThreshold' => 2,
|
||||
'HealthyThreshold' => 3
|
||||
}
|
||||
|
||||
AWS[:elb].configure_health_check(@load_balancer_id, health_check).body
|
||||
end
|
||||
|
||||
tests("#delete_load_balancer").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do
|
||||
AWS[:elb].delete_load_balancer(@load_balancer_id).body
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue