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
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= 0.6.6
|
2
|
+
== 19 July, 2011
|
3
|
+
* Fix: use SEE_OTHER as default redirect code to avoid FF 5 caching
|
4
|
+
* Fix: follow symlinks in base paths
|
5
|
+
* Fix: reworked resource paths, views inclusion and extension now more reliable
|
6
|
+
* Tree mixin now has tree_position, ordering
|
7
|
+
* DB dumping
|
8
|
+
* Better process management
|
9
|
+
* Added bin/spider to default home
|
10
|
+
|
1
11
|
= 0.6.5
|
2
12
|
== 29 June, 2011
|
3
13
|
* Mapper fixes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.6
|
@@ -2,5 +2,5 @@ Spider.config_option 'app_server.url', _("Url of the app server"), :default => '
|
|
2
2
|
Spider.config_option 'app_server.search_paths', _("Paths to search for apps"), :type => Array
|
3
3
|
Spider.config_option 'app_server.git_ssh', _("Name of the ssh server")
|
4
4
|
Spider.config_option 'app_server.git_http', _("Http git prefix for each git path"), :type => Hash
|
5
|
-
|
6
|
-
|
5
|
+
Spider.config_option 'app_server.git_repo_base', _("Base path for read-only git repository access")
|
6
|
+
Spider.config_option 'app_server.git_repo_rw_base', _("Base path for read-write git repository access")
|
@@ -62,13 +62,9 @@ Spider::Template.define_named_asset 'jquery-ui-selectable', [
|
|
62
62
|
], :depends => ['jquery-ui-core']
|
63
63
|
|
64
64
|
Spider::Template.define_named_asset 'jquery-ui-sortable', [
|
65
|
-
[:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.sortable.js', Spider::Components]
|
65
|
+
[:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.sortable.js', Spider::Components]
|
66
66
|
], :depends => ['jquery-ui-core']
|
67
67
|
|
68
|
-
Spider::Template.define_named_asset 'jquery-ui-nestedSortable', [
|
69
|
-
[:js, 'js/jquery/plugins/jquery.ui.nestedSortable.js', Spider::Components],
|
70
|
-
], :depends => ['jquery-ui-sortable']
|
71
|
-
|
72
68
|
Spider::Template.define_named_asset 'jquery-ui-accordion', [
|
73
69
|
[:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.accordion.js', Spider::Components]
|
74
70
|
], :depends => ['jquery-ui-core']
|
@@ -4,9 +4,9 @@
|
|
4
4
|
<thead>
|
5
5
|
<tr>
|
6
6
|
<th colspan="7">
|
7
|
-
<a href="{ @request[:path] }?_w{ @widget[:
|
7
|
+
<a href="{ @request[:path] }?_w{ @widget[:param_u] }%5Bd%5D={ @prev_link }"><span><<</span></a>
|
8
8
|
{ @current_month_name } { @year }
|
9
|
-
<a href="{ @request[:path] }?_w{ @widget[:
|
9
|
+
<a href="{ @request[:path] }?_w{ @widget[:param_u] }%5Bd%5D={ @next_link }"><span>>></span></a>
|
10
10
|
</th>
|
11
11
|
</tr>
|
12
12
|
<tr>
|
@@ -21,4 +21,4 @@
|
|
21
21
|
</tr>
|
22
22
|
</tbody>
|
23
23
|
</table>
|
24
|
-
</div>
|
24
|
+
</div>
|
@@ -90,6 +90,7 @@ module Spider; module Components
|
|
90
90
|
@model.elements_array.each{ |el| @scene.sortable[el.name] = @model.mapper.sortable?(el) ? true : false }
|
91
91
|
@scene.labels = {}
|
92
92
|
@elements.each do |el|
|
93
|
+
raise "No element #{el} in #{@model} for table #{@id}" unless @model.elements[el]
|
93
94
|
@scene.labels[el] = @model.elements[el].label
|
94
95
|
end
|
95
96
|
@rows = prepare_queryset(@queryset ? @queryset : @model.list)
|
@@ -138,6 +139,7 @@ module Spider; module Components
|
|
138
139
|
sub = sub.get(element.attributes[:junction_their_element])
|
139
140
|
end
|
140
141
|
sub_desc = sub.nil? ? '' : sub.to_s
|
142
|
+
sub_desc ||= ''
|
141
143
|
sub_desc = sub_desc[0..@attributes[:max_element_length]] if sub_desc.length > @attributes[:max_element_length]
|
142
144
|
list += "<li>"+sub_desc+"</li>" unless sub_desc.empty?
|
143
145
|
}
|
@@ -16,13 +16,16 @@ module Spider; module Components
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def prepare
|
19
|
-
|
19
|
+
@active_tab = params['tab']
|
20
|
+
@active_tab ||= transient_session[:tab]
|
20
21
|
@active_tab ||= @tabs.first
|
22
|
+
transient_session[:tab] = @active_tab
|
21
23
|
@scene << {
|
22
24
|
:active_tab => @active_tab,
|
23
25
|
:tabs => @tabs,
|
24
26
|
:tabs_labels => @tabs_labels
|
25
27
|
}
|
28
|
+
super
|
26
29
|
end
|
27
30
|
|
28
31
|
def self.parse_content(doc)
|
@@ -32,7 +35,7 @@ module Spider; module Components
|
|
32
35
|
tabs_override = '<tpl:override search="#tabs_content">'
|
33
36
|
doc.search('tab').each do |tab|
|
34
37
|
tab_id = tab.get_attribute('id')
|
35
|
-
tabs_override += '<div sp:if="@active_tab == \''+tab_id+'\'>'
|
38
|
+
tabs_override += '<div sp:if="@active_tab == \''+tab_id+'\'">'
|
36
39
|
tabs_override += '<sp:parent-context>'
|
37
40
|
tabs_override += tab.innerHTML
|
38
41
|
tabs_override += '</sp:parent-context>'
|
@@ -40,7 +43,7 @@ module Spider; module Components
|
|
40
43
|
tab.innerHTML = ''
|
41
44
|
end
|
42
45
|
tabs_override += '</tpl:override>'
|
43
|
-
overrides << Hpricot(tabs_override).root
|
46
|
+
overrides << Hpricot.XML(tabs_override).root
|
44
47
|
return doc.to_s, overrides
|
45
48
|
end
|
46
49
|
|
@@ -50,6 +53,9 @@ module Spider; module Components
|
|
50
53
|
doc.search('tab').each do |tab|
|
51
54
|
tab_id = tab.get_attribute('id')
|
52
55
|
label = tab.get_attribute('label')
|
56
|
+
if label =~ /_\((.+)\)/
|
57
|
+
label = _($1)
|
58
|
+
end
|
53
59
|
add_tab(tab_id, label)
|
54
60
|
end
|
55
61
|
return doc
|
data/apps/master/_init.rb
CHANGED
@@ -13,7 +13,9 @@ require 'apps/master/master'
|
|
13
13
|
|
14
14
|
require 'apps/master/models/admin'
|
15
15
|
require 'apps/master/models/customer'
|
16
|
-
require 'apps/master/models/
|
16
|
+
require 'apps/master/models/installation'
|
17
|
+
require 'apps/master/models/remote_log'
|
18
|
+
require 'apps/master/models/server'
|
17
19
|
require 'apps/master/models/scout_plugin_info'
|
18
20
|
require 'apps/master/models/scout_plugin_instance'
|
19
21
|
require 'apps/master/models/scout_report'
|
data/apps/master/cmd.rb
CHANGED
@@ -27,7 +27,7 @@ module Spider; module Master
|
|
27
27
|
if @instance_id
|
28
28
|
instances = [@instance_id]
|
29
29
|
elsif @server_id
|
30
|
-
instances = ScoutPluginInstance.where{ |i| (i.
|
30
|
+
instances = ScoutPluginInstance.where{ |i| (i.server == @server_id) }.map{ |i| i.id }
|
31
31
|
# else
|
32
32
|
# instances = ScoutPluginInstance.all.map{ |i| i.id }
|
33
33
|
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
require 'apps/master/controllers/
|
1
|
+
require 'apps/master/controllers/server_controller'
|
2
2
|
require 'apps/master/controllers/login_controller'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
|
5
6
|
module Spider; module Master
|
@@ -11,13 +12,13 @@ module Spider; module Master
|
|
11
12
|
layout 'master'
|
12
13
|
|
13
14
|
route /customers\/(\d+)\/installations\//, :installations
|
14
|
-
route /customers\/(\d+)\/
|
15
|
-
route /
|
16
|
-
route /
|
17
|
-
#route /
|
15
|
+
route /customers\/(\d+)\/servers\//, :servers
|
16
|
+
route /servers\/(\d+)\/plugins\/(\d+)(?:\/(\w+))?(?:\/(.+))?/, :plugin_instance
|
17
|
+
route /servers\/(\d+)\/sites\/(\d+|new|create)(?:\/(\w+))?(?:\/(.+))?/, :site
|
18
|
+
#route /servers\/([^\/]+)/, ServerController, :do => lambda{ |id| @request.misc[:server] = Server.new(id) }
|
18
19
|
route 'login', LoginController
|
19
20
|
|
20
|
-
require_user Master::Admin, :unless => [:login, :admin], :redirect => 'login'
|
21
|
+
require_user Master::Admin, :unless => [:login, :admin, :ping], :redirect => 'login'
|
21
22
|
require_user Spider::Auth::SuperUser, :only => [:admin]
|
22
23
|
|
23
24
|
|
@@ -34,6 +35,8 @@ module Spider; module Master
|
|
34
35
|
customers = @user.customers
|
35
36
|
if customers.length == 1
|
36
37
|
redirect "customers/#{customers[0].id}"
|
38
|
+
else
|
39
|
+
redirect "customers"
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
@@ -51,21 +54,21 @@ module Spider; module Master
|
|
51
54
|
trigger = @trigger
|
52
55
|
instance = @instance
|
53
56
|
instance ||= trigger.instance if trigger
|
54
|
-
|
55
|
-
|
57
|
+
server = @server
|
58
|
+
server ||= instance.server if instance
|
56
59
|
customer = @customer
|
57
|
-
customer ||=
|
60
|
+
customer ||= server.customer if server
|
58
61
|
@navigation << { :url => "#{Master.url}/customers/#{customer.id}", :name => customer.name } if customer
|
59
|
-
@navigation << { :url => "#{Master.url}/customers/#{customer.id}/
|
60
|
-
@navigation << { :url => "#{Master.url}/
|
62
|
+
@navigation << { :url => "#{Master.url}/customers/#{customer.id}/server/#{server.id}", :name => server.name } if server
|
63
|
+
@navigation << { :url => "#{Master.url}/servers/#{server.id}/plugins/#{instance.id}", :name => instance.name } if instance
|
61
64
|
@navigation << {
|
62
|
-
:url => "#{Master.url}/
|
65
|
+
:url => "#{Master.url}/servers/#{server.id}/plugins/#{instance.id}/triggers/#{trigger.id}",
|
63
66
|
:name => "#{_('Trigger')} #{trigger.label}"
|
64
67
|
} if trigger
|
65
68
|
@scene << {
|
66
69
|
:trigger => trigger,
|
67
70
|
:instance => instance,
|
68
|
-
:
|
71
|
+
:server => server,
|
69
72
|
:customer => customer
|
70
73
|
}
|
71
74
|
super
|
@@ -75,7 +78,7 @@ module Spider; module Master
|
|
75
78
|
customer = nil
|
76
79
|
if obj.is_a?(Customer)
|
77
80
|
customer = obj
|
78
|
-
elsif obj.is_a?(
|
81
|
+
elsif obj.is_a?(Server)
|
79
82
|
customer = obj.customer
|
80
83
|
end
|
81
84
|
raise Spider::Auth::Unauthorized.new(_("No customer")) if !customer && !@user.global?
|
@@ -109,86 +112,96 @@ module Spider; module Master
|
|
109
112
|
|
110
113
|
|
111
114
|
__.html :template => 'installation'
|
112
|
-
def
|
113
|
-
@customer = load_customer(customer_id)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@
|
129
|
-
@
|
115
|
+
def installs(id=nil, customer_id=nil)
|
116
|
+
@customer = load_customer(customer_id) if customer_id
|
117
|
+
if id
|
118
|
+
@installation = Installation.new(id) unless id == 'new'
|
119
|
+
@scene.edit = (@request.params['_w'] && @request.params['_w'].key?('installation_form')) || @request.params.key?('edit') || id == 'new'
|
120
|
+
@scene.pk = id
|
121
|
+
|
122
|
+
# if id == 'new'
|
123
|
+
# if @request.params.key?('installation_create') && !@request.params['installation_name'].empty?
|
124
|
+
# i = Installation.new(:name => @request.params['installation_name'])
|
125
|
+
# i.customer = @customer
|
126
|
+
# i.save
|
127
|
+
# redirect(File.dirname(@request.path)+"/#{i.id}")
|
128
|
+
# end
|
129
|
+
# else
|
130
|
+
# if @request.params.key?('save_apps')
|
131
|
+
# @installation.apps = @request.params['apps'].keys.join(',')
|
132
|
+
# @installation.save
|
133
|
+
# redirect(request.path)
|
134
|
+
# end
|
135
|
+
# @scene.install_apps = JSON.parse(@installation.apps) unless @installation.apps.blank?
|
136
|
+
# @scene.install_apps ||= []
|
137
|
+
# @scene.apps = Spider::AppServer.apps_by_id
|
138
|
+
# end
|
139
|
+
@scene.install_apps = JSON.parse(@installation.apps) unless @installation.apps.blank?
|
140
|
+
@scene.install_apps ||= []
|
141
|
+
@scene.apps = Spider::AppServer.apps_by_id
|
142
|
+
@scene.logs = RemoteLog.where(:installation => @installation)
|
143
|
+
@scene << {
|
144
|
+
:customer => @customer,
|
145
|
+
:installation => @installation
|
146
|
+
}
|
130
147
|
end
|
131
|
-
@scene << {
|
132
|
-
:customer => @customer,
|
133
|
-
:installation => @installation
|
134
|
-
}
|
135
148
|
end
|
136
149
|
|
137
150
|
__.html
|
138
|
-
def
|
151
|
+
def servers(id=nil, customer_id=nil)
|
139
152
|
customer_id ||= @request.params['customer']
|
140
153
|
customer_id ||= @user.customers[0] unless @user.global?
|
141
154
|
available_plugins = Master.scout_plugins.map{ |p| ScoutPlugin.new(p) }
|
142
155
|
@scene.available_plugins = available_plugins
|
143
156
|
if id
|
144
|
-
visual_params[:template] = '
|
145
|
-
@
|
146
|
-
check_access(@
|
147
|
-
@scene.edit = (@request.params['_w'] && @request.params['_w'].key?('
|
157
|
+
visual_params[:template] = 'server'
|
158
|
+
@server = Server.new(id) if id && id != 'new'
|
159
|
+
check_access(@server) if @server
|
160
|
+
@scene.edit = (@request.params['_w'] && @request.params['_w'].key?('server_form')) || @request.params.key?('edit') || id == 'new'
|
148
161
|
@scene.pk = id
|
149
162
|
get_template
|
150
|
-
if id == 'new' && @template.widgets[:
|
151
|
-
@template.widgets[:
|
163
|
+
if id == 'new' && @template.widgets[:server_form]
|
164
|
+
@template.widgets[:server_form].attributes[:auto_redirect] = Master.url+'/servers'
|
152
165
|
else
|
153
166
|
if @request.params['submit_add_plugin']
|
154
167
|
plugin = ScoutPlugin.new(@request.params['plugin'])
|
155
|
-
current = ScoutPluginInstance.where(:
|
168
|
+
current = ScoutPluginInstance.where(:server => @server, :plugin_id => plugin.id).total_rows
|
156
169
|
name = plugin.name
|
157
170
|
name += " #{current + 1}" if current > 0
|
158
|
-
instance = ScoutPluginInstance.create(:
|
159
|
-
@
|
160
|
-
@
|
171
|
+
instance = ScoutPluginInstance.create(:server => @server, :plugin_id => plugin.id, :name => name)
|
172
|
+
@server.scout_plan_changed = DateTime.now
|
173
|
+
@server.save
|
161
174
|
redirect(@request.path)
|
162
175
|
end
|
163
176
|
if @request.params['remove_plugin']
|
164
|
-
instance = ScoutPluginInstance.load(:id => @request.params['remove_plugin'], :
|
177
|
+
instance = ScoutPluginInstance.load(:id => @request.params['remove_plugin'], :server => id)
|
165
178
|
instance.delete if instance
|
166
|
-
@
|
167
|
-
@
|
179
|
+
@server.scout_plan_changed = DateTime.now
|
180
|
+
@server.save
|
168
181
|
redirect(@request.path)
|
169
182
|
end
|
170
183
|
end
|
171
184
|
if customer_id
|
172
185
|
@customer = Customer.new(customer_id)
|
173
|
-
if @template.widgets[:
|
174
|
-
@template.widgets[:
|
175
|
-
@template.widgets[:
|
186
|
+
if @template.widgets[:server_form]
|
187
|
+
@template.widgets[:server_form].attributes[:auto_redirect] = Master.url+"/customers/#{customer_id}"
|
188
|
+
@template.widgets[:server_form].fixed = {:customer => @customer}
|
176
189
|
end
|
177
190
|
end
|
178
191
|
else
|
179
|
-
@scene.
|
192
|
+
@scene.servers = Server.all
|
180
193
|
if customer_id
|
181
|
-
@scene.
|
194
|
+
@scene.servers.where(:customer => @request.params['customer'])
|
182
195
|
end
|
183
|
-
visual_params[:template] = '
|
196
|
+
visual_params[:template] = 'servers'
|
184
197
|
end
|
185
198
|
end
|
186
199
|
|
187
200
|
__.html
|
188
|
-
def plugin_instance(
|
189
|
-
instance = ScoutPluginInstance.load(:id => id, :
|
190
|
-
raise NotFound.new("Plugin #{id} for
|
191
|
-
@
|
201
|
+
def plugin_instance(server_id, id, action=nil, sub_action=nil)
|
202
|
+
instance = ScoutPluginInstance.load(:id => id, :server => server_id)
|
203
|
+
raise NotFound.new("Plugin #{id} for server #{server_id}") unless instance
|
204
|
+
@server = Server.new(:id => server_id)
|
192
205
|
@scene.plugin = instance.plugin
|
193
206
|
fields = []
|
194
207
|
last = instance.last_reported
|
@@ -215,7 +228,7 @@ module Spider; module Master
|
|
215
228
|
redirect @request.path
|
216
229
|
end
|
217
230
|
if action == "edit"
|
218
|
-
plugin_edit(@
|
231
|
+
plugin_edit(@server, @scene.plugin, @instance)
|
219
232
|
elsif action == "triggers"
|
220
233
|
trigger_edit(sub_action)
|
221
234
|
elsif action == "data"
|
@@ -226,10 +239,10 @@ module Spider; module Master
|
|
226
239
|
end
|
227
240
|
|
228
241
|
__.html
|
229
|
-
def site(
|
242
|
+
def site(server_id, id, action=nil, sub_action=nil)
|
230
243
|
if @request.params['submit']
|
231
244
|
end
|
232
|
-
@
|
245
|
+
@server = Server.new(server_id)
|
233
246
|
@scene.site_type = @request.params['site_type']
|
234
247
|
if @request.params['edit'] || id == 'new' || id == 'create'
|
235
248
|
render('site_edit')
|
@@ -239,14 +252,14 @@ module Spider; module Master
|
|
239
252
|
end
|
240
253
|
|
241
254
|
__.html
|
242
|
-
def plugin_edit(
|
255
|
+
def plugin_edit(server, plugin, instance)
|
243
256
|
if @request.params['submit']
|
244
257
|
instance.name = @request.params['name']
|
245
258
|
instance.settings = @request.params['settings']
|
246
259
|
instance.poll_interval = @request.params['poll_interval'] unless @request.params['poll_interval'].blank?
|
247
260
|
instance.timeout = @request.params['timeout'] unless @request.params['timeout'].blank?
|
248
261
|
instance.save
|
249
|
-
redirect("#{Master.url}/
|
262
|
+
redirect("#{Master.url}/server/#{@server.id}/plugins/#{@instance.id}")
|
250
263
|
end
|
251
264
|
render('plugin_edit')
|
252
265
|
end
|
@@ -259,7 +272,7 @@ module Spider; module Master
|
|
259
272
|
trigger.data = @request.params['data_series']
|
260
273
|
else
|
261
274
|
trigger = ScoutPluginTrigger.load(:id => id, :plugin_instance => @instance)
|
262
|
-
raise NotFound.new("Trigger #{id} of
|
275
|
+
raise NotFound.new("Trigger #{id} of server #{@scene.server}") unless trigger
|
263
276
|
end
|
264
277
|
@trigger = trigger
|
265
278
|
if @request.params['submit'] && (id != 'new' || @request.params['data'])
|
@@ -268,7 +281,7 @@ module Spider; module Master
|
|
268
281
|
trigger.set(k, v) if trigger.class.elements[k.to_sym]
|
269
282
|
end
|
270
283
|
trigger.save
|
271
|
-
redirect("#{Master.url}/
|
284
|
+
redirect("#{Master.url}/server/#{@server.id}/plugins/#{@instance.id}")
|
272
285
|
end
|
273
286
|
render 'trigger_edit'
|
274
287
|
end
|
@@ -311,51 +324,42 @@ module Spider; module Master
|
|
311
324
|
$out << res.to_json
|
312
325
|
end
|
313
326
|
|
314
|
-
__.
|
327
|
+
__.json
|
315
328
|
def ping
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
servant = Master::Servant.static(:id => servant_id)
|
321
|
-
new_servant = true
|
329
|
+
install_id = @request.params['install_id']
|
330
|
+
unless install_id
|
331
|
+
Spider.logger.error("No install_id passed in ping")
|
332
|
+
done
|
322
333
|
end
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
res.resource_type = res_type
|
336
|
-
res.name = name
|
337
|
-
res.description = details['description']
|
338
|
-
res.save
|
339
|
-
resources << res
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
servant.resources = resources
|
344
|
-
if new_servant
|
345
|
-
servant.insert
|
346
|
-
else
|
347
|
-
servant.update
|
334
|
+
install = Spider::Master::Installation.load_or_create(:uuid => install_id)
|
335
|
+
install.last_check = DateTime.now
|
336
|
+
install.apps = @request.params['apps']
|
337
|
+
install.interval = @request.params['interval']
|
338
|
+
install.configuration = decompress_string(@request.params['configuration'])
|
339
|
+
install.save
|
340
|
+
log_lines = JSON.parse(@request.params['log'])
|
341
|
+
log_lines.each do |log|
|
342
|
+
time, level, desc = *log
|
343
|
+
time = Time.parse(time)
|
344
|
+
next if log[2] =~ /^Not found/
|
345
|
+
RemoteLog.create(:text => desc, :level => level, :time => time, :installation => install)
|
348
346
|
end
|
349
347
|
response = {
|
350
348
|
:pong => DateTime.new
|
351
349
|
}
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
end
|
350
|
+
# server.pending_commands.each do |command|
|
351
|
+
# response[:commands] ||= []
|
352
|
+
# response[:commands] << command.to_h
|
353
|
+
# end
|
356
354
|
$out << response.to_json
|
357
355
|
end
|
358
356
|
|
357
|
+
private
|
358
|
+
|
359
|
+
def decompress_string(str)
|
360
|
+
Zlib::GzipReader.new(StringIO.new(str)).read
|
361
|
+
end
|
362
|
+
|
359
363
|
end
|
360
364
|
|
361
365
|
end; end
|
@@ -5,16 +5,16 @@ module Spider; module Master
|
|
5
5
|
class ScoutController < Spider::PageController
|
6
6
|
|
7
7
|
route /([\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})/, self, :do => lambda{ |uuid|
|
8
|
-
@
|
8
|
+
@server = Server.load(:uuid => uuid)
|
9
9
|
@uuid = uuid
|
10
|
-
raise NotFound.new("
|
10
|
+
raise NotFound.new("Server #{uuid}") unless @server
|
11
11
|
}
|
12
12
|
|
13
13
|
|
14
14
|
__.json
|
15
15
|
def plan
|
16
|
-
last_modified = (@
|
17
|
-
@
|
16
|
+
last_modified = (@server.scout_plan_changed || @server.obj_modified).to_local_time
|
17
|
+
@server.scout_plugins.each do |instance|
|
18
18
|
stat = File.lstat(instance.plugin.rb_path)
|
19
19
|
mtime = stat.mtime
|
20
20
|
last_modified = mtime if mtime > last_modified
|
@@ -29,7 +29,7 @@ module Spider; module Master
|
|
29
29
|
raise HTTPStatus.new(Spider::HTTP::NOT_MODIFIED) if last_modified <= if_modified
|
30
30
|
end
|
31
31
|
@response.headers['Last-Modified'] = last_modified.httpdate
|
32
|
-
$out << @
|
32
|
+
$out << @server.scout_plan.to_json
|
33
33
|
end
|
34
34
|
|
35
35
|
|
@@ -73,7 +73,7 @@ module Spider; module Master
|
|
73
73
|
next if had_previous
|
74
74
|
subject = alert["fields"]["subject"]
|
75
75
|
instance = ScoutPluginInstance.new(alert["plugin_id"])
|
76
|
-
subject = "#{instance.
|
76
|
+
subject = "#{instance.server} - #{subject}"
|
77
77
|
alert = ScoutAlert.create(
|
78
78
|
:plugin_instance => alert["plugin_id"],
|
79
79
|
:subject => alert["fields"]["subject"],
|
@@ -94,7 +94,7 @@ module Spider; module Master
|
|
94
94
|
end
|
95
95
|
subject = err["fields"]["subject"]
|
96
96
|
instance = ScoutPluginInstance.new(err["plugin_id"])
|
97
|
-
subject = "#{instance.
|
97
|
+
subject = "#{instance.server} - #{subject}"
|
98
98
|
error = ScoutError.create(
|
99
99
|
:plugin_instance => err["plugin_id"],
|
100
100
|
:subject => err["fields"]["subject"],
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Spider; module Master
|
2
2
|
|
3
|
-
class
|
3
|
+
class ServerController < Spider::PageController
|
4
4
|
|
5
5
|
__.html
|
6
6
|
def index
|
7
|
-
@scene.
|
8
|
-
render('
|
7
|
+
@scene.server = @request.misc[:server]
|
8
|
+
render('server')
|
9
9
|
end
|
10
10
|
|
11
11
|
def resources
|
Binary file
|
data/apps/master/master.rb
CHANGED
@@ -14,16 +14,16 @@ module Spider
|
|
14
14
|
res
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.
|
17
|
+
def self.url_for_server(id)
|
18
18
|
id = id.id if id.is_a?(Spider::Model::BaseModel)
|
19
|
-
|
20
|
-
"#{self.url}/
|
19
|
+
server = Server.new(id)
|
20
|
+
"#{self.url}/servers/#{server.id}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.url_for_plugin(id)
|
24
24
|
id = id.id if id.is_a?(Spider::Model::BaseModel)
|
25
25
|
instance = ScoutPluginInstance.new(id)
|
26
|
-
"#{self.url}/
|
26
|
+
"#{self.url}/servers/#{instance.server.id}/plugins/#{id}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.add_site_type(type)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'apps/master/models/installation'
|
2
|
-
|
3
1
|
module Spider; module Master
|
4
2
|
|
5
3
|
class Customer < Spider::Model::Managed
|
@@ -7,7 +5,6 @@ module Spider; module Master
|
|
7
5
|
element :uuid, UUID
|
8
6
|
element :public_key, Text
|
9
7
|
element :private_key, Text
|
10
|
-
many :installs, Installation, :add_reverse => :customer
|
11
8
|
multiple_choice :admins, Master::Admin, :add_multiple_reverse => {:name => :customers, :association => :multiple_choice} do
|
12
9
|
element :receive_notifications, Bool, :default => true
|
13
10
|
element :manage_plugins, Bool, :default => true
|
@@ -1,9 +1,20 @@
|
|
1
1
|
module Spider; module Master
|
2
2
|
|
3
3
|
class Installation < Spider::Model::Managed
|
4
|
-
element :
|
5
|
-
element :
|
6
|
-
|
4
|
+
element :uuid, UUID
|
5
|
+
element :name, String, :label => _('Name')
|
6
|
+
choice :customer, Customer, :add_multiple_reverse => :installations
|
7
|
+
element :apps, Text, :hidden => true
|
8
|
+
element :configuration, Text, :hidden => true
|
9
|
+
element :last_check, DateTime, :hidden => true
|
10
|
+
element :interval, Fixnum, :hidden => true
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
str = self.name || self.uuid
|
14
|
+
if self.customer
|
15
|
+
str += " - #{self.customer}"
|
16
|
+
end
|
17
|
+
end
|
7
18
|
|
8
19
|
end
|
9
20
|
|