zergrush_cf 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODdlMmM0ODNkOTU5ZTE5MTNiMTBmZGM2Y2JiYzhjM2VkYTM2ZWM4OA==
4
+ ZTM1NGM0NDdlZjljZmViOTcyOTI3YjJkMTg0OTIyMzViYTVlYjhiOA==
5
5
  data.tar.gz: !binary |-
6
- YjgwMWRlNDg0YmY2M2MxNzkzNDU5YzNlOWU3ZGU0MjUwZjc3MGQyNA==
6
+ Zjg3ZmIyODgxYzUyOTgzNmNjZDJkOGIyYWU5MTQ0OGJlYTJjMTI1NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGRmNjhlYzUyYTUwOWJkYjUxY2RjZTFhY2RlMjFjZmFlZTA0NDVkYzg1YWVl
10
- NDJhYTQ0ZTQxODM4MjE3NWY4ODc2NzZhYWVmN2Q1NjA5ZTUxZGQzNjM2NzU5
11
- MjM1YWVkNTI4MDZlZmJkNWU2ZmM4NzAzMzljNmNlYjdmOWNmMjE=
9
+ NzJiODUyYmI5YWZhZDFmM2FjYjdlODkyZDYzZGFkOGI4YzVmMTEyY2M0ZDkx
10
+ MTU2ZjliMGExYmZhZDgwZTgwOWIzZDhiZDYzOGI2ZmZjNWVlZThmN2QwMjNk
11
+ N2UyZTZmNjQ4OGQ0NzA1MTQwODcwNTA3OTRhYTkxODAzODBkZTE=
12
12
  data.tar.gz: !binary |-
13
- MzVjY2FlNDk1N2I1NDllZTFjY2M5MmFjYjc4MTUzMjdiMDVjNWQ2ZGVhM2E0
14
- ZjRkYmRiODBiYTQ0MGI3ZDNjZTk4ZWI1M2EzNmExMTRkMjI1MjVjYTJjOGZj
15
- MTFhMTg2Mjg3MGE1MjNmODU0YTg1ZTZiOTUzMzAwOWJlOTBjMTc=
13
+ ZDc1MzY5NzI1YmQ2ZmU2OTIzMWJjYzQ2MzMwZDExZjg3YjQ3MjJkYWJjYWYz
14
+ YzJhNWYwOTkyYzkyZmIyNjcyODlmMzRhMjI0MDU1MDYxYWY4Y2ZlNzExZGIz
15
+ MTk2Yjg4ZDE5MDNkYzA0OTJiMTQyZDQ0Nzc4OTIxOGMzZWI1YTU=
@@ -27,7 +27,6 @@ require 'excon'
27
27
  require 'rbconfig'
28
28
  require 'awesome_print'
29
29
  require 'securerandom'
30
- require 'ruby-progressbar'
31
30
  require_relative 'renderer'
32
31
 
33
32
  class CloudFormation < ZergGemPlugin::Plugin "/driver"
@@ -90,32 +89,45 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
90
89
  # create the cloudformation stack
91
90
  stack_name = "#{task_name}"
92
91
 
93
- progressbar = nil
94
92
  params = eval_params(task_hash["vm"]["driver"]["driveroptions"][0]["template_parameters"])
95
93
  stack_info = cf.create_stack(stack_name, { 'DisableRollback' => true, 'TemplateBody' => template_body.to_json, 'Parameters' => params, 'Capabilities' => [ "CAPABILITY_IAM" ] })
96
94
 
97
95
  # grab the id of the stack
98
96
  stack_id = stack_info.body["StackId"]
99
- puts("Creating stack #{stack_name} with id #{stack_id}\n-----------------------------")
100
- progressbar = ProgressBar.create(:starting_at => 20, :total => nil)
97
+ puts("Creating stack #{stack_name} with id #{stack_id}")
101
98
 
102
- # get stack outputs
99
+
100
+ # get the event collection and initial info
103
101
  outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
102
+ while outputs_info == nil do
103
+ sleep 1
104
+ outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
105
+ end
104
106
 
105
- until outputs_info.body["Stacks"][0]["StackStatus"] != "CREATE_IN_PROGRESS" do
106
- progressbar.increment
107
- sleep 2
107
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
108
+ while events == nil do
109
+ sleep 1
110
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
111
+ end
108
112
 
113
+ event_counter = 0
114
+ while outputs_info.body["Stacks"][0]["StackStatus"] == "CREATE_IN_PROGRESS" do
115
+ logEvents(events.first(events.length - event_counter))
116
+ event_counter = events.length
117
+
118
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
109
119
  outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
