|
|
@ -28,9 +28,10 @@ class Manager() :
|
|
|
|
setattr(name,value)
|
|
|
|
setattr(name,value)
|
|
|
|
def init(self,**args) :
|
|
|
|
def init(self,**args) :
|
|
|
|
self.id = args['node']
|
|
|
|
self.id = args['node']
|
|
|
|
self.pool = args['pool']
|
|
|
|
self.agents = args['agents']
|
|
|
|
self.config = args['config']
|
|
|
|
self.config = args['config']
|
|
|
|
self.key = args['key']
|
|
|
|
self.key = args['key']
|
|
|
|
|
|
|
|
self.actors = args['actors']
|
|
|
|
|
|
|
|
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
self.status() #-- Initializing status information
|
|
|
|
|
|
|
|
|
|
|
@ -53,17 +54,77 @@ class Manager() :
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.DELAY = -1
|
|
|
|
self.DELAY = -1
|
|
|
|
self.LIMIT = -1
|
|
|
|
self.LIMIT = -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def filter(meta) :
|
|
|
|
scope = []
|
|
|
|
scope = []
|
|
|
|
lactors= []
|
|
|
|
lactors= []
|
|
|
|
for item in meta :
|
|
|
|
for item in meta :
|
|
|
|
scope = scope + item['scope'].split(',')
|
|
|
|
scope = scope + item['scope'].split(',')
|
|
|
|
if 'actors' in item :
|
|
|
|
if 'actors' in item :
|
|
|
|
lactors= lactors + item['actors'].split(',')
|
|
|
|
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]
|
|
|
|
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
|
|
|
|
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):
|
|
|
|
def isvalid(self):
|
|
|
|
self.status()
|
|
|
|
self.status()
|
|
|
|
return self.DELAY > -1 and self.LIMIT > -1
|
|
|
|
return self.DELAY > -1 and self.LIMIT > -1
|
|
|
@ -85,6 +146,7 @@ class Manager() :
|
|
|
|
print [channel,header]
|
|
|
|
print [channel,header]
|
|
|
|
message = json.loads(stream)
|
|
|
|
message = json.loads(stream)
|
|
|
|
data = message['data']
|
|
|
|
data = message['data']
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
|
#DELAY=35*60 #- 35 Minutes
|
|
|
|
#DELAY=35*60 #- 35 Minutes
|
|
|
|
#LIMIT=1000
|
|
|
|
#LIMIT=1000
|
|
|
@ -99,7 +161,7 @@ class Manager() :
|
|
|
|
COUNT = 0
|
|
|
|
COUNT = 0
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
break
|
|
|
|
for agent in self.pool :
|
|
|
|
for agent in self.agents :
|
|
|
|
data = agent.composite()
|
|
|
|
data = agent.composite()
|
|
|
|
label = agent.getName()
|
|
|
|
label = agent.getName()
|
|
|
|
node = '@'.join([label,self.id])
|
|
|
|
node = '@'.join([label,self.id])
|
|
|
|