aws-asg-fleet 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/asg-fleet.gemspec +1 -1
- data/lib/aws/auto_scaling/fleet.rb +22 -7
- data/lib/aws/auto_scaling/fleet_group_collection.rb +8 -14
- metadata +2 -2
data/asg-fleet.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "aws-asg-fleet"
|
8
|
-
spec.version = "0.0.
|
8
|
+
spec.version = "0.0.2"
|
9
9
|
spec.authors = ["Zach Wily"]
|
10
10
|
spec.email = ["zach@zwily.com"]
|
11
11
|
spec.description = %q{AWS Auto Scaling Fleets}
|
@@ -59,16 +59,13 @@ module AWS
|
|
59
59
|
old_lc = template_group.launch_configuration
|
60
60
|
image_id = options[:image_id] || old_lc.image_id
|
61
61
|
instance_type = options[:instance_type] || old_lc.instance_type
|
62
|
-
|
62
|
+
|
63
|
+
options = Fleet.options_from(old_lc,
|
64
|
+
:block_device_mappings, :detailed_instance_monitoring, :kernel_id,
|
63
65
|
:key_pair, :ramdisk_id, :security_groups, :user_data,
|
64
|
-
:iam_instance_profile, :spot_price
|
65
|
-
existing_value = old_lc.send(k)
|
66
|
-
next if existing_value == nil || existing_value == []
|
67
|
-
options[k] ||= existing_value
|
68
|
-
end
|
66
|
+
:iam_instance_profile, :spot_price).merge(options)
|
69
67
|
|
70
68
|
launch_configurations = LaunchConfigurationCollection.new(:config => config)
|
71
|
-
puts options
|
72
69
|
new_lc = launch_configurations.create(name, image_id, instance_type, options)
|
73
70
|
|
74
71
|
groups.each do |group|
|
@@ -78,6 +75,24 @@ module AWS
|
|
78
75
|
new_lc
|
79
76
|
end
|
80
77
|
|
78
|
+
# @private
|
79
|
+
# Collects non-nil, non-empty-array attributes from the supplied object
|
80
|
+
# into a Hash. Also converts any Array-like objects into real
|
81
|
+
# Arrays.
|
82
|
+
def self.options_from(obj, *attributes)
|
83
|
+
opts = {}
|
84
|
+
attributes.each do |key|
|
85
|
+
value = obj.send(key)
|
86
|
+
next if value.nil?
|
87
|
+
if value.is_a? Array
|
88
|
+
value = value.to_a
|
89
|
+
next if value.empty?
|
90
|
+
end
|
91
|
+
opts[key] ||= value
|
92
|
+
end
|
93
|
+
opts
|
94
|
+
end
|
95
|
+
|
81
96
|
protected
|
82
97
|
|
83
98
|
def resource_identifiers
|
@@ -39,7 +39,7 @@ module AWS
|
|
39
39
|
## Clone the group
|
40
40
|
template_group = @fleet.template_group
|
41
41
|
|
42
|
-
options = options_from(template_group,
|
42
|
+
options = Fleet.options_from(template_group,
|
43
43
|
:load_balancers, :min_size, :max_size, :launch_configuration,
|
44
44
|
:availability_zones, :default_cooldown, :desired_capacity,
|
45
45
|
:health_check_grace_period, :health_check_type, :placement_group,
|
@@ -70,10 +70,15 @@ module AWS
|
|
70
70
|
|
71
71
|
group = GroupCollection.new(:config => config).create name, options
|
72
72
|
|
73
|
+
# Match metric collection with the template
|
74
|
+
# (If this call ever supports specifying a granularity of other than
|
75
|
+
# '1Minute', this will need to change.)
|
76
|
+
group.enable_metrics_collection(template_group.enabled_metrics.keys)
|
77
|
+
|
73
78
|
## Clone the scaling policies and alarms from the group
|
74
79
|
cloudwatch = AWS::CloudWatch.new(:config => config)
|
75
80
|
template_group.scaling_policies.each do |template_policy|
|
76
|
-
policy_options = options_from(template_policy,
|
81
|
+
policy_options = Fleet.options_from(template_policy,
|
77
82
|
:adjustment_type, :scaling_adjustment, :cooldown, :min_adjustment_step)
|
78
83
|
|
79
84
|
policy = group.scaling_policies.create template_policy.name, policy_options
|
@@ -81,7 +86,7 @@ module AWS
|
|
81
86
|
template_policy.alarms.keys.each do |template_alarm_name|
|
82
87
|
template_alarm = cloudwatch.alarms[template_alarm_name]
|
83
88
|
alarm_name = "#{template_alarm.name}-#{group.name}"
|
84
|
-
alarm_options = options_from(template_alarm,
|
89
|
+
alarm_options = Fleet.options_from(template_alarm,
|
85
90
|
:namespace, :metric_name, :comparison_operator, :evaluation_periods,
|
86
91
|
:period, :statistic, :threshold, :actions_enabled, :alarm_description,
|
87
92
|
:unit)
|
@@ -129,17 +134,6 @@ module AWS
|
|
129
134
|
yield tag.resource
|
130
135
|
end
|
131
136
|
end
|
132
|
-
|
133
|
-
def options_from(obj, *attributes)
|
134
|
-
opts = {}
|
135
|
-
attributes.each do |key|
|
136
|
-
value = obj.send(key)
|
137
|
-
next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
138
|
-
value = value.to_a if value.is_a? Array
|
139
|
-
opts[key] ||= value
|
140
|
-
end
|
141
|
-
opts
|
142
|
-
end
|
143
137
|
end
|
144
138
|
end
|
145
139
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-asg-fleet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|