CO - bug fix filter agents/actors

community
Gogs 7 years ago
parent dabf772217
commit bcb3a87777

@ -46,8 +46,14 @@ class Actor():
"""
pass
def getName(self):
return self.__class__.__name__.lower()
def getIdentifier(self):
return self.__class__.__name__.lower()
def init(self,args):
self.config = args
@ -89,7 +95,7 @@ class Apps(Actor) :
This function is intended to determine if it is possible to boot an application
"""
items = self.ng.search(name)
items = self.ng.search(name) if self.ng is not None else []
if len(items) == 0 :
return False
else:
@ -105,7 +111,6 @@ class Apps(Actor) :
cmd = " ".join([app,args,"&" ])
self.execute([app,args])
print [app,args]
def kill(self,name) :
"""
@ -121,7 +126,7 @@ class Apps(Actor) :
This function is designed to analyze a few logs and take appropriate action
@param logs logs of application/process data; folder analysis or sandbox analysis
"""
for item in self.logs :
for item in logs :
name = item['label']
if self.can_start(name) :
self.startup(name)

@ -32,7 +32,6 @@ class Manager() :
self.config = args['config']
self.key = args['key']
self.actors = args['actors']
self.status() #-- Initializing status information
def status(self) :
@ -56,8 +55,38 @@ class Manager() :
self.LIMIT = -1
self.filter(meta)
if len(self.actors) > 0 :
self.setup(meta)
self._filter('scope','apps',meta,self.agents)
self._filter('','folders',meta,self.agents)
#if len(self.actors) > 0 :
# self.setup(meta)
def _filter(self,id,key,meta,values):
"""
This function is designed to perform a filter on a list of values given a full set
@param id
@param lvalues
@param values
"""
read_class = self.config['store']['class']['read']
read_args = self.config['store']['args']
couchdb = self.factory.instance(type=read_class,args=read_args)
info = couchdb.view('config/'+key,key=self.key)
if info is None or (type(info) == list and len(info) == 0) :
return []
else:
#
# At this point we have a configuration we can keep apps/folders actors
#
r = []
plan = meta[id]
for item in values :
if item.getName() in plan :
item.init(info)
r.append(item)
def filter(self,meta) :
scope = []
@ -69,23 +98,28 @@ class Manager() :
self.agents = [agent for agent in self.agents if agent.getName() in scope]
if len(lactors) == 0 :
self.actors = []
self.actors = [ actor for actor in self.actors if actor.geIdentifier() in lactors]
self.actors = [ actor for actor in self.actors if actor.getIdentifier() in lactors]
if len(self.actors) > 0 :
#
# We should configure the actors accordingly and make sure they are operational
#
conf = {"folders":meta['folder_threshold'],"apps":None}
conf = {"apps":None}
#
# We need to get the configuration for the apps remotely
#
read_class = self.config['store']['class']['read']
read_args = self.config['store']['args']
couchdb = self.factory.instance(type=read_class,args=read_args)
uinfo = couchdb.view('config/apps',key=self.key)
if 'apps' in uinfo :
conf['apps'] = uinfo['apps']
#
# Threshold will always give a default value
#
info = couchdb.view('config/folders',key=self.key)
threshold = info
conf['folder_threshold'] = threshold
mailer = None
for actor in self.actors :
@ -118,6 +152,9 @@ class Manager() :
if 'apps' in uinfo :
conf['apps'] = uinfo['apps']
for agent in self.agents :
agent.init(conf['apps'])
mailer = None
for actor in self.actors :
id = actor.getIdentifier()
@ -183,9 +220,10 @@ class Manager() :
#
#
index = self.agents.index(agent)
if len(self.actors) > index and self.actors[index].getIdentifier() == agent.getName() :
actor = self.actors[index]
print self.analyze(row)
print actor.analyze(row)
self.lock.acquire()
store = self.factory.instance(type=write_class,args=read_args)

Loading…
Cancel
Save