Refactored API and views

community
Steve L. Nyemba 7 years ago
parent 93186b81fa
commit 75f948bf97

File diff suppressed because one or more lines are too long

@ -48,19 +48,39 @@ class_write= CONFIG['store']['class']['write']
factory = DataSourceFactory()
# gReader = factory.instance(type=class_read,args=p)
@app.route('/1/get/apps')
@app.route('/1/get/nodes')
def get_apps():
"""
This function returns the labels of applications for every node registered
@param None
e.g: apps@zulu.org
"""
r = []
try:
gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/nodes',key=p['uid'])
except Exception,e:
print (e)
return json.dumps(r)
@app.route('/1/get/apps')
def get_apps():
"""
This function returns the applications for a given node
@param node identifier e.g: apps@zulu.org
"""
r = []
try:
node_id = request.args.get('node')
gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/app_names',key=p['uid'])
r = r[node_id]
except Exception,e:
print (e)
return json.dumps(r)
@app.route('/1/get/summary/<id>')
def get_summary(id):
"""
@ -88,7 +108,7 @@ def get_usage_trend():
"""
This function returns cpu/memory usage for the entire system being monitored. It will return the 24 most recent observations in the logs
No parameters should be passed.
@param None
@return {memory_usage:[],cpu_usage:[],app_count:value,memory_available:[]}
"""
r = {}
@ -104,37 +124,41 @@ def get_usage_trend():
def get_usage_detail():
"""
This function returns detailed information about usage per application monitored. It will return the 24 most recent observations in the logs
No parameters should be passed
@return {app_1:{memory_usage:[],cpu_usage:[]},app_2:{memory_usage:[],cpu_usage:[]},...}
@TODO:
- add node references because if the same application lives on other nodes the info will be overriden
- parameters to be passed will be the node information
@param node node identifier e.g: apps@zulu.io
@return {node_x:{app_1:{memory_usage:[],cpu_usage:[]}},...}
"""
r = {}
try:
id = request.args.get('node')
gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/app_resource_usage_details',key=p['uid'])
r = r[id]
except Exception,e:
print (e)
return json.dumps(r)
@app.route('/1/app/status/<id>')
def app_status(id) :
@app.route('/1/app/status')
def app_status() :
"""
This function aggregates the number of crashes/running/idle instances found in the past 24 log entries
@TODO: The back-end doesn't allow nodes to be specified
@param id node that contains an app
"""
r = []
This function aggregates the number of crashes/running/idle instances found in the past 24 log entries
@param nid node identifier e.g: app@zulu.io
@param aid application identifier e.g: kate, firefox, chrome ... specified in the configuraiton
"""
r = []
try:
gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/app_status_details',key=p['uid'])
#
#@TODO: Once the back-end enables the nodes in which the application is running, uncomment the line below
#
#r = r[id]
except Exception,e:
print e
return r
nid = request.args.get('node') # Node identifier
aid = request.args.get('app') # application identifier
gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/app_status_details',key=p['uid'])
#
#@TODO: Once the back-end enables the nodes in which the application is running, uncomment the line below
#
r = r[nid][aid]
except Exception,e:
print e
return r
@app.route('/get/<id>')
def procs(id):
try:

Loading…
Cancel
Save