knife-spork 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +35 -35
- data/lib/chef/knife/spork-bump.rb +100 -100
- data/lib/chef/knife/spork-check.rb +165 -161
- data/lib/chef/knife/spork-databag-create.rb +54 -54
- data/lib/chef/knife/spork-databag-delete.rb +51 -51
- data/lib/chef/knife/spork-databag-edit.rb +54 -54
- data/lib/chef/knife/spork-databag-fromfile.rb +88 -88
- data/lib/chef/knife/spork-delete.rb +132 -132
- data/lib/chef/knife/spork-environment-check.rb +90 -90
- data/lib/chef/knife/spork-environment-create.rb +63 -63
- data/lib/chef/knife/spork-environment-delete.rb +38 -38
- data/lib/chef/knife/spork-environment-edit.rb +40 -40
- data/lib/chef/knife/spork-environment-fromfile.rb +46 -46
- data/lib/chef/knife/spork-info.rb +34 -34
- data/lib/chef/knife/spork-node-create.rb +41 -41
- data/lib/chef/knife/spork-node-delete.rb +41 -41
- data/lib/chef/knife/spork-node-edit.rb +48 -48
- data/lib/chef/knife/spork-node-fromfile.rb +46 -46
- data/lib/chef/knife/spork-node-runlistadd.rb +51 -51
- data/lib/chef/knife/spork-node-runlistremove.rb +44 -44
- data/lib/chef/knife/spork-node-runlistset.rb +44 -44
- data/lib/chef/knife/spork-omni.rb +112 -112
- data/lib/chef/knife/spork-promote.rb +197 -197
- data/lib/chef/knife/spork-role-create.rb +46 -46
- data/lib/chef/knife/spork-role-delete.rb +50 -50
- data/lib/chef/knife/spork-role-edit.rb +40 -40
- data/lib/chef/knife/spork-role-fromfile.rb +65 -65
- data/lib/chef/knife/spork-upload.rb +151 -151
- data/lib/chef/knife/spork-version.rb +12 -12
- data/lib/knife-spork.rb +3 -3
- data/lib/knife-spork/plugins.rb +27 -27
- data/lib/knife-spork/plugins/campfire.rb +219 -219
- data/lib/knife-spork/plugins/eventinator.rb +329 -329
- data/lib/knife-spork/plugins/foodcritic.rb +46 -46
- data/lib/knife-spork/plugins/git.rb +393 -399
- data/lib/knife-spork/plugins/graphite.rb +25 -25
- data/lib/knife-spork/plugins/grove.rb +167 -167
- data/lib/knife-spork/plugins/hipchat.rb +171 -171
- data/lib/knife-spork/plugins/influxdb.rb +28 -28
- data/lib/knife-spork/plugins/irccat.rb +332 -332
- data/lib/knife-spork/plugins/jabber.rb +133 -133
- data/lib/knife-spork/plugins/plugin.rb +117 -117
- data/lib/knife-spork/plugins/rubocop.rb +56 -56
- data/lib/knife-spork/plugins/slack.rb +125 -125
- data/lib/knife-spork/plugins/statusnet.rb +122 -122
- data/lib/knife-spork/runner.rb +342 -342
- data/lib/knife-spork/version.rb +5 -5
- metadata +4 -51
- data/.gitignore +0 -21
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -3
- data/CHANGELOG.md +0 -445
- data/Gemfile +0 -3
- data/README.md +0 -544
- data/Rakefile +0 -35
- data/knife-spork.gemspec +0 -28
- data/plugins/Campfire.md +0 -43
- data/plugins/Eventinator.md +0 -30
- data/plugins/Foodcritic.md +0 -53
- data/plugins/Git.md +0 -53
- data/plugins/Graphite.md +0 -30
- data/plugins/Grove.md +0 -31
- data/plugins/HipChat.md +0 -69
- data/plugins/Influxdb.md +0 -25
- data/plugins/Irccat.md +0 -50
- data/plugins/Jabber.md +0 -61
- data/plugins/README.md +0 -70
- data/plugins/Rubocop.md +0 -110
- data/plugins/Slack.md +0 -48
- data/plugins/StatusNet.md +0 -41
- data/plugins/Template.md +0 -34
- data/spec/spec_helper.rb +0 -10
- data/spec/test_helpers.rb +0 -46
- data/spec/unit/fixtures/config/spork-config.yml +0 -1
- data/spec/unit/fixtures/cookbooks/example/metadata.rb +0 -8
- data/spec/unit/fixtures/environments/example.json +0 -12
- data/spec/unit/fixtures/knife.rb +0 -6
- data/spec/unit/fixtures/test_client.pem +0 -27
- data/spec/unit/spork_bump_spec.rb +0 -75
- data/spec/unit/spork_info_spec.rb +0 -40
- data/spec/unit/spork_promote_spec.rb +0 -77
- data/spec/unit/spork_upload_spec.rb +0 -46
@@ -1,329 +1,329 @@
|
|
1
|
-
require 'knife-spork/plugins/plugin'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
module KnifeSpork
|
6
|
-
module Plugins
|
7
|
-
class Eventinator < Plugin
|
8
|
-
name :eventinator
|
9
|
-
|
10
|
-
def perform; end
|
11
|
-
|
12
|
-
def after_upload
|
13
|
-
cookbooks.each do |cookbook|
|
14
|
-
event_data = {
|
15
|
-
:tag => 'knife',
|
16
|
-
:username => current_user,
|
17
|
-
:status => "#{organization}#{current_user} uploaded and froze #{cookbook.name}@#{cookbook.version}",
|
18
|
-
:metadata => {
|
19
|
-
:cookbook_name => cookbook.name,
|
20
|
-
:cookbook_version => cookbook.version
|
21
|
-
}.to_json
|
22
|
-
}
|
23
|
-
eventinate(event_data)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def after_delete
|
28
|
-
event_data = {
|
29
|
-
:tag => 'knife',
|
30
|
-
:username => current_user,
|
31
|
-
:status => "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}",
|
32
|
-
:metadata => {
|
33
|
-
:deleted_cookbooks => misc_output
|
34
|
-
}.to_json
|
35
|
-
}
|
36
|
-
eventinate(event_data)
|
37
|
-
end
|
38
|
-
|
39
|
-
def after_promote_remote
|
40
|
-
environments.each do |environment|
|
41
|
-
cookbooks.each do |cookbook|
|
42
|
-
event_data = {
|
43
|
-
:tag => 'knife',
|
44
|
-
:username => current_user,
|
45
|
-
:status => "#{organization}#{current_user} promoted #{cookbook.name}(#{cookbook.version}) to #{environment.name}",
|
46
|
-
:metadata => {
|
47
|
-
:cookbook_name => cookbook.name,
|
48
|
-
:cookbook_version => cookbook.version
|
49
|
-
}.to_json
|
50
|
-
}
|
51
|
-
eventinate(event_data)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def after_environmentfromfile
|
57
|
-
event_data = {
|
58
|
-
:tag => 'knife',
|
59
|
-
:username => current_user,
|
60
|
-
:status => "#{organization}#{current_user} uploaded environment #{object_name}",
|
61
|
-
:metadata => {
|
62
|
-
:environment_name => object_name,
|
63
|
-
}.to_json
|
64
|
-
}
|
65
|
-
eventinate(event_data)
|
66
|
-
end
|
67
|
-
|
68
|
-
def after_environmentedit
|
69
|
-
event_data = {
|
70
|
-
:tag => 'knife',
|
71
|
-
:username => current_user,
|
72
|
-
:status => "#{organization}#{current_user} edited environment #{object_name}",
|
73
|
-
:metadata => {
|
74
|
-
:environment_name => object_name,
|
75
|
-
}.to_json
|
76
|
-
}
|
77
|
-
eventinate(event_data)
|
78
|
-
end
|
79
|
-
|
80
|
-
def after_environmentcreate
|
81
|
-
event_data = {
|
82
|
-
:tag => 'knife',
|
83
|
-
:username => current_user,
|
84
|
-
:status => "#{organization}#{current_user} created environment #{object_name}",
|
85
|
-
:metadata => {
|
86
|
-
:environment_name => object_name,
|
87
|
-
}.to_json
|
88
|
-
}
|
89
|
-
eventinate(event_data)
|
90
|
-
end
|
91
|
-
|
92
|
-
def after_environmentdelete
|
93
|
-
event_data = {
|
94
|
-
:tag => 'knife',
|
95
|
-
:username => current_user,
|
96
|
-
:status => "#{organization}#{current_user} deleted environment #{object_name}",
|
97
|
-
:metadata => {
|
98
|
-
:environment_name => object_name,
|
99
|
-
}.to_json
|
100
|
-
}
|
101
|
-
eventinate(event_data)
|
102
|
-
end
|
103
|
-
|
104
|
-
def after_rolefromfile
|
105
|
-
event_data = {
|
106
|
-
:tag => 'knife',
|
107
|
-
:username => current_user,
|
108
|
-
:status => "#{organization}#{current_user} uploaded role #{object_name}",
|
109
|
-
:metadata => {
|
110
|
-
:role_name => object_name,
|
111
|
-
}.to_json
|
112
|
-
}
|
113
|
-
eventinate(event_data)
|
114
|
-
end
|
115
|
-
|
116
|
-
def after_roleedit
|
117
|
-
event_data = {
|
118
|
-
:tag => 'knife',
|
119
|
-
:username => current_user,
|
120
|
-
:status => "#{organization}#{current_user} edited role #{object_name}",
|
121
|
-
:metadata => {
|
122
|
-
:role_name => object_name,
|
123
|
-
}.to_json
|
124
|
-
}
|
125
|
-
eventinate(event_data)
|
126
|
-
end
|
127
|
-
|
128
|
-
def after_rolecreate
|
129
|
-
event_data = {
|
130
|
-
:tag => 'knife',
|
131
|
-
:username => current_user,
|
132
|
-
:status => "#{organization}#{current_user} created role #{object_name}",
|
133
|
-
:metadata => {
|
134
|
-
:role_name => object_name,
|
135
|
-
}.to_json
|
136
|
-
}
|
137
|
-
eventinate(event_data)
|
138
|
-
end
|
139
|
-
|
140
|
-
def after_roledelete
|
141
|
-
event_data = {
|
142
|
-
:tag => 'knife',
|
143
|
-
:username => current_user,
|
144
|
-
:status => "#{organization}#{current_user} deleted role #{object_name}",
|
145
|
-
:metadata => {
|
146
|
-
:role_name => object_name,
|
147
|
-
}.to_json
|
148
|
-
}
|
149
|
-
eventinate(event_data)
|
150
|
-
end
|
151
|
-
|
152
|
-
def after_databagedit
|
153
|
-
event_data = {
|
154
|
-
:tag => 'knife',
|
155
|
-
:username => current_user,
|
156
|
-
:status => "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}",
|
157
|
-
:metadata => {
|
158
|
-
:databag_name => object_name,
|
159
|
-
:databag_item => object_secondary_name,
|
160
|
-
}.to_json
|
161
|
-
}
|
162
|
-
eventinate(event_data)
|
163
|
-
end
|
164
|
-
|
165
|
-
def after_databagcreate
|
166
|
-
event_data = {
|
167
|
-
:tag => 'knife',
|
168
|
-
:username => current_user,
|
169
|
-
:status => "#{organization}#{current_user} created data bag #{object_name}",
|
170
|
-
:metadata => {
|
171
|
-
:databag_name => object_name,
|
172
|
-
}.to_json
|
173
|
-
}
|
174
|
-
eventinate(event_data)
|
175
|
-
end
|
176
|
-
|
177
|
-
def after_databagdelete
|
178
|
-
event_data = {
|
179
|
-
:tag => 'knife',
|
180
|
-
:username => current_user,
|
181
|
-
:status => "#{organization}#{current_user} deleted data bag item #{object_name}",
|
182
|
-
:metadata => {
|
183
|
-
:databag_name => object_name,
|
184
|
-
}.to_json
|
185
|
-
}
|
186
|
-
eventinate(event_data)
|
187
|
-
end
|
188
|
-
|
189
|
-
def after_databagitemdelete
|
190
|
-
event_data = {
|
191
|
-
:tag => 'knife',
|
192
|
-
:username => current_user,
|
193
|
-
:status => "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}",
|
194
|
-
:metadata => {
|
195
|
-
:databag_name => object_name,
|
196
|
-
:databag_item => object_secondary_name,
|
197
|
-
}.to_json
|
198
|
-
}
|
199
|
-
eventinate(event_data)
|
200
|
-
end
|
201
|
-
|
202
|
-
def after_databagfromfile
|
203
|
-
event_data = {
|
204
|
-
:tag => 'knife',
|
205
|
-
:username => current_user,
|
206
|
-
:status => "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}",
|
207
|
-
:metadata => {
|
208
|
-
:databag_name => object_name,
|
209
|
-
:databag_item => object_secondary_name,
|
210
|
-
}.to_json
|
211
|
-
}
|
212
|
-
eventinate(event_data)
|
213
|
-
end
|
214
|
-
|
215
|
-
def after_nodeedit
|
216
|
-
event_data = {
|
217
|
-
:tag => 'knife',
|
218
|
-
:username => current_user,
|
219
|
-
:status => "#{organization}#{current_user} edited node #{object_name}",
|
220
|
-
:metadata => {
|
221
|
-
:node_name => object_name
|
222
|
-
}.to_json
|
223
|
-
}
|
224
|
-
eventinate(event_data)
|
225
|
-
end
|
226
|
-
|
227
|
-
def after_nodedelete
|
228
|
-
event_data = {
|
229
|
-
:tag => 'knife',
|
230
|
-
:username => current_user,
|
231
|
-
:status => "#{organization}#{current_user} deleted node #{object_name}",
|
232
|
-
:metadata => {
|
233
|
-
:node_name => object_name
|
234
|
-
}.to_json
|
235
|
-
}
|
236
|
-
eventinate(event_data)
|
237
|
-
end
|
238
|
-
|
239
|
-
def after_nodecreate
|
240
|
-
event_data = {
|
241
|
-
:tag => 'knife',
|
242
|
-
:username => current_user,
|
243
|
-
:status => "#{organization}#{current_user} created node #{object_name}",
|
244
|
-
:metadata => {
|
245
|
-
:node_name => object_name
|
246
|
-
}.to_json
|
247
|
-
}
|
248
|
-
eventinate(event_data)
|
249
|
-
end
|
250
|
-
|
251
|
-
def after_nodefromfile
|
252
|
-
event_data = {
|
253
|
-
:tag => 'knife',
|
254
|
-
:username => current_user,
|
255
|
-
:status => "#{organization}#{current_user} uploaded node #{object_name}",
|
256
|
-
:metadata => {
|
257
|
-
:node_name => object_name
|
258
|
-
}.to_json
|
259
|
-
}
|
260
|
-
eventinate(event_data)
|
261
|
-
end
|
262
|
-
|
263
|
-
def after_noderunlistadd
|
264
|
-
event_data = {
|
265
|
-
:tag => 'knife',
|
266
|
-
:username => current_user,
|
267
|
-
:status => "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}",
|
268
|
-
:metadata => {
|
269
|
-
:node_name => object_name,
|
270
|
-
:run_list_items => object_secondary_name,
|
271
|
-
}.to_json
|
272
|
-
}
|
273
|
-
eventinate(event_data)
|
274
|
-
end
|
275
|
-
|
276
|
-
def after_noderunlistremove
|
277
|
-
event_data = {
|
278
|
-
:tag => 'knife',
|
279
|
-
:username => current_user,
|
280
|
-
:status => "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}",
|
281
|
-
:metadata => {
|
282
|
-
:node_name => object_name,
|
283
|
-
:run_list_items => object_secondary_name,
|
284
|
-
}.to_json
|
285
|
-
}
|
286
|
-
eventinate(event_data)
|
287
|
-
end
|
288
|
-
|
289
|
-
def after_noderunlistset
|
290
|
-
event_data = {
|
291
|
-
:tag => 'knife',
|
292
|
-
:username => current_user,
|
293
|
-
:status => "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}",
|
294
|
-
:metadata => {
|
295
|
-
:node_name => object_name,
|
296
|
-
:run_list_items => object_secondary_name,
|
297
|
-
}.to_json
|
298
|
-
}
|
299
|
-
eventinate(event_data)
|
300
|
-
end
|
301
|
-
|
302
|
-
def eventinate(event_data)
|
303
|
-
begin
|
304
|
-
uri = URI.parse(config.url)
|
305
|
-
rescue Exception => e
|
306
|
-
ui.error 'Could not parse URI for Eventinator.'
|
307
|
-
ui.error e.to_s
|
308
|
-
return
|
309
|
-
end
|
310
|
-
|
311
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
312
|
-
http.read_timeout = config.read_timeout || 5
|
313
|
-
|
314
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
315
|
-
request.set_form_data(event_data)
|
316
|
-
|
317
|
-
begin
|
318
|
-
response = http.request(request)
|
319
|
-
ui.error "Eventinator at #{config.url} did not receive a good response from the server" if response.code != '200'
|
320
|
-
rescue Timeout::Error
|
321
|
-
ui.error "Eventinator timed out connecting to #{config.url}. Is that URL accessible?"
|
322
|
-
rescue Exception => e
|
323
|
-
ui.error 'Eventinator error.'
|
324
|
-
ui.error e.to_s
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
1
|
+
require 'knife-spork/plugins/plugin'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module KnifeSpork
|
6
|
+
module Plugins
|
7
|
+
class Eventinator < Plugin
|
8
|
+
name :eventinator
|
9
|
+
|
10
|
+
def perform; end
|
11
|
+
|
12
|
+
def after_upload
|
13
|
+
cookbooks.each do |cookbook|
|
14
|
+
event_data = {
|
15
|
+
:tag => 'knife',
|
16
|
+
:username => current_user,
|
17
|
+
:status => "#{organization}#{current_user} uploaded and froze #{cookbook.name}@#{cookbook.version}",
|
18
|
+
:metadata => {
|
19
|
+
:cookbook_name => cookbook.name,
|
20
|
+
:cookbook_version => cookbook.version
|
21
|
+
}.to_json
|
22
|
+
}
|
23
|
+
eventinate(event_data)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def after_delete
|
28
|
+
event_data = {
|
29
|
+
:tag => 'knife',
|
30
|
+
:username => current_user,
|
31
|
+
:status => "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}",
|
32
|
+
:metadata => {
|
33
|
+
:deleted_cookbooks => misc_output
|
34
|
+
}.to_json
|
35
|
+
}
|
36
|
+
eventinate(event_data)
|
37
|
+
end
|
38
|
+
|
39
|
+
def after_promote_remote
|
40
|
+
environments.each do |environment|
|
41
|
+
cookbooks.each do |cookbook|
|
42
|
+
event_data = {
|
43
|
+
:tag => 'knife',
|
44
|
+
:username => current_user,
|
45
|
+
:status => "#{organization}#{current_user} promoted #{cookbook.name}(#{cookbook.version}) to #{environment.name}",
|
46
|
+
:metadata => {
|
47
|
+
:cookbook_name => cookbook.name,
|
48
|
+
:cookbook_version => cookbook.version
|
49
|
+
}.to_json
|
50
|
+
}
|
51
|
+
eventinate(event_data)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_environmentfromfile
|
57
|
+
event_data = {
|
58
|
+
:tag => 'knife',
|
59
|
+
:username => current_user,
|
60
|
+
:status => "#{organization}#{current_user} uploaded environment #{object_name}",
|
61
|
+
:metadata => {
|
62
|
+
:environment_name => object_name,
|
63
|
+
}.to_json
|
64
|
+
}
|
65
|
+
eventinate(event_data)
|
66
|
+
end
|
67
|
+
|
68
|
+
def after_environmentedit
|
69
|
+
event_data = {
|
70
|
+
:tag => 'knife',
|
71
|
+
:username => current_user,
|
72
|
+
:status => "#{organization}#{current_user} edited environment #{object_name}",
|
73
|
+
:metadata => {
|
74
|
+
:environment_name => object_name,
|
75
|
+
}.to_json
|
76
|
+
}
|
77
|
+
eventinate(event_data)
|
78
|
+
end
|
79
|
+
|
80
|
+
def after_environmentcreate
|
81
|
+
event_data = {
|
82
|
+
:tag => 'knife',
|
83
|
+
:username => current_user,
|
84
|
+
:status => "#{organization}#{current_user} created environment #{object_name}",
|
85
|
+
:metadata => {
|
86
|
+
:environment_name => object_name,
|
87
|
+
}.to_json
|
88
|
+
}
|
89
|
+
eventinate(event_data)
|
90
|
+
end
|
91
|
+
|
92
|
+
def after_environmentdelete
|
93
|
+
event_data = {
|
94
|
+
:tag => 'knife',
|
95
|
+
:username => current_user,
|
96
|
+
:status => "#{organization}#{current_user} deleted environment #{object_name}",
|
97
|
+
:metadata => {
|
98
|
+
:environment_name => object_name,
|
99
|
+
}.to_json
|
100
|
+
}
|
101
|
+
eventinate(event_data)
|
102
|
+
end
|
103
|
+
|
104
|
+
def after_rolefromfile
|
105
|
+
event_data = {
|
106
|
+
:tag => 'knife',
|
107
|
+
:username => current_user,
|
108
|
+
:status => "#{organization}#{current_user} uploaded role #{object_name}",
|
109
|
+
:metadata => {
|
110
|
+
:role_name => object_name,
|
111
|
+
}.to_json
|
112
|
+
}
|
113
|
+
eventinate(event_data)
|
114
|
+
end
|
115
|
+
|
116
|
+
def after_roleedit
|
117
|
+
event_data = {
|
118
|
+
:tag => 'knife',
|
119
|
+
:username => current_user,
|
120
|
+
:status => "#{organization}#{current_user} edited role #{object_name}",
|
121
|
+
:metadata => {
|
122
|
+
:role_name => object_name,
|
123
|
+
}.to_json
|
124
|
+
}
|
125
|
+
eventinate(event_data)
|
126
|
+
end
|
127
|
+
|
128
|
+
def after_rolecreate
|
129
|
+
event_data = {
|
130
|
+
:tag => 'knife',
|
131
|
+
:username => current_user,
|
132
|
+
:status => "#{organization}#{current_user} created role #{object_name}",
|
133
|
+
:metadata => {
|
134
|
+
:role_name => object_name,
|
135
|
+
}.to_json
|
136
|
+
}
|
137
|
+
eventinate(event_data)
|
138
|
+
end
|
139
|
+
|
140
|
+
def after_roledelete
|
141
|
+
event_data = {
|
142
|
+
:tag => 'knife',
|
143
|
+
:username => current_user,
|
144
|
+
:status => "#{organization}#{current_user} deleted role #{object_name}",
|
145
|
+
:metadata => {
|
146
|
+
:role_name => object_name,
|
147
|
+
}.to_json
|
148
|
+
}
|
149
|
+
eventinate(event_data)
|
150
|
+
end
|
151
|
+
|
152
|
+
def after_databagedit
|
153
|
+
event_data = {
|
154
|
+
:tag => 'knife',
|
155
|
+
:username => current_user,
|
156
|
+
:status => "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name}",
|
157
|
+
:metadata => {
|
158
|
+
:databag_name => object_name,
|
159
|
+
:databag_item => object_secondary_name,
|
160
|
+
}.to_json
|
161
|
+
}
|
162
|
+
eventinate(event_data)
|
163
|
+
end
|
164
|
+
|
165
|
+
def after_databagcreate
|
166
|
+
event_data = {
|
167
|
+
:tag => 'knife',
|
168
|
+
:username => current_user,
|
169
|
+
:status => "#{organization}#{current_user} created data bag #{object_name}",
|
170
|
+
:metadata => {
|
171
|
+
:databag_name => object_name,
|
172
|
+
}.to_json
|
173
|
+
}
|
174
|
+
eventinate(event_data)
|
175
|
+
end
|
176
|
+
|
177
|
+
def after_databagdelete
|
178
|
+
event_data = {
|
179
|
+
:tag => 'knife',
|
180
|
+
:username => current_user,
|
181
|
+
:status => "#{organization}#{current_user} deleted data bag item #{object_name}",
|
182
|
+
:metadata => {
|
183
|
+
:databag_name => object_name,
|
184
|
+
}.to_json
|
185
|
+
}
|
186
|
+
eventinate(event_data)
|
187
|
+
end
|
188
|
+
|
189
|
+
def after_databagitemdelete
|
190
|
+
event_data = {
|
191
|
+
:tag => 'knife',
|
192
|
+
:username => current_user,
|
193
|
+
:status => "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name}",
|
194
|
+
:metadata => {
|
195
|
+
:databag_name => object_name,
|
196
|
+
:databag_item => object_secondary_name,
|
197
|
+
}.to_json
|
198
|
+
}
|
199
|
+
eventinate(event_data)
|
200
|
+
end
|
201
|
+
|
202
|
+
def after_databagfromfile
|
203
|
+
event_data = {
|
204
|
+
:tag => 'knife',
|
205
|
+
:username => current_user,
|
206
|
+
:status => "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name}",
|
207
|
+
:metadata => {
|
208
|
+
:databag_name => object_name,
|
209
|
+
:databag_item => object_secondary_name,
|
210
|
+
}.to_json
|
211
|
+
}
|
212
|
+
eventinate(event_data)
|
213
|
+
end
|
214
|
+
|
215
|
+
def after_nodeedit
|
216
|
+
event_data = {
|
217
|
+
:tag => 'knife',
|
218
|
+
:username => current_user,
|
219
|
+
:status => "#{organization}#{current_user} edited node #{object_name}",
|
220
|
+
:metadata => {
|
221
|
+
:node_name => object_name
|
222
|
+
}.to_json
|
223
|
+
}
|
224
|
+
eventinate(event_data)
|
225
|
+
end
|
226
|
+
|
227
|
+
def after_nodedelete
|
228
|
+
event_data = {
|
229
|
+
:tag => 'knife',
|
230
|
+
:username => current_user,
|
231
|
+
:status => "#{organization}#{current_user} deleted node #{object_name}",
|
232
|
+
:metadata => {
|
233
|
+
:node_name => object_name
|
234
|
+
}.to_json
|
235
|
+
}
|
236
|
+
eventinate(event_data)
|
237
|
+
end
|
238
|
+
|
239
|
+
def after_nodecreate
|
240
|
+
event_data = {
|
241
|
+
:tag => 'knife',
|
242
|
+
:username => current_user,
|
243
|
+
:status => "#{organization}#{current_user} created node #{object_name}",
|
244
|
+
:metadata => {
|
245
|
+
:node_name => object_name
|
246
|
+
}.to_json
|
247
|
+
}
|
248
|
+
eventinate(event_data)
|
249
|
+
end
|
250
|
+
|
251
|
+
def after_nodefromfile
|
252
|
+
event_data = {
|
253
|
+
:tag => 'knife',
|
254
|
+
:username => current_user,
|
255
|
+
:status => "#{organization}#{current_user} uploaded node #{object_name}",
|
256
|
+
:metadata => {
|
257
|
+
:node_name => object_name
|
258
|
+
}.to_json
|
259
|
+
}
|
260
|
+
eventinate(event_data)
|
261
|
+
end
|
262
|
+
|
263
|
+
def after_noderunlistadd
|
264
|
+
event_data = {
|
265
|
+
:tag => 'knife',
|
266
|
+
:username => current_user,
|
267
|
+
:status => "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name}",
|
268
|
+
:metadata => {
|
269
|
+
:node_name => object_name,
|
270
|
+
:run_list_items => object_secondary_name,
|
271
|
+
}.to_json
|
272
|
+
}
|
273
|
+
eventinate(event_data)
|
274
|
+
end
|
275
|
+
|
276
|
+
def after_noderunlistremove
|
277
|
+
event_data = {
|
278
|
+
:tag => 'knife',
|
279
|
+
:username => current_user,
|
280
|
+
:status => "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name}",
|
281
|
+
:metadata => {
|
282
|
+
:node_name => object_name,
|
283
|
+
:run_list_items => object_secondary_name,
|
284
|
+
}.to_json
|
285
|
+
}
|
286
|
+
eventinate(event_data)
|
287
|
+
end
|
288
|
+
|
289
|
+
def after_noderunlistset
|
290
|
+
event_data = {
|
291
|
+
:tag => 'knife',
|
292
|
+
:username => current_user,
|
293
|
+
:status => "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name}",
|
294
|
+
:metadata => {
|
295
|
+
:node_name => object_name,
|
296
|
+
:run_list_items => object_secondary_name,
|
297
|
+
}.to_json
|
298
|
+
}
|
299
|
+
eventinate(event_data)
|
300
|
+
end
|
301
|
+
|
302
|
+
def eventinate(event_data)
|
303
|
+
begin
|
304
|
+
uri = URI.parse(config.url)
|
305
|
+
rescue Exception => e
|
306
|
+
ui.error 'Could not parse URI for Eventinator.'
|
307
|
+
ui.error e.to_s
|
308
|
+
return
|
309
|
+
end
|
310
|
+
|
311
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
312
|
+
http.read_timeout = config.read_timeout || 5
|
313
|
+
|
314
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
315
|
+
request.set_form_data(event_data)
|
316
|
+
|
317
|
+
begin
|
318
|
+
response = http.request(request)
|
319
|
+
ui.error "Eventinator at #{config.url} did not receive a good response from the server" if response.code != '200'
|
320
|
+
rescue Timeout::Error
|
321
|
+
ui.error "Eventinator timed out connecting to #{config.url}. Is that URL accessible?"
|
322
|
+
rescue Exception => e
|
323
|
+
ui.error 'Eventinator error.'
|
324
|
+
ui.error e.to_s
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|