120
+ if outputs_info.body["Stacks"][0]["StackStatus"] == "CREATE_COMPLETE"
121
+ logEvents(events.first(events.length - event_counter))
122
+ puts("Stack outputs:")
123
+ ap outputs_info.body["Stacks"][0]["Outputs"]
124
+ return 0
125
+ end
110
126
  end
111
- progressbar.stop
112
- abort "ERROR: Stack #{stack_name} creation failed. Refer to AWS CloudFormation console for further info." unless outputs_info.body["Stacks"][0]["StackStatus"] == "CREATE_COMPLETE"
113
-
114
- puts("SUCCESS! Stack outputs:")
115
- ap outputs_info.body["Stacks"][0]["Outputs"]
116
127
 
128
+ abort("ERROR: Failed with stack status: #{outputs_info.body["Stacks"][0]["StackStatus"]}")
129
+
117
130
  rescue Fog::Errors::Error => fog_cf_error
118
- progressbar.stop unless progressbar == nil
119
131
  abort ("ERROR: AWS error: #{fog_cf_error.message}")
120
132
  end
121
133
 
@@ -146,33 +158,60 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
146
158
  :aws_secret_access_key => aws_secret
147
159
  )
148
160
 
149
- progressbar = nil
150
-
151
161
  stack_info = cf.delete_stack(stack_name)
152
162
  puts("Deleting stack #{stack_name}")
153
- progressbar = ProgressBar.create(:starting_at => 20, :total => nil)
154
- outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
155
163
 
156
- while outputs_info.body["Stacks"][0]["StackStatus"] == "DELETE_IN_PROGRESS" do
157
- progressbar.increment
158
- sleep 2
164
+ # get the event collection and initial info
165
+ outputs_info = nil
166
+ while outputs_info == nil do
167
+ sleep 1
168
+ begin
169
+ outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
170
+ rescue Fog::AWS::CloudFormation::NotFound
171
+ return 0
172
+ end
173
+ end
174
+
175
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
176
+ while events == nil do
177
+ sleep 1
178
+ begin
179
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
180
+ rescue Fog::AWS::CloudFormation::NotFound
181
+ return 0
182
+ end
183
+ end
159
184
 
185
+ event_counter = 0
186
+ while outputs_info.body["Stacks"][0]["StackStatus"] == "DELETE_IN_PROGRESS" do
187
+ logEvents(events.first(events.length - event_counter))
188
+ event_counter = events.length
160
189
  begin
190
+ events = cf.describe_stack_events(stack_name).body['StackEvents']
161
191
  outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
162
192
  rescue Fog::AWS::CloudFormation::NotFound
163
- progressbar.stop
164
- break
193
+ logEvents(events.first(events.length - event_counter))
194
+ return 0
165
195
  end
166
196
  end
167
197
 
168
- rescue Fog::AWS::CloudFormation::NotFound
169
- progressbar.stop unless progressbar == nil
170
- abort ("ERROR: Stack #{stack_name} was not found in AWS.")
198
+ abort("ERROR: Failed with stack status: #{outputs_info.body["Stacks"][0]["StackStatus"]}")
199
+
171
200
  rescue Fog::Errors::Error => fog_cf_error
172
- progressbar.stop unless progressbar == nil
173
201
  abort ("ERROR: AWS error: #{fog_cf_error.ai}")
174
202
  end
175
203
 
204
+ def logEvents events
205
+ events.each do |event|
206
+ puts "Timestamp: #{event['Timestamp']}"
207
+ puts "LogicalResourceId: #{event['LogicalResourceId']}"
208
+ puts "ResourceType: #{event['ResourceType']}"
209
+ puts "ResourceStatus: #{event['ResourceStatus']}"
210
+ puts "ResourceStatusReason: #{event['ResourceStatusReason']}" if event['ResourceStatusReason']
211
+ puts "--"
212
+ end
213
+ end
214
+
176
215
  def halt hive_location, task_name, task_hash, debug
177
216
  puts("Halt is not implemented for CloudFormation.")
178
217
  return
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module ZergrushCF
25
- VERSION = "0.0.4"
25
+ VERSION = "0.0.5"
26
26
  end
data/zergrush_cf.gemspec CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency "zergrush", ">= 0.0.11"
21
21
 
22
22
  s.add_dependency "fog", ">=1.20.0"
23
- s.add_dependency "ruby-progressbar", "1.4.2"
24
23
 
25
24
  s.files = `git ls-files`.split("\n")
26
25
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zergrush_cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MTN Satellite Communications
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.20.0
69
- - !ruby/object:Gem::Dependency
70
- name: ruby-progressbar
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 1.4.2
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 1.4.2
83
69
  description: Amazon Cloud Formation driver for zergrush
84
70
  email:
85
71
  - Marat.Garafutdinov@mtnsat.com