cloudformation-tool 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e5abc1e4e61d28dd02bbfd5afbe35227264c85180f3c142f45bc3d310f5502c
|
4
|
+
data.tar.gz: 0cd6c58286dc243b41e5589ad979b26ccacbbaf4e7935e48ebc6ca86aaeba58d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de747553ac8b014e644a02c5762b7b2e0f45f967d43b1e215a338d88fe56a9afb336852f3c2070202d471a8fae55e3651e37422878bed79b136108b3ae37dd0b
|
7
|
+
data.tar.gz: ad25012520b89d6374f804f0083e74a34b25c5603ebdcedec50ba9f5bb9c174e0a63ac8de784dae6d219b098db162e49ba99d5ba76ad6e5309efbca8ec069dc7
|
@@ -35,6 +35,7 @@ module CloudFormationTool
|
|
35
35
|
subcommand 'status', "Check the current status of a stack", Status
|
36
36
|
subcommand 'delete', "Delete an existing stack", Delete
|
37
37
|
subcommand 'servers', 'List stack resources', Servers
|
38
|
+
subcommand 'recycle', 'Recycle servers in an auto scaling group', Recycle
|
38
39
|
subcommand 'output', 'Retrieve output values from the stack', Output
|
39
40
|
end
|
40
41
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module CloudFormationTool
|
4
|
+
module CLI
|
5
|
+
|
6
|
+
class Recycle < Clamp::Command
|
7
|
+
include CloudFormationTool
|
8
|
+
|
9
|
+
parameter "STACK_NAME", "Name of the stack to recycle servers in"
|
10
|
+
parameter "ASG_NAME", "Name of the auto scaling group in which to recycle all servers"
|
11
|
+
|
12
|
+
def execute
|
13
|
+
st = CloudFormation::Stack.new(stack_name)
|
14
|
+
st.asgroups.select do |res|
|
15
|
+
asg_name.nil? or (res.logical_resource_id == asg_name)
|
16
|
+
end.collect do |res|
|
17
|
+
Thread.new do
|
18
|
+
grp = res.group
|
19
|
+
torecycle = cursize = grp.instances.size
|
20
|
+
puts "#{grp.name}: Recyclying #{cursize} instance" + (cursize > 1 ? "s" : "")
|
21
|
+
while torecycle > 0
|
22
|
+
grp.set_desired_capacity(desired_capacity: (cursize + 1))
|
23
|
+
while grp.instances.size != (cursize + 1)
|
24
|
+
sleep 5
|
25
|
+
grp.reload
|
26
|
+
end
|
27
|
+
grp.set_desired_capacity(desired_capacity: cursize)
|
28
|
+
while grp.instances.size != cursize
|
29
|
+
sleep 5
|
30
|
+
grp.reload
|
31
|
+
end
|
32
|
+
torecycle -= 1
|
33
|
+
puts "#{grp.name}: Left to recycle - #{torecycle}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end.each(&:join)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -101,6 +101,14 @@ module CloudFormationTool
|
|
101
101
|
def asgroups
|
102
102
|
resources.select do |res|
|
103
103
|
res.resource_type == 'AWS::AutoScaling::AutoScalingGroup'
|
104
|
+
end.collect do |res|
|
105
|
+
res.extend(CloudFormationTool)
|
106
|
+
res.instance_eval do
|
107
|
+
def group
|
108
|
+
Aws::AutoScaling::AutoScalingGroup.new(self.physical_resource_id, client: awsas).reload
|
109
|
+
end
|
110
|
+
end
|
111
|
+
res
|
104
112
|
end
|
105
113
|
end
|
106
114
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudformation-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Arbel
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/cloud_formation_tool/cli/monitor.rb
|
89
89
|
- lib/cloud_formation_tool/cli/output.rb
|
90
90
|
- lib/cloud_formation_tool/cli/parameters.rb
|
91
|
+
- lib/cloud_formation_tool/cli/recycle.rb
|
91
92
|
- lib/cloud_formation_tool/cli/servers.rb
|
92
93
|
- lib/cloud_formation_tool/cli/status.rb
|
93
94
|
- lib/cloud_formation_tool/cloud_formation.rb
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.7.2
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: A pre-compiler tool for CloudFormation YAML templates
|