|
|
|
@ -28,9 +28,10 @@ class Manager() :
|
|
|
|
|
setattr(name,value)
|
|
|
|
|
def init(self,**args) :
|
|
|
|
|
self.id = args['node']
|
|
|
|
|
self.pool = args['pool']
|
|
|
|
|
self.agents = args['agents']
|
|
|
|
|
self.config = args['config']
|
|
|
|
|
self.key = args['key']
|
|
|
|
|
self.actors = args['actors']
|
|
|
|
|
|
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
|
|
|
|
|
@ -53,16 +54,76 @@ class Manager() :
|
|
|
|
|
else:
|
|
|
|
|
self.DELAY = -1
|
|
|
|
|
self.LIMIT = -1
|
|
|
|
|
|
|
|
|
|
def filter(meta) :
|
|
|
|
|
scope = []
|
|
|
|
|
lactors= []
|
|
|
|
|
for item in meta :
|
|
|
|
|
scope = scope + item['scope'].split(',')
|
|
|
|
|
if 'actors' in item :
|
|
|
|
|
lactors= lactors + item['actors'].split(',')
|
|
|
|
|
self.pool = [agent for agent in self.pool if agent.getName() in scope]
|
|
|
|
|
self.agents = [agent for agent in self.agents if agent.getName() in scope]
|
|
|
|
|
self.actors = [ actor for actor in self.actors if actor.getName() 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}
|
|
|
|
|
#
|
|
|
|
|
# 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']
|
|
|
|
|
|
|
|
|
|
mailer = None
|
|
|
|
|
for actor in self.actors :
|
|
|
|
|
id = actor.getIdentifier()
|
|
|
|
|
if id == "mailer" :
|
|
|
|
|
mailer = actor.Mailer()
|
|
|
|
|
if conf[id] is None :
|
|
|
|
|
continue
|
|
|
|
|
args = conf[id]
|
|
|
|
|
actor.init(args)
|
|
|
|
|
#
|
|
|
|
|
# Initializing the mailer
|
|
|
|
|
if mailer is not None and mailer in self.config:
|
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
|
|
|
|
|
|
return meta
|
|
|
|
|
def setup(self,meta):
|
|
|
|
|
#
|
|
|
|
|
# We should configure the actors accordingly and make sure they are operational
|
|
|
|
|
#
|
|
|
|
|
conf = {"folders":meta['folder_threshold'],"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']
|
|
|
|
|
|
|
|
|
|
mailer = None
|
|
|
|
|
for actor in self.actors :
|
|
|
|
|
id = actor.getIdentifier()
|
|
|
|
|
if id == "mailer" :
|
|
|
|
|
mailer = actor.Mailer()
|
|
|
|
|
if conf[id] is None :
|
|
|
|
|
continue
|
|
|
|
|
args = conf[id]
|
|
|
|
|
actor.init(args)
|
|
|
|
|
#
|
|
|
|
|
# Initializing the mailer
|
|
|
|
|
if mailer is not None and mailer in self.config:
|
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
|
|
|
|
|
|
def isvalid(self):
|
|
|
|
|
self.status()
|
|
|
|
@ -85,6 +146,7 @@ class Manager() :
|
|
|
|
|
print [channel,header]
|
|
|
|
|
message = json.loads(stream)
|
|
|
|
|
data = message['data']
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
#DELAY=35*60 #- 35 Minutes
|
|
|
|
|
#LIMIT=1000
|
|
|
|
@ -99,7 +161,7 @@ class Manager() :
|
|
|
|
|
COUNT = 0
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
for agent in self.pool :
|
|
|
|
|
for agent in self.agents :
|
|
|
|
|
data = agent.composite()
|
|
|
|
|
label = agent.getName()
|
|
|
|
|
node = '@'.join([label,self.id])
|
|
|
|
|