|
|
@ -32,9 +32,9 @@ 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.update() #-- Initializing status information
|
|
|
|
|
|
|
|
|
|
|
|
def status(self) :
|
|
|
|
def update(self) :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This method inspect the plans for the current account and makes sure it can/should proceed
|
|
|
|
This method inspect the plans for the current account and makes sure it can/should proceed
|
|
|
|
The user must be subscribed and to the service otherwise this is not going to work
|
|
|
|
The user must be subscribed and to the service otherwise this is not going to work
|
|
|
@ -54,41 +54,32 @@ class Manager() :
|
|
|
|
self.DELAY = -1
|
|
|
|
self.DELAY = -1
|
|
|
|
self.LIMIT = -1
|
|
|
|
self.LIMIT = -1
|
|
|
|
|
|
|
|
|
|
|
|
self.filter(meta)
|
|
|
|
#self.filter(meta)
|
|
|
|
self._filter('scope','apps',meta,self.agents)
|
|
|
|
self.filter('agents',meta,self.agents)
|
|
|
|
self._filter('','folders',meta,self.agents)
|
|
|
|
self.filter('actors',meta,self.actors)
|
|
|
|
#if len(self.actors) > 0 :
|
|
|
|
self.setup(meta)
|
|
|
|
# self.setup(meta)
|
|
|
|
|
|
|
|
def _filter(self,id,key,meta,values):
|
|
|
|
def filter_collectors(self,meta) :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function is designed to perform a filter on a list of values given a full set
|
|
|
|
remove collectors that are not specified by the plan
|
|
|
|
@param id
|
|
|
|
Note that the agents (collectors) have already been initialized ?
|
|
|
|
@param lvalues
|
|
|
|
|
|
|
|
@param values
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
values = meta['agents'].replace(' ','').split(',')
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
self.agents = [agent for agent in self.agents if agent.getName() in values]
|
|
|
|
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_actors(self,meta):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
removes actors that are NOT specified by the subscription plan
|
|
|
|
|
|
|
|
Note that the actor have already been instatiated and need initialization
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
values = meta['actors'].replace(' ','').split('.'
|
|
|
|
|
|
|
|
self.actors = [actor for actor in self.actors if actor.getName() in values]
|
|
|
|
|
|
|
|
|
|
|
|
def filter(self,meta) :
|
|
|
|
def filter(self,id,meta,objects):
|
|
|
|
|
|
|
|
values = meta[id].replace(' ','').split(',')
|
|
|
|
|
|
|
|
return [item for item in objects if object.getName() in values]
|
|
|
|
|
|
|
|
def __filter(self,meta) :
|
|
|
|
scope = []
|
|
|
|
scope = []
|
|
|
|
lactors= []
|
|
|
|
lactors= []
|
|
|
|
for item in meta :
|
|
|
|
for item in meta :
|
|
|
@ -136,7 +127,28 @@ class Manager() :
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
|
|
|
|
|
|
|
|
return meta
|
|
|
|
return meta
|
|
|
|
def setup(self,meta):
|
|
|
|
def setup(self,meta) :
|
|
|
|
|
|
|
|
conf = {"folders":None,"apps":None}
|
|
|
|
|
|
|
|
read_class = self.config['store']['class']['read']
|
|
|
|
|
|
|
|
read_args = self.config['store']['args']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
couchdb = self.factory.instance(type=read_class,args=read_args)
|
|
|
|
|
|
|
|
args = couchdb.view('config/apps',key=self.key)
|
|
|
|
|
|
|
|
if len(args.keys()) > 0 :
|
|
|
|
|
|
|
|
self.apply_setup('apps',args)
|
|
|
|
|
|
|
|
args = couchdb.view('config/folders',key=self.key)
|
|
|
|
|
|
|
|
if 'folder_threshold' not in meta :
|
|
|
|
|
|
|
|
args['threshold'] = meta['folder_threshold']
|
|
|
|
|
|
|
|
self.apply_setup('folders',args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_setup(self,name,args) :
|
|
|
|
|
|
|
|
for actor in self.actors :
|
|
|
|
|
|
|
|
if args is not None and actor.getName() == name and len(args.keys()) > 0:
|
|
|
|
|
|
|
|
actor.init(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __setup(self,meta):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# We should configure the actors accordingly and make sure they are operational
|
|
|
|
# We should configure the actors accordingly and make sure they are operational
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -170,7 +182,7 @@ class Manager() :
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
mailer.init(self.config['mailer'])
|
|
|
|
|
|
|
|
|
|
|
|
def isvalid(self):
|
|
|
|
def isvalid(self):
|
|
|
|
self.status()
|
|
|
|
self.update()
|
|
|
|
return self.DELAY > -1 and self.LIMIT > -1
|
|
|
|
return self.DELAY > -1 and self.LIMIT > -1
|
|
|
|
def post(self,row) :
|
|
|
|
def post(self,row) :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|