bug fix and registration process streamlined

community
Steve Nyemba 7 years ago
parent 833407dd4c
commit 73556f1d3e

@ -1,15 +1,16 @@
Flask==0.11.1
Flask-Session==0.3.0
Flask-SocketIO==2.8.2
Jinja2==2.8
MarkupSafe==0.23
Werkzeug==0.11.11
aniso8601==1.2.0 aniso8601==1.2.0
argparse==1.2.1 certifi==2017.11.5
chardet==3.0.4
click==6.6 click==6.6
couchdbkit==0.6.5 couchdbkit==0.6.5
Flask==0.11.1
Flask-Session==0.3.0
Flask-SocketIO==2.8.2
http-parser==0.8.3 http-parser==0.8.3
idna==2.6
itsdangerous==0.24 itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
ngram==3.3.0 ngram==3.3.0
numpy==1.11.3 numpy==1.11.3
pika==0.10.0 pika==0.10.0
@ -17,7 +18,9 @@ python-dateutil==2.6.0
python-engineio==1.1.0 python-engineio==1.1.0
python-socketio==1.6.2 python-socketio==1.6.2
pytz==2016.10 pytz==2016.10
requests==2.18.4
restkit==4.2.2 restkit==4.2.2
six==1.10.0 six==1.10.0
socketpool==0.5.3 socketpool==0.5.3
wsgiref==0.1.2 urllib3==1.22
Werkzeug==0.11.11

@ -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)
""" """

Loading…
Cancel
Save