sfpagent 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sfpagent might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/sfpagent/agent.rb +18 -10
- data/lib/sfpagent/bsig.rb +12 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a46954e0baa7fad3685faae5e88b9a2f7d769f
|
4
|
+
data.tar.gz: edf671fc44ffb00b0067bd09e1a7f59f051a2719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4c45a2879ea273dd9ca19151ab01cfaada5475eadd81df40306be9856a2d4b46b17bba81e7babafaa8afdc704d713f4ed383ae4e13ee894acaa74bfb4f7d05
|
7
|
+
data.tar.gz: 3ada473126c4d2a3bde62295d255977c173f2de73d7bd6e7df80255482cc32a27480699f003f6b031dbeec1d6a3a8152a461929baed3632a9a6c0f942565d8ec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.9
|
data/lib/sfpagent/agent.rb
CHANGED
@@ -676,13 +676,16 @@ module Sfp
|
|
676
676
|
# Process HTTP GET request
|
677
677
|
#
|
678
678
|
# uri:
|
679
|
-
# /pid
|
680
|
-
# /state
|
681
|
-
# /model
|
682
|
-
# /
|
683
|
-
# /
|
684
|
-
# /
|
685
|
-
# /
|
679
|
+
# /pid => save daemon's PID to a file (only requested from localhost)
|
680
|
+
# /state => return the current state
|
681
|
+
# /model => return the current model
|
682
|
+
# /model/cache => return the cached model
|
683
|
+
# /sfp => return the SFP description of a module
|
684
|
+
# /modules => return a list of available modules
|
685
|
+
# /agents => return a list of agents database
|
686
|
+
# /log => return last 100 lines of log file
|
687
|
+
# /bsig => return BSig model
|
688
|
+
# /bsig/flaws => return flaws of BSig model
|
686
689
|
#
|
687
690
|
def do_GET(request, response)
|
688
691
|
status = 400
|
@@ -713,7 +716,12 @@ module Sfp
|
|
713
716
|
status, content_type, body = self.get_cache_model({:name => path[13, path.length-13]})
|
714
717
|
|
715
718
|
elsif path == '/bsig'
|
716
|
-
status,
|
719
|
+
status, content_type, body = get_bsig
|
720
|
+
|
721
|
+
elsif path == '/bsig/flaws'
|
722
|
+
status = 200
|
723
|
+
content_type = 'application/json'
|
724
|
+
body = JSON.generate(Sfp::Agent.bsig_engine.get_flaws)
|
717
725
|
|
718
726
|
elsif path =~ /^\/sfp\/.+/
|
719
727
|
status, content_type, body = get_sfp({:module => path[10, path.length-10]})
|
@@ -803,7 +811,7 @@ module Sfp
|
|
803
811
|
status, content_type, body = self.set_bsig({:query => request.query})
|
804
812
|
|
805
813
|
elsif path == '/bsig/satisfier'
|
806
|
-
status, content_type, body = self.satisfy_bsig_request({:query => request.query})
|
814
|
+
status, content_type, body = self.satisfy_bsig_request({:query => request.query, :client => request.remote_ip})
|
807
815
|
|
808
816
|
end
|
809
817
|
end
|
@@ -1025,7 +1033,7 @@ module Sfp
|
|
1025
1033
|
return [500, '', ''] if Sfp::Agent.bsig_engine.nil?
|
1026
1034
|
|
1027
1035
|
req = p[:query]
|
1028
|
-
return [200, '', ''] if Sfp::Agent.bsig_engine.receive_goal_from_agent(req['id'].to_i, JSON[req['goal']], req['pi'].to_i)
|
1036
|
+
return [200, '', ''] if Sfp::Agent.bsig_engine.receive_goal_from_agent(req['id'].to_i, JSON[req['goal']], req['pi'].to_i, p[:client])
|
1029
1037
|
|
1030
1038
|
[500, '', '']
|
1031
1039
|
end
|
data/lib/sfpagent/bsig.rb
CHANGED
@@ -91,6 +91,16 @@ class Sfp::BSig
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
def get_flaws
|
95
|
+
bsig = Sfp::Agent.get_bsig
|
96
|
+
if bsig.nil?
|
97
|
+
{}
|
98
|
+
else
|
99
|
+
current = get_current_state
|
100
|
+
compute_flaws(bsig['goal'], current)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
94
104
|
def wait_for_satisfier?
|
95
105
|
total_satisfier = 1
|
96
106
|
loop do
|
@@ -271,7 +281,7 @@ class Sfp::BSig
|
|
271
281
|
true
|
272
282
|
end
|
273
283
|
|
274
|
-
def receive_goal_from_agent(id, goal, pi)
|
284
|
+
def receive_goal_from_agent(id, goal, pi, client='')
|
275
285
|
register_satisfier_thread
|
276
286
|
|
277
287
|
return false if not @enabled
|
@@ -283,7 +293,7 @@ class Sfp::BSig
|
|
283
293
|
status = nil
|
284
294
|
tries = MaxTries
|
285
295
|
begin
|
286
|
-
status = achieve_local_goal(bsig['id'], goal, bsig['operators'], pi,
|
296
|
+
status = achieve_local_goal(bsig['id'], goal, bsig['operators'], pi, "satisfier[#{client}]")
|
287
297
|
if status == :no_flaw or status == :failure or not @enabled
|
288
298
|
break
|
289
299
|
elsif status == :pending
|