Class: Fog::AWS::AutoScaling::Group
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::AutoScaling::Group
show all
- Defined in:
- lib/fog/aws/models/auto_scaling/group.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Group
Returns a new instance of Group.
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 26
def initialize(attributes={})
attributes['DefaultCooldown'] ||= 0
attributes['DesiredCapacity'] ||= 0
attributes['EnabledMetrics'] ||= []
attributes['HealthCheckGracePeriod'] ||= 0
attributes['HealthCheckType'] ||= 'EC2'
attributes['Instances'] ||= []
attributes['LoadBalancerNames'] ||= []
attributes['MaxSize'] ||= 0
attributes['MinSize'] ||= 0
attributes['SuspendedProcesses'] ||= []
attributes['Tags'] ||= []
super
end
|
Instance Method Details
#activities ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 41
def activities
requires :id
data = []
next_token = nil
loop do
result = connection.describe_scaling_activities('AutoScalingGroupName' => id, 'NextToken' => next_token).body['DescribeScalingActivitiesResult']
data += result['Activities']
next_token = result['NextToken']
break if next_token.nil?
end
Fog::AWS::AutoScaling::Activities.new({
:data => data,
:connection => connection,
})
end
|
#configuration ⇒ Object
58
59
60
61
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 58
def configuration
requires :launch_configuration_name
connection.configurations.get(launch_configuration_name)
end
|
#destroy ⇒ Object
def reload
super
self
end
122
123
124
125
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 122
def destroy
requires :id
connection.delete_auto_scaling_group(id)
end
|
#disable_metrics_collection(metrics = {}) ⇒ Object
63
64
65
66
67
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 63
def disable_metrics_collection(metrics = {})
requires :id
connection.disable_metrics_collection(id, 'Metrics' => metrics)
reload
end
|
#enable_metrics_collection(granularity = '1Minute', metrics = {}) ⇒ Object
69
70
71
72
73
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 69
def enable_metrics_collection(granularity = '1Minute', metrics = {})
requires :id
connection.enable_metrics_collection(id, granularity, 'Metrics' => metrics)
reload
end
|
#instances ⇒ Object
75
76
77
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 75
def instances
Fog::AWS::AutoScaling::Instances.new(:connection => connection).load(attributes[:instances])
end
|
#instances_in_service ⇒ Object
79
80
81
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 79
def instances_in_service
attributes[:instances].select {|hash| hash['LifecycleState'] == 'InService'}.map {|hash| hash['InstanceId']}
end
|
#instances_out_service ⇒ Object
83
84
85
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 83
def instances_out_service
attributes[:instances].select {|hash| hash['LifecycleState'] == 'OutOfService'}.map {|hash| hash['InstanceId']}
end
|
#options ⇒ Object
133
134
135
136
137
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 133
def options
ret = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
ret.delete_if { |key, value| value.nil? }
ret
end
|
#ready? ⇒ Boolean
99
100
101
102
103
104
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 99
def ready?
true
end
|
#resume_processes(processes = []) ⇒ Object
87
88
89
90
91
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 87
def resume_processes(processes = [])
requires :id
connection.resume_processes(id, 'ScalingProcesses' => processes)
reload
end
|
#save ⇒ Object
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 106
def save
requires :id
requires :availability_zones
requires :launch_configuration_name
requires :max_size
requires :min_size
connection.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, options)
reload
end
|
#suspend_processes(processes = []) ⇒ Object
93
94
95
96
97
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 93
def suspend_processes(processes = [])
requires :id
connection.suspend_processes(id, 'ScalingProcesses' => processes)
reload
end
|
#update ⇒ Object
127
128
129
130
131
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 127
def update
requires :id
connection.update_auto_scaling_group(id, options)
reload
end
|