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
- #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.
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 121 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 |
#exists? ⇒ Boolean
64 65 66 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 64 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
68 69 70 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 68 def groups FleetGroupCollection.new(self) end |
#resume_all_processes ⇒ Object
Resumes all scaling processes in all Auto Scaling groups in the fleet.
82 83 84 85 86 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 82 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.
74 75 76 77 78 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 74 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
60 61 62 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 60 def template_or_any_group template_group || any_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.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/aws-sdk-autoscaling/fleet.rb', line 99 def update_launch_configuration name, = {} old_lc = template_or_any_group.launch_configuration = 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| group.update(:launch_configuration_name => name) end LaunchConfiguration.new(name: name, client: @client) end |