panoramix 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/panoramix/plugin/cfn.rb +15 -8
- data/lib/panoramix/tasks/actions.rb +1 -0
- metadata +1 -1
data/lib/panoramix/plugin/cfn.rb
CHANGED
@@ -28,13 +28,18 @@ module Panoramix
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Final Cloud Formation stack name
|
31
|
-
def
|
31
|
+
def gen_stack_name
|
32
32
|
@version ? "#{@stage}-#{@dst}-#{@version}-#{owner}" : "#{@stage}-#{@dst}-#{owner}"
|
33
33
|
end
|
34
34
|
|
35
|
+
# Return stack name
|
36
|
+
def stack_name
|
37
|
+
puts gen_stack_name
|
38
|
+
end
|
39
|
+
|
35
40
|
def ask_pro
|
36
41
|
choose do |menu|
|
37
|
-
menu.prompt = "Would you like to delete the stack #{
|
42
|
+
menu.prompt = "Would you like to delete the stack #{gen_stack_name}? "
|
38
43
|
|
39
44
|
menu.choice(:No) do
|
40
45
|
say("Don't do it again!")
|
@@ -78,8 +83,8 @@ module Panoramix
|
|
78
83
|
parsed_stacks = JSON.parse query
|
79
84
|
|
80
85
|
# Check wether the stacks has already been created
|
81
|
-
info = parsed_stacks.select { |s| s["StackName"] ==
|
82
|
-
@created = info.empty? ? nil: info
|
86
|
+
info = parsed_stacks.select { |s| s["StackName"] == gen_stack_name }
|
87
|
+
@created = info.empty? ? nil: info.first
|
83
88
|
end
|
84
89
|
|
85
90
|
# Action delete for this task
|
@@ -88,7 +93,7 @@ module Panoramix
|
|
88
93
|
return unless question
|
89
94
|
|
90
95
|
cmd = "aws cloudformation delete-stack \
|
91
|
-
--stack-name #{
|
96
|
+
--stack-name #{gen_stack_name}"
|
92
97
|
|
93
98
|
shell(cmd)
|
94
99
|
# Wait until the stack is being deleted
|
@@ -122,6 +127,7 @@ module Panoramix
|
|
122
127
|
def wait_for_creation stack_id
|
123
128
|
loop do
|
124
129
|
status = shell("aws cloudformation describe-stacks --stack #{stack_id} --query Stacks[0].StackStatus --output text", true)[:out].strip
|
130
|
+
raise "Creation Failed" if status == "CREATE_FAILED"
|
125
131
|
break if status != "CREATE_IN_PROGRESS"
|
126
132
|
sleep 30
|
127
133
|
end
|
@@ -139,7 +145,8 @@ module Panoramix
|
|
139
145
|
# Deafult task
|
140
146
|
def run_default
|
141
147
|
if created?
|
142
|
-
|
148
|
+
puts "WARNING: #{gen_stack_name} already exists!".red
|
149
|
+
return
|
143
150
|
end
|
144
151
|
env = fill_env @src
|
145
152
|
|
@@ -151,7 +158,7 @@ module Panoramix
|
|
151
158
|
|
152
159
|
cmd = "aws cloudformation create-stack \
|
153
160
|
--query StackId \
|
154
|
-
--stack-name #{
|
161
|
+
--stack-name #{gen_stack_name} \
|
155
162
|
--template-body #{template} \
|
156
163
|
--disable-rollback \
|
157
164
|
--parameters #{params}"
|
@@ -164,7 +171,7 @@ module Panoramix
|
|
164
171
|
|
165
172
|
def ps
|
166
173
|
if created?
|
167
|
-
shell("aws cloudformation describe-stacks --stack-name #{
|
174
|
+
shell("aws cloudformation describe-stacks --stack-name #{gen_stack_name}")
|
168
175
|
end
|
169
176
|
end
|
170
177
|
end
|
@@ -22,6 +22,7 @@ module Panoramix
|
|
22
22
|
|
23
23
|
Actions = Array.new
|
24
24
|
Actions.push(Action.new("delete", false, [Plugin::CloudFormation]))
|
25
|
+
Actions.push(Action.new("stack_name", false, [Plugin::CloudFormation]))
|
25
26
|
Actions.push(Action.new("ps", false, [Plugin::DockerUp, Plugin::CloudFormation, Plugin::Environment]))
|
26
27
|
Actions.push(Action.new("rm", false, [Plugin::DockerUp]))
|
27
28
|
Actions.push(Action.new("vars", false, [Plugin::Environment]))
|