zergrush_cf 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +36 -0
- data/lib/zergrush_cf/init.rb +52 -1
- data/lib/zergrush_cf/version.rb +1 -1
- data/resources/option_schema.template +59 -0
- data/zergrush_cf.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmMyNjgxOTNmNzkwNjVlYzFmYmU5OTU3YTU0MzYwNDFhMjJlMjRjZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWJkNmJjZDg4NTNiZTQ5ZTZhM2QxNzgzODc2MzdmMjk0YjJlMTk4ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGQ2YzJmYThhZjc5YjRmMTlkZDg1M2QzZmUzNTU3OWE1OTI4Njg0ZTFjNWUy
|
10
|
+
MzQ2MThiNDRjN2Q2OTc2OGQzNTNmZmJhNGVmYWQ4ZjZiY2YxZmJhMzdmMGE3
|
11
|
+
MDRhZGE1ODBjMjg4MTdlZjQxNTIyMjI2NjRiOWEzZDMyNTNlNGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjNiZjYwNWI4ZDYzMGQxYmQwZTRiNTBlZGQzOGUwMTlmNzA4OWUxNzdjNWY3
|
14
|
+
ZjYxOGU5OTAxYTI5NmZkYjdhYTk3OWUzZjYwNzRhMDA4N2FhYzE5OWVjMDQ2
|
15
|
+
Y2FmZWFiM2E0OGRjNWEyMGU2ZGNlOWI2MDAxYmU1NWI1ZTczZDk=
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Additional properties defined
|
|
16
16
|
- template - body of a AWS CloudFormation template (use this OR template_file)
|
17
17
|
- template_file - file containing the CloudFormation template. Path is relative to location of .ke task file in .hive (use this OR template)
|
18
18
|
- template_parameters - parameter values for the cloudformation template
|
19
|
+
- rabbit - optional information on a rabbitmq server to publish event log to
|
20
|
+
- storage - optional information on an S3 bucket to upload files from "additional_files_section" of zerg to.
|
19
21
|
|
20
22
|
Example use:
|
21
23
|
```
|
@@ -33,6 +35,40 @@ Example use:
|
|
33
35
|
"template_parameters": {
|
34
36
|
"Param1": "value",
|
35
37
|
"Param2": "ENV['SOME_VARIABLE']"
|
38
|
+
},
|
39
|
+
"rabbit": {
|
40
|
+
"bunny_params": {
|
41
|
+
...
|
42
|
+
},
|
43
|
+
"queue": {
|
44
|
+
"name": "your rabbit queue",
|
45
|
+
"params": {
|
46
|
+
"durable": true,
|
47
|
+
<other bunny queue parameters>
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"exchange": {
|
51
|
+
"name": "your rabbit exchange",
|
52
|
+
"params": {
|
53
|
+
"durable": true,
|
54
|
+
<other bunny exchange parameters>
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"event_timestamp_name": "happened at:",
|
58
|
+
"event_resource_id_name": "CF Resource ID:",
|
59
|
+
"event_resource_type_name": "CF Resource Type:",
|
60
|
+
"event_resource_status_name": "CF Resource Status:",
|
61
|
+
"event_resource_reason_name": "What up?"
|
62
|
+
},
|
63
|
+
"storage": {
|
64
|
+
"s3_bucket": {
|
65
|
+
"name": "my_task_storage",
|
66
|
+
"public": false,
|
67
|
+
"files": [
|
68
|
+
"first_to_file_from_additional_files_section.extension",
|
69
|
+
"second_to_file_from_additional_files_section.extension"
|
70
|
+
]
|
71
|
+
}
|
36
72
|
}
|
37
73
|
}
|
38
74
|
}
|
data/lib/zergrush_cf/init.rb
CHANGED
@@ -27,6 +27,8 @@ require 'excon'
|
|
27
27
|
require 'rbconfig'
|
28
28
|
require 'awesome_print'
|
29
29
|
require 'securerandom'
|
30
|
+
require 'bunny'
|
31
|
+
require 'time'
|
30
32
|
require_relative 'renderer'
|
31
33
|
|
32
34
|
class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
@@ -46,6 +48,8 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
46
48
|
abort("AWS key id is not specified in task") unless aws_key_id != nil
|
47
49
|
abort("AWS secret is not specified in task") unless aws_secret != nil
|
48
50
|
|
51
|
+
rabbit_objects = initRabbitConnection(task_hash["vm"]["driver"]["driveroptions"][0]["rabbit"])
|
52
|
+
|
49
53
|
renderer = ZergrushCF::Renderer.new(
|
50
54
|
hive_location,
|
51
55
|
task_name,
|
@@ -113,6 +117,7 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
113
117
|
event_counter = 0
|
114
118
|
while outputs_info.body["Stacks"][0]["StackStatus"] == "CREATE_IN_PROGRESS" do
|
115
119
|
logEvents(events.first(events.length - event_counter))
|
120
|
+
logRabbitEvents(events.first(events.length - event_counter), rabbit_objects, eval_params(task_hash["vm"]["driver"]["driveroptions"][0]["rabbit"]))
|
116
121
|
event_counter = events.length
|
117
122
|
|
118
123
|
events = cf.describe_stack_events(stack_name).body['StackEvents']
|
@@ -121,13 +126,16 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
121
126
|
logEvents(events.first(events.length - event_counter))
|
122
127
|
puts("Stack outputs:")
|
123
128
|
ap outputs_info.body["Stacks"][0]["Outputs"]
|
129
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
124
130
|
return 0
|
125
131
|
end
|
126
132
|
end
|
127
133
|
|
134
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
128
135
|
abort("ERROR: Failed with stack status: #{outputs_info.body["Stacks"][0]["StackStatus"]}")
|
129
136
|
|
130
137
|
rescue Fog::Errors::Error => fog_cf_error
|
138
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
131
139
|
abort ("ERROR: AWS error: #{fog_cf_error.message}")
|
132
140
|
end
|
133
141
|
|
@@ -148,6 +156,8 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
148
156
|
abort("AWS key id is not specified in task") unless aws_key_id != nil
|
149
157
|
abort("AWS secret is not specified in task") unless aws_secret != nil
|
150
158
|
|
159
|
+
rabbit_objects = initRabbitConnection(task_hash["vm"]["driver"]["driveroptions"][0]["rabbit"])
|
160
|
+
|
151
161
|
puts("Cleaning task #{task_name} ...")
|
152
162
|
|
153
163
|
# run fog cleanup on the stack.
|
@@ -168,6 +178,7 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
168
178
|
begin
|
169
179
|
outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
|
170
180
|
rescue Fog::AWS::CloudFormation::NotFound
|
181
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
171
182
|
return 0
|
172
183
|
end
|
173
184
|
end
|
@@ -178,6 +189,7 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
178
189
|
begin
|
179
190
|
events = cf.describe_stack_events(stack_name).body['StackEvents']
|
180
191
|
rescue Fog::AWS::CloudFormation::NotFound
|
192
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
181
193
|
return 0
|
182
194
|
end
|
183
195
|
end
|
@@ -185,25 +197,30 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
185
197
|
event_counter = 0
|
186
198
|
while outputs_info.body["Stacks"][0]["StackStatus"] == "DELETE_IN_PROGRESS" do
|
187
199
|
logEvents(events.first(events.length - event_counter))
|
200
|
+
logRabbitEvents(events.first(events.length - event_counter), rabbit_objects, eval_params(task_hash["vm"]["driver"]["driveroptions"][0]["rabbit"]))
|
201
|
+
|
188
202
|
event_counter = events.length
|
189
203
|
begin
|
190
204
|
events = cf.describe_stack_events(stack_name).body['StackEvents']
|
191
205
|
outputs_info = cf.describe_stacks({ 'StackName' => stack_name })
|
192
206
|
rescue Fog::AWS::CloudFormation::NotFound
|
193
207
|
logEvents(events.first(events.length - event_counter))
|
208
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
194
209
|
return 0
|
195
210
|
end
|
196
211
|
end
|
197
212
|
|
213
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
198
214
|
abort("ERROR: Failed with stack status: #{outputs_info.body["Stacks"][0]["StackStatus"]}")
|
199
215
|
|
200
216
|
rescue Fog::Errors::Error => fog_cf_error
|
217
|
+
rabbit_objects[:connection].close unless rabbit_objects == nil
|
201
218
|
abort ("ERROR: AWS error: #{fog_cf_error.ai}")
|
202
219
|
end
|
203
220
|
|
204
221
|
def logEvents events
|
205
222
|
events.each do |event|
|
206
|
-
puts "Timestamp: #{event['Timestamp']}"
|
223
|
+
puts "Timestamp: #{Time.parse(event['Timestamp'].to_s).iso8601}"
|
207
224
|
puts "LogicalResourceId: #{event['LogicalResourceId']}"
|
208
225
|
puts "ResourceType: #{event['ResourceType']}"
|
209
226
|
puts "ResourceStatus: #{event['ResourceStatus']}"
|
@@ -212,6 +229,40 @@ class CloudFormation < ZergGemPlugin::Plugin "/driver"
|
|
212
229
|
end
|
213
230
|
end
|
214
231
|
|
232
|
+
def initRabbitConnection rabbitInfo
|
233
|
+
return nil unless rabbitInfo != nil
|
234
|
+
params = eval_params(rabbitInfo)
|
235
|
+
conn = Bunny.new(Hash[params["bunny_params"].map{ |k, v| [k.to_sym, v] }])
|
236
|
+
conn.start
|
237
|
+
|
238
|
+
channel = conn.create_channel
|
239
|
+
exch = (params["exchange"] == nil) ? channel.default_echange : channel.direct(params["exchange"]["name"], Hash[params["exchange"]["params"].map{ |k, v| [k.to_sym, v] }])
|
240
|
+
channel.queue(params["queue"]["name"], Hash[params["queue"]["params"].map{ |k, v| [k.to_sym, v] }]).bind(exch)
|
241
|
+
|
242
|
+
return { :connection => conn, :channel => channel, :exchange => exch }
|
243
|
+
end
|
244
|
+
|
245
|
+
def logRabbitEvents events, rabbit_objects, rabbit_properties
|
246
|
+
timestamp = (rabbit_properties["event_timestamp_name"] == nil) ? "timestamp" : rabbit_properties["event_timestamp_name"]
|
247
|
+
res_id_name = (rabbit_properties["event_resource_id_name"] == nil) ? "resource_id" : rabbit_properties["event_resource_id_name"]
|
248
|
+
res_type_name = (rabbit_properties["event_resource_type_name"] == nil) ? "resource_type" : rabbit_properties["event_resource_type_name"]
|
249
|
+
res_status = (rabbit_properties["event_resource_status_name"] == nil) ? "resource_status" : rabbit_properties["event_resource_status_name"]
|
250
|
+
reason = (rabbit_properties["event_resource_reason_name"] == nil) ? "reason" : rabbit_properties["event_resource_reason_name"]
|
251
|
+
|
252
|
+
|
253
|
+
events.each do |event|
|
254
|
+
event_info = {
|
255
|
+
timestamp.to_sym => "#{Time.parse(event['Timestamp'].to_s).iso8601}",
|
256
|
+
res_id_name.to_sym => "#{event['LogicalResourceId']}",
|
257
|
+
res_type_name.to_sym => "#{event['ResourceType']}",
|
258
|
+
res_status.to_sym => "#{event['ResourceStatus']}",
|
259
|
+
reason.to_sym => "#{event['ResourceStatusReason']}"
|
260
|
+
}
|
261
|
+
|
262
|
+
rabbit_objects[:exchange].publish(event_info.to_json, :routing_key => rabbit_properties["queue"]["name"])
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
215
266
|
def halt hive_location, task_name, task_hash, debug
|
216
267
|
puts("Halt is not implemented for CloudFormation.")
|
217
268
|
return
|
data/lib/zergrush_cf/version.rb
CHANGED
@@ -13,6 +13,65 @@
|
|
13
13
|
"template_parameters": {
|
14
14
|
"type": "object"
|
15
15
|
},
|
16
|
+
"rabbit": {
|
17
|
+
"type": "object",
|
18
|
+
"properties": {
|
19
|
+
"bunny_params": {
|
20
|
+
"type": "object"
|
21
|
+
},
|
22
|
+
"queue": {
|
23
|
+
"type": "object",
|
24
|
+
"properties": {
|
25
|
+
"name": {
|
26
|
+
"type": "string"
|
27
|
+
},
|
28
|
+
"params": {
|
29
|
+
"type": "object"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"required": [
|
33
|
+
"name"
|
34
|
+
],
|
35
|
+
"additionalProperties": false
|
36
|
+
|
37
|
+
},
|
38
|
+
"exchange": {
|
39
|
+
"type": "object",
|
40
|
+
"properties": {
|
41
|
+
"name": {
|
42
|
+
"type": "string"
|
43
|
+
},
|
44
|
+
"params": {
|
45
|
+
"type": "object"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"required": [
|
49
|
+
"name"
|
50
|
+
],
|
51
|
+
"additionalProperties": false
|
52
|
+
},
|
53
|
+
"event_timestamp_name": {
|
54
|
+
"type": "string"
|
55
|
+
},
|
56
|
+
"event_resource_id_name": {
|
57
|
+
"type": "string"
|
58
|
+
},
|
59
|
+
"event_resource_type_name": {
|
60
|
+
"type": "string"
|
61
|
+
},
|
62
|
+
"event_resource_status_name": {
|
63
|
+
"type": "string"
|
64
|
+
},
|
65
|
+
"event_resource_reason_name": {
|
66
|
+
"type": "string"
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"required": [
|
70
|
+
"bunny_params",
|
71
|
+
"queue"
|
72
|
+
],
|
73
|
+
"additionalProperties": false
|
74
|
+
},
|
16
75
|
"storage": {
|
17
76
|
"type": "object",
|
18
77
|
"properties": {
|
data/zergrush_cf.gemspec
CHANGED
@@ -17,9 +17,10 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
19
19
|
s.add_development_dependency "rake"
|
20
|
-
s.add_development_dependency "zergrush", ">= 0.0.
|
20
|
+
s.add_development_dependency "zergrush", ">= 0.0.13"
|
21
21
|
|
22
22
|
s.add_dependency "fog", ">=1.20.0"
|
23
|
+
s.add_dependency "bunny", ">=1.2.1"
|
23
24
|
|
24
25
|
s.files = `git ls-files`.split("\n")
|
25
26
|
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
|
+
version: 0.0.6
|
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
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0.
|
47
|
+
version: 0.0.13
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.0.
|
54
|
+
version: 0.0.13
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fog
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.20.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bunny
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.2.1
|
69
83
|
description: Amazon Cloud Formation driver for zergrush
|
70
84
|
email:
|
71
85
|
- Marat.Garafutdinov@mtnsat.com
|