Class: Fog::AWS::ELB::LoadBalancer
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::ELB::LoadBalancer
show all
- Defined in:
- lib/fog/aws/models/elb/load_balancer.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#inspect, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
#initialize(attributes = {}) ⇒ LoadBalancer
Returns a new instance of LoadBalancer.
16
17
18
19
20
21
22
23
24
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 16
def initialize(attributes={})
attributes[:availability_zones] ||= %w(us-east-1a us-east-1b us-east-1c us-east-1d)
attributes['ListenerDescriptions'] ||= [{
'Listener' => {'LoadBalancerPort' => 80, 'InstancePort' => 80, 'Protocol' => 'http'},
'PolicyNames' => []
}]
attributes['Policies'] ||= {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => []}
super
end
|
Instance Method Details
65
66
67
68
69
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 65
def configure_health_check(health_check)
requires :id
data = connection.configure_health_check(id, health_check).body['ConfigureHealthCheckResult']['HealthCheck']
merge_attributes(:health_check => data)
end
|
#deregister_instances(instances) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 33
def deregister_instances(instances)
requires :id
data = connection.deregister_instances_from_load_balancer(instances, id).body['DeregisterInstancesFromLoadBalancerResult']
data['Instances'].map!{|h| h['InstanceId']}
merge_attributes(data)
end
|
#destroy ⇒ Object
122
123
124
125
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 122
def destroy
requires :id
connection.delete_load_balancer(id)
end
|
#disable_availability_zones(zones) ⇒ Object
46
47
48
49
50
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 46
def disable_availability_zones(zones)
requires :id
data = connection.disable_availability_zones_for_load_balancer(zones, id).body['DisableAvailabilityZonesForLoadBalancerResult']
merge_attributes(data)
end
|
#enable_availability_zones(zones) ⇒ Object
40
41
42
43
44
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 40
def enable_availability_zones(zones)
requires :id
data = connection.enable_availability_zones_for_load_balancer(zones, id).body['EnableAvailabilityZonesForLoadBalancerResult']
merge_attributes(data)
end
|
#instance_health ⇒ Object
52
53
54
55
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 52
def instance_health
requires :id
@instance_health ||= connection.describe_instance_health(id).body['DescribeInstanceHealthResult']['InstanceStates']
end
|
#instances_in_service ⇒ Object
57
58
59
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 57
def instances_in_service
instance_health.select{|hash| hash['State'] == 'InService'}.map{|hash| hash['InstanceId']}
end
|
#instances_out_of_service ⇒ Object
61
62
63
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 61
def instances_out_of_service
instance_health.select{|hash| hash['State'] == 'OutOfService'}.map{|hash| hash['InstanceId']}
end
|
#listeners ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 71
def listeners
Fog::AWS::ELB::Listeners.new({
:data => attributes['ListenerDescriptions'],
:connection => connection,
:load_balancer => self
})
end
|
#policies ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 79
def policies
Fog::AWS::ELB::Policies.new({
:data => attributes['Policies'],
:connection => connection,
:load_balancer => self
})
end
|
#ready? ⇒ Boolean
98
99
100
101
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 98
def ready?
true
end
|
#register_instances(instances) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 26
def register_instances(instances)
requires :id
data = connection.register_instances_with_load_balancer(instances, id).body['RegisterInstancesWithLoadBalancerResult']
data['Instances'].map!{|h| h['InstanceId']}
merge_attributes(data)
end
|
#reload ⇒ Object
116
117
118
119
120
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 116
def reload
super
@instance_health = nil
self
end
|
#save ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 103
def save
requires :id
requires :listeners
requires :availability_zones
connection.create_load_balancer(availability_zones, id, listeners.map{|l| l.to_params})
reload
end
|
#set_listener_policy(port, policy_name) ⇒ Object
87
88
89
90
91
92
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 87
def set_listener_policy(port, policy_name)
requires :id
policy_name = [policy_name].flatten
connection.set_load_balancer_policies_of_listener(id, port, policy_name)
reload
end
|
#unset_listener_policy(port) ⇒ Object
94
95
96
|
# File 'lib/fog/aws/models/elb/load_balancer.rb', line 94
def unset_listener_policy(port)
set_listener_policy(port, [])
end
|