spiderfw 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/VERSION +1 -1
- data/apps/app_server/config/options.rb +2 -2
- data/apps/core/components/assets.rb +1 -5
- data/apps/core/components/widgets/month_calendar/month_calendar.shtml +3 -3
- data/apps/core/components/widgets/table/table.rb +2 -0
- data/apps/core/components/widgets/tabs/tabs.rb +9 -3
- data/apps/core/components/widgets/tabs/tabs.shtml +1 -1
- data/apps/master/_init.rb +3 -1
- data/apps/master/cmd.rb +1 -1
- data/apps/master/controllers/master_controller.rb +107 -103
- data/apps/master/controllers/scout_controller.rb +7 -7
- data/apps/master/controllers/{servant_controller.rb → server_controller.rb} +3 -3
- data/apps/master/data/locale/it/LC_MESSAGES/master.mo +0 -0
- data/apps/master/master.rb +4 -4
- data/apps/master/models/customer.rb +0 -3
- data/apps/master/models/installation.rb +14 -3
- data/apps/master/models/remote_log.rb +11 -0
- data/apps/master/models/scout_plugin_instance.rb +9 -9
- data/apps/master/models/scout_plugin_trigger.rb +2 -2
- data/apps/master/models/{servant.rb → server.rb} +6 -6
- data/apps/master/po/it/{spider_master.po → master.po} +127 -54
- data/apps/master/po/master.pot +23 -23
- data/apps/master/templates/email/alert.html.erb +1 -1
- data/apps/master/views/customer.shtml +3 -3
- data/apps/master/views/index.shtml +1 -2
- data/apps/master/views/installation.shtml +28 -16
- data/apps/master/views/master.layout.shtml +2 -1
- data/apps/master/views/plugin_data.shtml +1 -1
- data/apps/master/views/{servant.shtml → server.shtml} +14 -14
- data/apps/master/views/servers.shtml +11 -0
- data/apps/master/views/site_edit.shtml +1 -1
- data/apps/master/views/trigger_edit.shtml +4 -4
- data/apps/messenger/controllers/mixins/messenger_helper.rb +3 -3
- data/apps/servant/Gemfile +1 -0
- data/apps/servant/_init.rb +5 -1
- data/apps/servant/cmd.rb +14 -45
- data/apps/servant/config/options.rb +1 -0
- data/apps/servant/controllers/servant_controller.rb +7 -1
- data/apps/servant/lib/client.rb +55 -0
- data/apps/servant/servant.appspec +1 -1
- data/apps/servant/servant.rb +90 -0
- data/apps/worker/cmd.rb +9 -4
- data/apps/worker/worker.rb +11 -6
- data/blueprints/bin/spider +7 -0
- data/blueprints/home/config/config.yml +2 -3
- data/blueprints/home/init.rb +1 -1
- data/lib/spiderfw/app.rb +50 -2
- data/lib/spiderfw/cmd/commands/app.rb +22 -12
- data/lib/spiderfw/cmd/commands/config.rb +2 -1
- data/lib/spiderfw/config/configuration_editor.rb +7 -4
- data/lib/spiderfw/config/options/spider.rb +3 -1
- data/lib/spiderfw/controller/helpers/widget_helper.rb +6 -3
- data/lib/spiderfw/controller/mixins/http_mixin.rb +2 -1
- data/lib/spiderfw/controller/mixins/visual.rb +12 -10
- data/lib/spiderfw/env.rb +8 -1
- data/lib/spiderfw/home.rb +31 -4
- data/lib/spiderfw/http/server.rb +32 -14
- data/lib/spiderfw/model/mappers/mapper.rb +2 -2
- data/lib/spiderfw/model/mixins/tree.rb +7 -5
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +55 -2
- data/lib/spiderfw/model/storage/db/adapters/oracle.rb +80 -3
- data/lib/spiderfw/model/storage/db/connectors/jdbc_oracle.rb +3 -2
- data/lib/spiderfw/model/storage/db/connectors/oci8.rb +3 -2
- data/lib/spiderfw/model/storage/db/db_storage.rb +22 -0
- data/lib/spiderfw/setup/app_manager.rb +6 -2
- data/lib/spiderfw/site.rb +3 -1
- data/lib/spiderfw/spider.rb +145 -18
- data/lib/spiderfw/templates/blocks/parent_context.rb +3 -1
- data/lib/spiderfw/templates/template.rb +14 -5
- data/lib/spiderfw/widget/widget.rb +1 -0
- data/lib/spiderfw/widget/widget_attributes.rb +2 -2
- metadata +16 -16
- data/apps/master/po/spider_master.pot +0 -331
- data/apps/master/views/servants.shtml +0 -11
- data/apps/servant/lib/commands/discovery.rb +0 -0
- data/apps/servant/lib/resource.rb +0 -14
- data/apps/servant/lib/resources/db/mysql.rb +0 -35
- data/apps/servant/lib/resources/db.rb +0 -55
- data/apps/servant/lib/servant.rb +0 -88
- data/apps/servant/var/log/error.log +0 -1
@@ -1,331 +0,0 @@
|
|
1
|
-
# SOME DESCRIPTIVE TITLE.
|
2
|
-
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3
|
-
# This file is distributed under the same license as the PACKAGE package.
|
4
|
-
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5
|
-
#
|
6
|
-
#, fuzzy
|
7
|
-
msgid ""
|
8
|
-
msgstr ""
|
9
|
-
"Project-Id-Version: Spider::Master \n"
|
10
|
-
"POT-Creation-Date: 2010-09-24 20:50+0200\n"
|
11
|
-
"PO-Revision-Date: 2010-09-24 20:25+0200\n"
|
12
|
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13
|
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14
|
-
"MIME-Version: 1.0\n"
|
15
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
16
|
-
"Content-Transfer-Encoding: 8bit\n"
|
17
|
-
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
18
|
-
|
19
|
-
#: controllers/master_controller.rb:48 views/customers.shtml:3
|
20
|
-
#: views/index.shtml:2 views/master.layout.shtml:18
|
21
|
-
msgid "Customers"
|
22
|
-
msgstr ""
|
23
|
-
|
24
|
-
#: controllers/master_controller.rb:79
|
25
|
-
msgid "No customer"
|
26
|
-
msgstr ""
|
27
|
-
|
28
|
-
#: controllers/master_controller.rb:81
|
29
|
-
msgid "User can't access this customer"
|
30
|
-
msgstr ""
|
31
|
-
|
32
|
-
#: controllers/master_controller.rb:100
|
33
|
-
msgid "User can't list customers"
|
34
|
-
msgstr ""
|
35
|
-
|
36
|
-
#: models/scout_plugin_trigger.rb:6
|
37
|
-
msgid "Peak trigger"
|
38
|
-
msgstr ""
|
39
|
-
|
40
|
-
#: models/scout_plugin_trigger.rb:7
|
41
|
-
msgid "Plateau trigger"
|
42
|
-
msgstr ""
|
43
|
-
|
44
|
-
#: models/scout_plugin_trigger.rb:8
|
45
|
-
msgid "Trend trigger"
|
46
|
-
msgstr ""
|
47
|
-
|
48
|
-
#: models/scout_plugin_trigger.rb:13
|
49
|
-
msgid "Up"
|
50
|
-
msgstr ""
|
51
|
-
|
52
|
-
#: models/scout_plugin_trigger.rb:14
|
53
|
-
msgid "Down"
|
54
|
-
msgstr ""
|
55
|
-
|
56
|
-
#: models/scout_plugin_trigger.rb:15
|
57
|
-
msgid "Either"
|
58
|
-
msgstr ""
|
59
|
-
|
60
|
-
#: models/scout_plugin_trigger.rb:20 views/trigger_edit.shtml:76
|
61
|
-
msgid "yesterday's average"
|
62
|
-
msgstr ""
|
63
|
-
|
64
|
-
#: models/scout_plugin_trigger.rb:21 views/trigger_edit.shtml:79
|
65
|
-
msgid "previous 7-day average"
|
66
|
-
msgstr ""
|
67
|
-
|
68
|
-
#: models/scout_plugin_trigger.rb:22 views/trigger_edit.shtml:82
|
69
|
-
msgid "preceding window"
|
70
|
-
msgstr ""
|
71
|
-
|
72
|
-
#: models/scout_plugin_trigger.rb:25
|
73
|
-
msgid "normal"
|
74
|
-
msgstr ""
|
75
|
-
|
76
|
-
#: models/scout_plugin_trigger.rb:26
|
77
|
-
msgid "fired"
|
78
|
-
msgstr ""
|
79
|
-
|
80
|
-
#: models/scout_plugin_trigger.rb:90 models/scout_plugin_trigger.rb:98
|
81
|
-
msgid "%d minutes"
|
82
|
-
msgstr ""
|
83
|
-
|
84
|
-
#: models/scout_plugin_trigger.rb:108
|
85
|
-
msgid "Alert me when %s exceeds %s"
|
86
|
-
msgstr ""
|
87
|
-
|
88
|
-
#: models/scout_plugin_trigger.rb:110
|
89
|
-
msgid ""
|
90
|
-
"Alert me when %s goes %s more than %s over the preceding %s (relative to %"
|
91
|
-
"s), \n"
|
92
|
-
" as long as the value is at least %s"
|
93
|
-
msgstr ""
|
94
|
-
|
95
|
-
#: models/scout_plugin_trigger.rb:116
|
96
|
-
msgid "Alert me when %s stays above %s for %s or more"
|
97
|
-
msgstr ""
|
98
|
-
|
99
|
-
#: views/admin.layout.shtml:5
|
100
|
-
msgid "\"Administration\""
|
101
|
-
msgstr ""
|
102
|
-
|
103
|
-
#: views/customer.shtml:6
|
104
|
-
msgid "New customer"
|
105
|
-
msgstr ""
|
106
|
-
|
107
|
-
#: views/customer.shtml:8 views/servant.shtml:6
|
108
|
-
msgid "Edit"
|
109
|
-
msgstr ""
|
110
|
-
|
111
|
-
#: views/customer.shtml:21 views/index.shtml:3 views/master.layout.shtml:19
|
112
|
-
msgid "Servants"
|
113
|
-
msgstr ""
|
114
|
-
|
115
|
-
#: views/customer.shtml:21 views/customer.shtml:32 views/customers.shtml:3
|
116
|
-
#: views/plugin_instance.shtml:20
|
117
|
-
msgid "Add"
|
118
|
-
msgstr ""
|
119
|
-
|
120
|
-
#: views/customer.shtml:32
|
121
|
-
msgid "Installations"
|
122
|
-
msgstr ""
|
123
|
-
|
124
|
-
#: views/installation.shtml:3
|
125
|
-
msgid "Back to customer"
|
126
|
-
msgstr ""
|
127
|
-
|
128
|
-
#: views/installation.shtml:6
|
129
|
-
msgid "New installation for %s"
|
130
|
-
msgstr ""
|
131
|
-
|
132
|
-
#: views/installation.shtml:9 views/plugin_edit.shtml:10
|
133
|
-
msgid "Name"
|
134
|
-
msgstr ""
|
135
|
-
|
136
|
-
#: views/installation.shtml:16
|
137
|
-
msgid "Installation \"%s\" for %s"
|
138
|
-
msgstr ""
|
139
|
-
|
140
|
-
#: views/installation.shtml:18
|
141
|
-
msgid "Edit installation"
|
142
|
-
msgstr ""
|
143
|
-
|
144
|
-
#: views/installation.shtml:20
|
145
|
-
msgid "Apps"
|
146
|
-
msgstr ""
|
147
|
-
|
148
|
-
#: views/installation.shtml:28
|
149
|
-
msgid "Save"
|
150
|
-
msgstr ""
|
151
|
-
|
152
|
-
#: views/installation.shtml:32
|
153
|
-
msgid "Targets"
|
154
|
-
msgstr ""
|
155
|
-
|
156
|
-
#: views/master.layout.shtml:17
|
157
|
-
msgid "Home"
|
158
|
-
msgstr ""
|
159
|
-
|
160
|
-
#: views/plugin_edit.shtml:3
|
161
|
-
msgid "Edit plugin \"%s\""
|
162
|
-
msgstr ""
|
163
|
-
|
164
|
-
#: views/plugin_edit.shtml:4
|
165
|
-
msgid "Back to plugin details"
|
166
|
-
msgstr ""
|
167
|
-
|
168
|
-
#: views/plugin_edit.shtml:15
|
169
|
-
msgid "Settings"
|
170
|
-
msgstr ""
|
171
|
-
|
172
|
-
#: views/plugin_edit.shtml:28
|
173
|
-
msgid "Advanced options"
|
174
|
-
msgstr ""
|
175
|
-
|
176
|
-
#: views/plugin_edit.shtml:30
|
177
|
-
msgid "Interval"
|
178
|
-
msgstr ""
|
179
|
-
|
180
|
-
#: views/plugin_edit.shtml:34
|
181
|
-
msgid "Timeout"
|
182
|
-
msgstr ""
|
183
|
-
|
184
|
-
#: views/plugin_edit.shtml:38
|
185
|
-
msgid "Update"
|
186
|
-
msgstr ""
|
187
|
-
|
188
|
-
#: views/plugin_instance.shtml:4
|
189
|
-
msgid "Edit settings"
|
190
|
-
msgstr ""
|
191
|
-
|
192
|
-
#: views/plugin_instance.shtml:8 views/trigger_edit.shtml:12
|
193
|
-
msgid "Servant"
|
194
|
-
msgstr ""
|
195
|
-
|
196
|
-
#: views/plugin_instance.shtml:12 views/servant.shtml:14
|
197
|
-
#: views/trigger_edit.shtml:8
|
198
|
-
msgid "Customer"
|
199
|
-
msgstr ""
|
200
|
-
|
201
|
-
#: views/plugin_instance.shtml:20
|
202
|
-
msgid "Triggers"
|
203
|
-
msgstr ""
|
204
|
-
|
205
|
-
#: views/plugin_instance.shtml:25
|
206
|
-
msgid "edit"
|
207
|
-
msgstr ""
|
208
|
-
|
209
|
-
#: views/servant.shtml:23 views/servants.shtml:4
|
210
|
-
msgid "New servant"
|
211
|
-
msgstr ""
|
212
|
-
|
213
|
-
#: views/servant.shtml:23
|
214
|
-
msgid "for customer %s"
|
215
|
-
msgstr ""
|
216
|
-
|
217
|
-
#: views/servant.shtml:31
|
218
|
-
msgid "Plugins"
|
219
|
-
msgstr ""
|
220
|
-
|
221
|
-
#: views/servant.shtml:34
|
222
|
-
msgid "Add plugin"
|
223
|
-
msgstr ""
|
224
|
-
|
225
|
-
#: views/servant.shtml:49
|
226
|
-
msgid "Remove"
|
227
|
-
msgstr ""
|
228
|
-
|
229
|
-
#: views/servant.shtml:57
|
230
|
-
msgid "Servant %s"
|
231
|
-
msgstr ""
|
232
|
-
|
233
|
-
#: views/servant.shtml:60
|
234
|
-
msgid "Last check"
|
235
|
-
msgstr ""
|
236
|
-
|
237
|
-
#: views/servant.shtml:65
|
238
|
-
msgid "Manage resources"
|
239
|
-
msgstr ""
|
240
|
-
|
241
|
-
#: views/servant.shtml:68
|
242
|
-
msgid "Resources"
|
243
|
-
msgstr ""
|
244
|
-
|
245
|
-
#: views/servant.shtml:81
|
246
|
-
msgid "System details"
|
247
|
-
msgstr ""
|
248
|
-
|
249
|
-
#: views/trigger_edit.shtml:3
|
250
|
-
msgid "Edit Trigger %s"
|
251
|
-
msgstr ""
|
252
|
-
|
253
|
-
#: views/trigger_edit.shtml:4
|
254
|
-
msgid "New Trigger for plugin %s"
|
255
|
-
msgstr ""
|
256
|
-
|
257
|
-
#: views/trigger_edit.shtml:16
|
258
|
-
msgid "Plugin"
|
259
|
-
msgstr ""
|
260
|
-
|
261
|
-
#: views/trigger_edit.shtml:20 views/trigger_edit.shtml:24
|
262
|
-
msgid "Data series"
|
263
|
-
msgstr ""
|
264
|
-
|
265
|
-
#: views/trigger_edit.shtml:30
|
266
|
-
msgid "Trigger type"
|
267
|
-
msgstr ""
|
268
|
-
|
269
|
-
#: views/trigger_edit.shtml:32
|
270
|
-
msgid "peak"
|
271
|
-
msgstr ""
|
272
|
-
|
273
|
-
#: views/trigger_edit.shtml:33
|
274
|
-
msgid "plateau"
|
275
|
-
msgstr ""
|
276
|
-
|
277
|
-
#: views/trigger_edit.shtml:34
|
278
|
-
msgid "trend"
|
279
|
-
msgstr ""
|
280
|
-
|
281
|
-
#: views/trigger_edit.shtml:42 views/trigger_edit.shtml:52
|
282
|
-
msgid "Max Value"
|
283
|
-
msgstr ""
|
284
|
-
|
285
|
-
#: views/trigger_edit.shtml:48
|
286
|
-
msgid "Duration"
|
287
|
-
msgstr ""
|
288
|
-
|
289
|
-
#: views/trigger_edit.shtml:49
|
290
|
-
msgid "minutes"
|
291
|
-
msgstr ""
|
292
|
-
|
293
|
-
#: views/trigger_edit.shtml:58
|
294
|
-
msgid "Trigger"
|
295
|
-
msgstr ""
|
296
|
-
|
297
|
-
#: views/trigger_edit.shtml:61
|
298
|
-
msgid "Alert me to changes going"
|
299
|
-
msgstr ""
|
300
|
-
|
301
|
-
#: views/trigger_edit.shtml:63
|
302
|
-
msgid "up"
|
303
|
-
msgstr ""
|
304
|
-
|
305
|
-
#: views/trigger_edit.shtml:64
|
306
|
-
msgid "down"
|
307
|
-
msgstr ""
|
308
|
-
|
309
|
-
#: views/trigger_edit.shtml:65
|
310
|
-
msgid "up or down"
|
311
|
-
msgstr ""
|
312
|
-
|
313
|
-
#: views/trigger_edit.shtml:69
|
314
|
-
msgid "during the span of"
|
315
|
-
msgstr ""
|
316
|
-
|
317
|
-
#: views/trigger_edit.shtml:73
|
318
|
-
msgid "relative to"
|
319
|
-
msgstr ""
|
320
|
-
|
321
|
-
#: views/trigger_edit.shtml:89
|
322
|
-
msgid "when change is at least"
|
323
|
-
msgstr ""
|
324
|
-
|
325
|
-
#: views/trigger_edit.shtml:93
|
326
|
-
msgid "Minimum Value"
|
327
|
-
msgstr ""
|
328
|
-
|
329
|
-
#: views/trigger_edit.shtml:98
|
330
|
-
msgid "Submit"
|
331
|
-
msgstr ""
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<div>
|
2
|
-
<h3>Servants</h3>
|
3
|
-
<div class="actions">
|
4
|
-
<a href="{ Master.url }/servants/new">_(New servant)</a>
|
5
|
-
</div>
|
6
|
-
<ul>
|
7
|
-
<li sp:each="@servants |servant|">
|
8
|
-
<a href="{ Master.url }/servants/{ servant.id }">{ servant.name }</a>
|
9
|
-
</li>
|
10
|
-
</ul>
|
11
|
-
</div>
|
File without changes
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Spider; module Servant; module Resources
|
2
|
-
|
3
|
-
class Mysql < Db
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def create_db(name)
|
8
|
-
return if db_exists?(name)
|
9
|
-
sql = "create database #{name}"
|
10
|
-
@storage.execute(sql)
|
11
|
-
end
|
12
|
-
|
13
|
-
def db_exists?(name)
|
14
|
-
sql = "select schema_name from information_schema.schemata where schema_name = '#{name}'"
|
15
|
-
res = @storage.execute(sql)
|
16
|
-
return res[0] ? true : false
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_user(name, password)
|
20
|
-
sql = "create user '#{name}'@'localhost' identified by '#{password}'"
|
21
|
-
@storage.execute(sql)
|
22
|
-
end
|
23
|
-
|
24
|
-
def grant_db_to_user(db_name, user)
|
25
|
-
sql = "grant all on #{db_name}.* to '#{user}'@'localhost'"
|
26
|
-
@storage.execute(sql)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.discovery(ip)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end; end; end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spiderfw'
|
2
|
-
|
3
|
-
module Spider; module Servant; module Resources
|
4
|
-
|
5
|
-
class Db < Resource
|
6
|
-
|
7
|
-
def self.get_resource(url)
|
8
|
-
matches = url.match(/^(.+?):\/\/(.+)/)
|
9
|
-
adapter = matches[1]
|
10
|
-
rest = matches[2]
|
11
|
-
if (adapter =~ /(.+):(.+)/)
|
12
|
-
connector = $1
|
13
|
-
adapter = $2
|
14
|
-
url = "#{adapter}://#{rest}"
|
15
|
-
end
|
16
|
-
case adapter
|
17
|
-
when 'sqlite'
|
18
|
-
class_name = :SQLite
|
19
|
-
when 'oci8'
|
20
|
-
class_name = :OCI8
|
21
|
-
when 'mysql'
|
22
|
-
class_name = :Mysql
|
23
|
-
when 'mssql'
|
24
|
-
class_name = :MSSQL
|
25
|
-
end
|
26
|
-
return Resources.const_get(class_name).new(url)
|
27
|
-
end
|
28
|
-
|
29
|
-
def initialize(url)
|
30
|
-
@storage = Spider::Model::Storage.get_storage('db', url)
|
31
|
-
end
|
32
|
-
|
33
|
-
# __.command :name => _('Create Db'), :params => [:name => String]
|
34
|
-
def create_db(name)
|
35
|
-
raise "Unimplemented"
|
36
|
-
end
|
37
|
-
|
38
|
-
def db_exists?(name)
|
39
|
-
raise "Unimplemented"
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_user(name, password)
|
43
|
-
raise "Unimplemented"
|
44
|
-
end
|
45
|
-
|
46
|
-
def grant_db_to_user(db_name, user)
|
47
|
-
raise "Unimplemented"
|
48
|
-
end
|
49
|
-
|
50
|
-
def resource_type
|
51
|
-
:db
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end; end; end
|
data/apps/servant/lib/servant.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'ohai'
|
3
|
-
require 'httpclient'
|
4
|
-
$SPIDER_SERVANT_LIB = File.dirname(__FILE__)
|
5
|
-
require "#{$SPIDER_SERVANT_LIB}/resource"
|
6
|
-
require "#{$SPIDER_SERVANT_LIB}/resources/db"
|
7
|
-
require "#{$SPIDER_SERVANT_LIB}/resources/db/mysql"
|
8
|
-
|
9
|
-
module Spider
|
10
|
-
|
11
|
-
module Servant
|
12
|
-
|
13
|
-
class Servant
|
14
|
-
DEFAULTS = {
|
15
|
-
:config_file => '/etc/spider/servant.yml'
|
16
|
-
}
|
17
|
-
|
18
|
-
def initialize(config_file=nil)
|
19
|
-
@config = {
|
20
|
-
:server_url => 'http://localhost:8989/spider/master'
|
21
|
-
}
|
22
|
-
config_file ||= Servant::DEFAULTS[:config_file] if File.exists?(Servant::DEFAULTS[:config_file])
|
23
|
-
if config_file
|
24
|
-
y = YAML::load_file(config_file)
|
25
|
-
@config.merge!(y)
|
26
|
-
end
|
27
|
-
ohai = Ohai::System.new
|
28
|
-
ohai.all_plugins
|
29
|
-
@ohai = ohai
|
30
|
-
@config[:servant_id] ||= ohai["hostname"]
|
31
|
-
@config[:servant_name] ||= @config[:servant_id]
|
32
|
-
create_resources
|
33
|
-
end
|
34
|
-
|
35
|
-
def ping_server(url=nil)
|
36
|
-
url ||= @config[:server_url]
|
37
|
-
@system_status = @ohai.to_json
|
38
|
-
clnt = HTTPClient.new
|
39
|
-
res = clnt.post("#{url}/ping", Spider::HTTP.params_to_hash(self.description))
|
40
|
-
JSON.parse(res)
|
41
|
-
if res[:commands]
|
42
|
-
res[:commands].each do |command|
|
43
|
-
command_result = execute_command(command[:name], command[:arguments])
|
44
|
-
clnt.post()
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_resources
|
50
|
-
@resources = {}
|
51
|
-
return unless @config['resources'].is_a?(Hash)
|
52
|
-
@config['resources'].each do |res_type, hash|
|
53
|
-
@resources[res_type] ||= {}
|
54
|
-
case res_type
|
55
|
-
when 'db'
|
56
|
-
hash.each do |res_name, params|
|
57
|
-
@resources[res_type][res_name] = Resources::Db.get_resource(params['url'])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def description
|
64
|
-
{
|
65
|
-
:servant_id => @config[:servant_id],
|
66
|
-
:servant_name => @config[:servant_name],
|
67
|
-
:system_status => @system_status,
|
68
|
-
:resources => resources_description
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
def resources_description
|
73
|
-
desc = {}
|
74
|
-
@resources.each do |type, type_resources|
|
75
|
-
desc[type] ||= {}
|
76
|
-
type_resources.each do |name, resource|
|
77
|
-
desc[type][name] = {
|
78
|
-
:description => resource.description.to_json
|
79
|
-
}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
# Logfile created on Mon Apr 12 15:39:53 +0200 2010 by /
|