|
|
@ -371,14 +371,46 @@ def app_status() :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/init/collector',methods=['POST'])
|
|
|
|
@app.route('/init/collector',methods=['POST'])
|
|
|
|
|
|
|
|
def init_collector():
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
This function will provide context for the calling code to be able to submit data
|
|
|
|
|
|
|
|
@header key user's key
|
|
|
|
|
|
|
|
@header id node identifier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@return {"plan":...,"store":...}
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
r = {}
|
|
|
|
|
|
|
|
if 'key' in request.headers and 'id' in request.headers :
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
key = request.headers['key']
|
|
|
|
|
|
|
|
node= request.headers['id']
|
|
|
|
|
|
|
|
config = json.loads(json.dumps(CONFIG))
|
|
|
|
|
|
|
|
handler = Register(write=class_write,read=class_read,store=config['store']['args'],default=CONFIG['plan'],uid=key)
|
|
|
|
|
|
|
|
plan = handler.get_active_plan()
|
|
|
|
|
|
|
|
if plan :
|
|
|
|
|
|
|
|
store = json.loads(json.dumps(CONFIG['store']))
|
|
|
|
|
|
|
|
store['args']['uid'] = key
|
|
|
|
|
|
|
|
store['args']['dbname'] = plan['name']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r = {"plan":plan,"store":store}
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
print e
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Invalid parameters were sent
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
return json.dumps(r)
|
|
|
|
def InitCollector():
|
|
|
|
def InitCollector():
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This endpoint is intended to initialize the collection agent
|
|
|
|
This endpoint is intended to initialize the collection agent
|
|
|
|
@pre registration of the client should be done against the store API
|
|
|
|
@pre registration of the client should be done against the store API
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
global CONFIG
|
|
|
|
|
|
|
|
r = []
|
|
|
|
r = []
|
|
|
|
manager={}
|
|
|
|
manager={}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
factory = DataSourceFactory()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
key = request.headers['key']
|
|
|
|
key = request.headers['key']
|
|
|
@ -393,7 +425,6 @@ def InitCollector():
|
|
|
|
a = {'apps':'actor.Apps','mailer':'actor.Mailer','folders':'actor.Folders'}
|
|
|
|
a = {'apps':'actor.Apps','mailer':'actor.Mailer','folders':'actor.Folders'}
|
|
|
|
lagents = []
|
|
|
|
lagents = []
|
|
|
|
lactors = []
|
|
|
|
lactors = []
|
|
|
|
|
|
|
|
|
|
|
|
for id in m :
|
|
|
|
for id in m :
|
|
|
|
if id in body :
|
|
|
|
if id in body :
|
|
|
|
agent = eval(m[id]+"()")
|
|
|
|
agent = eval(m[id]+"()")
|
|
|
@ -410,18 +441,30 @@ def InitCollector():
|
|
|
|
_actor = eval(a[id]+"()")
|
|
|
|
_actor = eval(a[id]+"()")
|
|
|
|
lactors.append(_actor)
|
|
|
|
lactors.append(_actor)
|
|
|
|
|
|
|
|
|
|
|
|
config = dict(CONFIG)
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# @TODO: The database name should be provided by the active plan
|
|
|
|
# @TODO: The database name should be provided by the active plan
|
|
|
|
# The database name will be overriden by the user's current plan
|
|
|
|
# The database name will be overriden by the user's current plan
|
|
|
|
#
|
|
|
|
#
|
|
|
|
config['store']['args']['dbname'] = None #'monitor-logs'
|
|
|
|
#global class_write,class_read,CONFIG
|
|
|
|
config['store']['args']['uid'] = key
|
|
|
|
print 'plan' in session,CONFIG['store']['args']
|
|
|
|
|
|
|
|
if 'plan' not in session :
|
|
|
|
|
|
|
|
config = json.loads(json.dumps(CONFIG))
|
|
|
|
|
|
|
|
plan = config['plan']
|
|
|
|
|
|
|
|
handler = Register(write=class_write,read=class_read,store=config['store']['args'],default=plan,uid=key)
|
|
|
|
|
|
|
|
plan = handler.get_active_plan()
|
|
|
|
|
|
|
|
session['plan'] = plan
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
plan = session['plan']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_config = json.loads(json.dumps(CONFIG))
|
|
|
|
|
|
|
|
#_config['store']['args']['dbname'] = plan['name'] #'monitor-logs'
|
|
|
|
|
|
|
|
_config['store']['args']['uid'] = key
|
|
|
|
|
|
|
|
_config['store']['args']['dbname'] = plan['name']
|
|
|
|
manager = Manager()
|
|
|
|
manager = Manager()
|
|
|
|
manager.init(actors = lactors,agents=lagents,config=config,key=key,node=node) ;
|
|
|
|
manager.init(actors = lactors,agents=lagents,config=_config,key=key,node=node) ;
|
|
|
|
r = [pickle.dumps(manager)]
|
|
|
|
r = [pickle.dumps(manager)]
|
|
|
|
except Exception,e:
|
|
|
|
except Exception as e:
|
|
|
|
print '***** ',str(e)
|
|
|
|
print ' init (error) ',str(e)
|
|
|
|
return json.dumps(r)
|
|
|
|
return json.dumps(r)
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|