opendelivery 0.0.9 → 0.0.10
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/lib/opendelivery/stack.rb +56 -55
- metadata +1 -1
data/lib/opendelivery/stack.rb
CHANGED
@@ -66,76 +66,77 @@ module OpenDelivery
|
|
66
66
|
def destroy(stack_name, domain=nil, wait=false)
|
67
67
|
stack = @cfn.stacks[stack_name]
|
68
68
|
unless stack.exists? raise "Stack: #{stack_name} doesn't exist, therefore it cannot be destroyed"
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
stack.delete
|
70
|
+
while wait and stack.exists?
|
71
|
+
sleep 20
|
72
|
+
end
|
73
|
+
@domain.destroy_item(domain, stack_name)
|
72
74
|
end
|
73
|
-
@domain.destroy_item(domain, stack_name)
|
74
|
-
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
def list
|
77
|
+
@cfn.stacks.each do |stack|
|
78
|
+
puts "Stack Name: #{stack.name} | Status: #{stack.status}"
|
79
|
+
end
|
79
80
|
end
|
80
|
-
end
|
81
81
|
|
82
|
-
|
82
|
+
private
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
def wait_for_stack(stack)
|
85
|
+
while stack.status != "CREATE_COMPLETE"
|
86
|
+
sleep 20
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
if FAILURE_STATUSES.include? stack.status
|
89
|
+
stack.delete
|
90
|
+
end
|
90
91
|
end
|
91
92
|
end
|
92
|
-
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
def print_status(status, silent)
|
95
|
+
timestamp = Time.now.strftime("%Y.%m.%d %H:%M:%S:%L")
|
96
|
+
unless silent
|
97
|
+
puts "#{timestamp}: #{status}"
|
98
|
+
end
|
98
99
|
end
|
99
|
-
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
101
|
+
def watch_loop(stack, sleep_time, silent)
|
102
|
+
keep_watching = true
|
103
|
+
success = false
|
104
|
+
abort_count = 10
|
105
|
+
while(keep_watching) do
|
106
|
+
begin
|
107
|
+
stack_status = stack.status
|
108
|
+
if (SUCCESS_STATUSES.include? stack_status)
|
109
|
+
status = "Success: #{stack_status}"
|
110
|
+
print_status(status, silent)
|
111
|
+
success = true
|
112
|
+
keep_watching = false
|
113
|
+
elsif (PROGRESS_STATUSES.include? stack_status)
|
114
|
+
status = "In Progress: #{stack_status}"
|
115
|
+
print_status(status, silent)
|
116
|
+
success = false
|
117
|
+
keep_watching = true
|
118
|
+
elsif (FAILURE_STATUSES.include? stack_status)
|
119
|
+
status = "Failed: #{stack_status}"
|
120
|
+
print_status(status, silent)
|
121
|
+
success = false
|
122
|
+
keep_watching = false
|
123
|
+
else
|
124
|
+
status = "didn't find #{stack_status} in the list of expected statuses"
|
125
|
+
print_status(status, silent)
|
126
|
+
success = false
|
127
|
+
abort_count = abort_count - 1
|
128
|
+
# if we get too many unknown statuses, assume something has gone horribly wrong and quit.
|
129
|
+
keep_watching = (abort_count > 0)
|
130
|
+
end
|
131
|
+
rescue AWS::CloudFormation::Errors::Throttling
|
132
|
+
status = "Rate limit exceeded, retrying..."
|
125
133
|
print_status(status, silent)
|
126
|
-
|
127
|
-
abort_count = abort_count - 1
|
128
|
-
# if we get too many unknown statuses, assume something has gone horribly wrong and quit.
|
129
|
-
keep_watching = (abort_count > 0)
|
134
|
+
sleep (sleep_time * 0.1)
|
130
135
|
end
|
131
|
-
|
132
|
-
status = "Rate limit exceeded, retrying..."
|
133
|
-
print_status(status, silent)
|
134
|
-
sleep (sleep_time * 0.1)
|
136
|
+
sleep(sleep_time)
|
135
137
|
end
|
136
|
-
|
138
|
+
return success
|
137
139
|
end
|
138
|
-
return success
|
139
140
|
end
|
140
141
|
end
|
141
142
|
end
|