|
|
@ -32,7 +32,6 @@ class Manager() :
|
|
|
|
self.config = args['config']
|
|
|
|
self.config = args['config']
|
|
|
|
self.key = args['key']
|
|
|
|
self.key = args['key']
|
|
|
|
self.actors = args['actors']
|
|
|
|
self.actors = args['actors']
|
|
|
|
|
|
|
|
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
|
|
|
|
|
|
|
|
def status(self) :
|
|
|
|
def status(self) :
|
|
|
@ -56,8 +55,38 @@ class Manager() :
|
|
|
|
self.LIMIT = -1
|
|
|
|
self.LIMIT = -1
|
|
|
|
|
|
|
|
|
|
|
|
self.filter(meta)
|
|
|
|
self.filter(meta)
|
|
|
|
if len(self.actors) > 0 :
|
|
|
|
self._filter('scope','apps',meta,self.agents)
|
|
|
|
self.setup(meta)
|
|
|
|
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) :
|
|
|
|
def filter(self,meta) :
|
|
|
|
scope = []
|
|
|
|
scope = []
|
|
|
@ -69,23 +98,28 @@ class Manager() :
|
|
|
|
self.agents = [agent for agent in self.agents if agent.getName() in scope]
|
|
|
|
self.agents = [agent for agent in self.agents if agent.getName() in scope]
|
|
|
|
if len(lactors) == 0 :
|
|
|
|
if len(lactors) == 0 :
|
|
|
|
self.actors = []
|
|
|
|
self.actors = []
|
|
|
|
|
|
|
|
self.actors = [ actor for actor in self.actors if actor.getIdentifier() in lactors]
|
|
|
|
self.actors = [ actor for actor in self.actors if actor.geIdentifier() in lactors]
|
|
|
|
|
|
|
|
if len(self.actors) > 0 :
|
|
|
|
if len(self.actors) > 0 :
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# We should configure the actors accordingly and make sure they are operational
|
|
|
|
# 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
|
|
|
|
# We need to get the configuration for the apps remotely
|
|
|
|
#
|
|
|
|
#
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
|
|
|
|
|
|
|
|
couchdb = self.factory.instance(type=read_class,args=read_args)
|
|
|
|
couchdb = self.factory.instance(type=read_class,args=read_args)
|
|
|
|
uinfo = couchdb.view('config/apps',key=self.key)
|
|
|
|
uinfo = couchdb.view('config/apps',key=self.key)
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
conf['apps'] = uinfo['apps']
|
|
|
|
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
|
|
|
|
mailer = None
|
|
|
|
for actor in self.actors :
|
|
|
|
for actor in self.actors :
|
|
|
@ -118,6 +152,9 @@ class Manager() :
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
if 'apps' in uinfo :
|
|
|
|
conf['apps'] = uinfo['apps']
|
|
|
|
conf['apps'] = uinfo['apps']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for agent in self.agents :
|
|
|
|
|
|
|
|
agent.init(conf['apps'])
|
|
|
|
|
|
|
|
|
|
|
|
mailer = None
|
|
|
|
mailer = None
|
|
|
|
for actor in self.actors :
|
|
|
|
for actor in self.actors :
|
|
|
|
id = actor.getIdentifier()
|
|
|
|
id = actor.getIdentifier()
|
|
|
@ -183,9 +220,10 @@ class Manager() :
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
index = self.agents.index(agent)
|
|
|
|
index = self.agents.index(agent)
|
|
|
|
|
|
|
|
|
|
|
|
if len(self.actors) > index and self.actors[index].getIdentifier() == agent.getName() :
|
|
|
|
if len(self.actors) > index and self.actors[index].getIdentifier() == agent.getName() :
|
|
|
|
actor = self.actors[index]
|
|
|
|
actor = self.actors[index]
|
|
|
|
print self.analyze(row)
|
|
|
|
print actor.analyze(row)
|
|
|
|
|
|
|
|
|
|
|
|
self.lock.acquire()
|
|
|
|
self.lock.acquire()
|
|
|
|
store = self.factory.instance(type=write_class,args=read_args)
|
|
|
|
store = self.factory.instance(type=write_class,args=read_args)
|
|
|
|