Permalink
Browse files

Merge remote branch 'ktheory/aws_elb_requests'

  • Loading branch information...
geemus committed Apr 12, 2011
2 parents 2898848 + 082adf8 commit a0377c1952a6fd4e4f7195e9874bc64d9fc628ad
View
@@ -6,14 +6,22 @@ class ELB < Fog::Service
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
@@ -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
@@ -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 @@ module Formats
'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 @@
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

0 comments on commit a0377c1

Please sign in to comment.