Class: Aws::AutoScaling::Fleet
- Inherits:
-
Object
- Object
- Aws::AutoScaling::Fleet
- Defined in:
- lib/aws-sdk-autoscaling/fleet.rb
Instance Attribute Summary collapse
- #name ⇒ String readonly
Class Method Summary collapse
-
.options_from(obj, *attributes) ⇒ Object
Collects non-nil, non-empty-array attributes from the supplied object into a Hash.
Instance Method Summary collapse
- #any_group ⇒ Group
- #any_lc_group ⇒ Object
- #exists? ⇒ Boolean
- #group_for_tag(tag) ⇒ Object
- #groups ⇒ Object
-
#initialize(name, options) ⇒ Fleet
constructor
A new instance of Fleet.
-
#resume_all_processes ⇒ Object
Resumes all scaling processes in all Auto Scaling groups in the fleet.
-
#suspend_all_processes ⇒ Object
Suspends all scaling processes in all Auto Scaling groups in the fleet.
- #tag_name ⇒ Object
- #tags(filters = []) ⇒ Object
- #template_group ⇒ Group
- #template_or_any_group ⇒ Object
-
#update_launch_configuration(name, options = {}) ⇒ Object
Creates a new launch configuration and applies it to all the Auto Scaling groups in the fleet.
Constructor Details
#initialize(name, options) ⇒ Fleet
Returns a new instance of Fleet.
4 5 6 7 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 4 def initialize name, @name = name @client = .delete(:client) end |
Instance Attribute Details
#name ⇒ String (readonly)
10 11 12 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 10 def name @name end |
Class Method Details
.options_from(obj, *attributes) ⇒ Object
Collects non-nil, non-empty-array attributes from the supplied object into a Hash. Also converts any Array-like objects into real Arrays.
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 134 def self.(obj, *attributes) opts = {} attributes.each do |key| value = obj.send(key) next if value.blank? if value.is_a? Array value = value.to_a next if value.empty? end opts[key] ||= value end opts end |
Instance Method Details
#any_group ⇒ Group
56 57 58 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 56 def any_group group_for_tag(.first) end |
#any_lc_group ⇒ Object
60 61 62 63 64 65 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 60 def any_lc_group tag_with_lc = .detect { |tag| !group_for_tag(tag).launch_configuration.nil? } return nil if tag_with_lc.nil? group_for_tag(tag_with_lc) end |
#exists? ⇒ Boolean
71 72 73 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 71 def exists? !any_group.nil? end |
#group_for_tag(tag) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 34 def group_for_tag(tag) return nil unless tag case tag.resource_type when 'auto-scaling-group' AutoScalingGroup.new(name: tag.resource_id, client: @client) else msg = "unhandled resource type: #{tag.resource_type}" # shamelessly copied from old aws-sdk raise ArgumentError, msg end end |
#groups ⇒ Object
75 76 77 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 75 def groups FleetGroupCollection.new(self) end |
#resume_all_processes ⇒ Object
Resumes all scaling processes in all Auto Scaling groups in the fleet.
89 90 91 92 93 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 89 def resume_all_processes groups.each do |group| group.resume_processes end end |
#suspend_all_processes ⇒ Object
Suspends all scaling processes in all Auto Scaling groups in the fleet.
81 82 83 84 85 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 81 def suspend_all_processes groups.each do |group| group.suspend_processes end end |
#tag_name ⇒ Object
45 46 47 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 45 def tag_name "asgfleet:#{name}" end |
#tags(filters = []) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 12 def (filters=[]) # mostly copied from Resource#tags = {:filters => [{:name => "key", :values => [tag_name]}] + filters} batches = Enumerator.new do |y| resp = @client.() resp.each_page do |page| batch = [] page.data..each do |t| batch << Tag.new( key: t.key, resource_id: t.resource_id, resource_type: t.resource_type, data: t, client: @client ) end y.yield(batch) end end Tag::Collection.new(batches) end |
#template_group ⇒ Group
50 51 52 53 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 50 def template_group tag = ([{:name => 'value', :values => ["template"]}]).first group_for_tag(tag) end |
#template_or_any_group ⇒ Object
67 68 69 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 67 def template_or_any_group template_group || any_lc_group end |
#update_launch_configuration(name, options = {}) ⇒ Object
Creates a new launch configuration and applies it to all the Auto Scaling groups in the fleet. Any options not specified will be pulled from the Launch Configuration currently attached to the template Auto Scaling group.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 106 def update_launch_configuration name, = {} old_lc = template_or_any_group&.launch_configuration # There aren't any groups using lcs, so skip updating return if old_lc.nil? = Fleet.(old_lc, :image_id, :instance_type, :block_device_mappings, :instance_monitoring, :kernel_id, :key_name, :ramdisk_id, :security_groups, :user_data, :iam_instance_profile, :spot_price).merge() [:launch_configuration_name] = name @client.create_launch_configuration() groups.each do |group| next unless group.launch_template.nil? next unless group.mixed_instances_policy.nil? group.update(:launch_configuration_name => name) end LaunchConfiguration.new(name: name, client: @client) end |