Class: Fog::AWS::AutoScaling::Group

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/auto_scaling/group.rb

Instance Method Summary collapse

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
40
41
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 26

def initialize(attributes={})
  self.instances = []
  self.default_cooldown = 300
  self.desired_capacity = 0
  self.enabled_metrics = []
  self.health_check_grace_period = 0
  self.health_check_type = 'EC2'
  self.load_balancer_names = []
  self.max_size = 0
  self.min_size = 0
  self.suspended_processes = []
  self.tags = {}
  self.termination_policies = ['Default']
  self.target_group_arns = []
  super
end

Instance Method Details

#activitiesObject



43
44
45
46
47
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 43

def activities
  requires :id

  activities = Fog::AWS::AutoScaling::Activities.new(:service => service, :filters => {'AutoScalingGroupName' => id})
end

#attach_instances(*instance_ids) ⇒ Object



72
73
74
75
76
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 72

def attach_instances(*instance_ids)
  requires :id
  service.attach_instances(id, 'InstanceIds' => instance_ids)
  reload
end

#attach_load_balancer_target_groups(*target_group_arns) ⇒ Object



78
79
80
81
82
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 78

def attach_load_balancer_target_groups(*target_group_arns)
  requires :id
  service.attach_load_balancer_target_groups(id, 'TargetGroupARNs' => target_group_arns)
  reload
end

#attach_load_balancers(*load_balancer_names) ⇒ Object



49
50
51
52
53
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 49

def attach_load_balancers(*load_balancer_names)
  requires :id
  service.attach_load_balancers(id, 'LoadBalancerNames' => load_balancer_names)
  reload
end

#configurationObject



55
56
57
58
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 55

def configuration
  requires :launch_configuration_name
  service.configurations.get(launch_configuration_name)
end

#destroy(options = { :force => false }) ⇒ Object

def reload

super
self

end



158
159
160
161
162
163
164
165
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 158

def destroy(options = { :force => false })
  requires :id

  opts = {}
  opts.merge!({'ForceDelete' => true}) if options[:force]

  service.delete_auto_scaling_group(id, opts)
end

#detach_instances(*instance_ids) ⇒ Object



66
67
68
69
70
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 66

def detach_instances(*instance_ids)
  requires :id
  service.detach_instances(id, 'InstanceIds' => instance_ids)
  reload
end

#detach_load_balancer_target_groups(*target_group_arns) ⇒ Object



84
85
86
87
88
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 84

def detach_load_balancer_target_groups(*target_group_arns)
  requires :id
  service.detach_load_balancer_target_groups(id, 'TargetGroupARNs' => target_group_arns)
  reload
end

#detach_load_balancers(*load_balancer_names) ⇒ Object



60
61
62
63
64
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 60

def detach_load_balancers(*load_balancer_names)
  requires :id
  service.detach_load_balancers(id, 'LoadBalancerNames' => load_balancer_names)
  reload
end

#disable_metrics_collection(metrics = {}) ⇒ Object



90
91
92
93
94
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 90

def disable_metrics_collection(metrics = {})
  requires :id
  service.disable_metrics_collection(id, 'Metrics' => metrics)
  reload
end

#enable_metrics_collection(granularity = '1Minute', metrics = {}) ⇒ Object



96
97
98
99
100
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 96

def enable_metrics_collection(granularity = '1Minute', metrics = {})
  requires :id
  service.enable_metrics_collection(id, granularity, 'Metrics' => metrics)
  reload
end

#filtered_options(method) ⇒ Object



173
174
175
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 173

def filtered_options(method)
  Hash[options.select{|k,_| ExpectedOptions[method].include?(k)}]
end

#instancesObject



112
113
114
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 112

def instances
  Fog::AWS::AutoScaling::Instances.new(:service => service).load(attributes[:instances])
end

#instances_in_serviceObject



116
117
118
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 116

def instances_in_service
  attributes[:instances].select {|hash| hash['LifecycleState'] == 'InService'}.map {|hash| hash['InstanceId']}
end

#instances_out_serviceObject



120
121
122
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 120

def instances_out_service
  attributes[:instances].select {|hash| hash['LifecycleState'] == 'OutOfService'}.map {|hash| hash['InstanceId']}
end

#optionsObject



177
178
179
180
181
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 177

def options
  ret = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
  ret.delete_if { |key, value| value.nil? }
  ret
end

#ready?Boolean

Returns:

  • (Boolean)


136
137
138
139
140
141
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 136

def ready?
  # Is this useful?
  #instances_in_service.length == desired_capacity
  #instances_in_service.length >= min_size
  true
end

#resume_processes(processes = []) ⇒ Object



124
125
126
127
128
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 124

def resume_processes(processes = [])
  requires :id
  service.resume_processes(id, 'ScalingProcesses' => processes)
  reload
end

#saveObject



143
144
145
146
147
148
149
150
151
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 143

def save
  requires :id
  requires :availability_zones
  requires :launch_configuration_name
  requires :max_size
  requires :min_size
  service.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, filtered_options(:create_auto_scaling_group))
  reload
end

#set_instance_protection(instance_ids, protected_from_scale_in) ⇒ Object



102
103
104
105
106
107
108
109
110
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 102

def set_instance_protection(instance_ids, protected_from_scale_in)
  requires :id
  service.set_instance_protection(
    id,
    'InstanceIds' => instance_ids,
    'ProtectedFromScaleIn' => protected_from_scale_in
  )
  reload
end

#suspend_processes(processes = []) ⇒ Object



130
131
132
133
134
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 130

def suspend_processes(processes = [])
  requires :id
  service.suspend_processes(id, 'ScalingProcesses' => processes)
  reload
end

#updateObject



167
168
169
170
171
# File 'lib/fog/aws/models/auto_scaling/group.rb', line 167

def update
  requires :id
  service.update_auto_scaling_group(id, filtered_options(:update_auto_scaling_group) )
  reload
end