opendelivery 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/opendelivery/stack.rb +17 -14
- data/lib/opendelivery/version.rb +1 -1
- metadata +1 -1
data/lib/opendelivery/stack.rb
CHANGED
@@ -3,15 +3,13 @@ require 'aws-sdk'
|
|
3
3
|
module OpenDelivery
|
4
4
|
class Stack
|
5
5
|
|
6
|
-
def initialize(region=nil
|
6
|
+
def initialize(region=nil)
|
7
7
|
if region.nil?
|
8
8
|
@cfn = AWS::CloudFormation.new
|
9
9
|
else
|
10
10
|
@cfn = AWS::CloudFormation.new(:region => region)
|
11
11
|
end
|
12
|
-
|
13
|
-
@sleep_time = sleep_time
|
14
|
-
@silent = silent
|
12
|
+
@domain = OpenDelivery::Domain.new
|
15
13
|
end
|
16
14
|
|
17
15
|
|
@@ -36,11 +34,11 @@ module OpenDelivery
|
|
36
34
|
|
37
35
|
attr_accessor :sleep_time, :silent, :cfm
|
38
36
|
|
39
|
-
def watch
|
37
|
+
def watch(stack_name, sleep_time, silent=false)
|
40
38
|
success = false
|
41
39
|
begin
|
42
40
|
stack = @cfn.stacks[stack_name]
|
43
|
-
success = watch_loop
|
41
|
+
success = watch_loop(stack, sleep_time, silent)
|
44
42
|
rescue AWS::CloudFormation::Errors::ValidationError => msg
|
45
43
|
print_status "Exception raised: #{msg}"
|
46
44
|
success = false
|
@@ -100,7 +98,7 @@ module OpenDelivery
|
|
100
98
|
end
|
101
99
|
end
|
102
100
|
|
103
|
-
def watch_loop
|
101
|
+
def watch_loop(stack, sleep_time, silent)
|
104
102
|
keep_watching = true
|
105
103
|
success = false
|
106
104
|
abort_count = 10
|
@@ -108,29 +106,34 @@ module OpenDelivery
|
|
108
106
|
begin
|
109
107
|
stack_status = stack.status
|
110
108
|
if (SUCCESS_STATUSES.include? stack_status)
|
111
|
-
|
109
|
+
status = "Success: #{stack_status}"
|
110
|
+
print_status(status, silent)
|
112
111
|
success = true
|
113
112
|
keep_watching = false
|
114
113
|
elsif (PROGRESS_STATUSES.include? stack_status)
|
115
|
-
|
114
|
+
status = "In Progress: #{stack_status}"
|
115
|
+
print_status(status, silent)
|
116
116
|
success = false
|
117
117
|
keep_watching = true
|
118
118
|
elsif (FAILURE_STATUSES.include? stack_status)
|
119
|
-
|
119
|
+
status = "Failed: #{stack_status}"
|
120
|
+
print_status(status, silent)
|
120
121
|
success = false
|
121
122
|
keep_watching = false
|
122
123
|
else
|
123
|
-
|
124
|
+
status = "didn't find #{stack_status} in the list of expected statuses"
|
125
|
+
print_status(status, silent)
|
124
126
|
success = false
|
125
127
|
abort_count = abort_count - 1
|
126
128
|
# if we get too many unknown statuses, assume something has gone horribly wrong and quit.
|
127
129
|
keep_watching = (abort_count > 0)
|
128
130
|
end
|
129
131
|
rescue AWS::CloudFormation::Errors::Throttling
|
130
|
-
|
131
|
-
|
132
|
+
status = "Rate limit exceeded, retrying..."
|
133
|
+
print_status(status, silent)
|
134
|
+
sleep (sleep_time * 0.1)
|
132
135
|
end
|
133
|
-
sleep(
|
136
|
+
sleep(sleep_time)
|
134
137
|
end
|
135
138
|
return success
|
136
139
|
end
|
data/lib/opendelivery/version.rb
CHANGED