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.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 27
def initialize(attributes={})
attributes['DefaultCooldown'] ||= 300
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'] ||= []
attributes['TerminationPolicies'] ||= ['Default']
super
end
|
Instance Method Details
#activities ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 43
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
60
61
62
63
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 60
def configuration
requires :launch_configuration_name
connection.configurations.get(launch_configuration_name)
end
|
#destroy(options = { :force => false }) ⇒ Object
def reload
super
self
end
124
125
126
127
128
129
130
131
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 124
def destroy(options = { :force => false })
requires :id
opts = {}
opts.merge!({'ForceDelete' => true}) if options[:force]
connection.delete_auto_scaling_group(id, opts)
end
|
#disable_metrics_collection(metrics = {}) ⇒ Object
65
66
67
68
69
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 65
def disable_metrics_collection(metrics = {})
requires :id
connection.disable_metrics_collection(id, 'Metrics' => metrics)
reload
end
|
#enable_metrics_collection(granularity = '1Minute', metrics = {}) ⇒ Object
71
72
73
74
75
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 71
def enable_metrics_collection(granularity = '1Minute', metrics = {})
requires :id
connection.enable_metrics_collection(id, granularity, 'Metrics' => metrics)
reload
end
|
#instances ⇒ Object
77
78
79
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 77
def instances
Fog::AWS::AutoScaling::Instances.new(:connection => connection).load(attributes[:instances])
end
|
#instances_in_service ⇒ Object
81
82
83
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 81
def instances_in_service
attributes[:instances].select {|hash| hash['LifecycleState'] == 'InService'}.map {|hash| hash['InstanceId']}
end
|
#instances_out_service ⇒ Object
85
86
87
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 85
def instances_out_service
attributes[:instances].select {|hash| hash['LifecycleState'] == 'OutOfService'}.map {|hash| hash['InstanceId']}
end
|
#options ⇒ Object
139
140
141
142
143
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 139
def options
ret = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
ret.delete_if { |key, value| value.nil? }
ret
end
|
#ready? ⇒ Boolean
101
102
103
104
105
106
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 101
def ready?
true
end
|
#resume_processes(processes = []) ⇒ Object
89
90
91
92
93
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 89
def resume_processes(processes = [])
requires :id
connection.resume_processes(id, 'ScalingProcesses' => processes)
reload
end
|
#save ⇒ Object
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 108
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
95
96
97
98
99
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 95
def suspend_processes(processes = [])
requires :id
connection.suspend_processes(id, 'ScalingProcesses' => processes)
reload
end
|
#update ⇒ Object
133
134
135
136
137
|
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 133
def update
requires :id
connection.update_auto_scaling_group(id, options)
reload
end
|