new feature with most of the data compiled (single call)

community
Steve Nyemba 7 years ago
parent 3d56fc734d
commit ae94d3e6d0

@ -95,11 +95,6 @@ def register() :
plan = body['plan'] plan = body['plan']
handler = Register(write=class_write,read=class_read,store=p,default=default_plan,uid=uid) handler = Register(write=class_write,read=class_read,store=p,default=default_plan,uid=uid)
r = handler.register(plan) r = handler.register(plan)
if not r :
info = handler.get_info()
return "" if info is None else json.dumps(info)
else:
print r
return json.dumps(r) return json.dumps(r)
def __register(): def __register():
@ -154,7 +149,7 @@ def __register():
#@TODO : Initiate a retry #@TODO : Initiate a retry
# #
args = dict(p) args = json.loads(json.dumps(p))
couchdb = factory.instance(type=class_read,args=args) couchdb = factory.instance(type=class_read,args=args)
args['uid'] = r #-- returned uid args['uid'] = r #-- returned uid
plan = couchdb.view('plans/active',key=r) plan = couchdb.view('plans/active',key=r)
@ -164,7 +159,7 @@ def __register():
args['uid'] = body['uid'] args['uid'] = body['uid']
couchdb = factory.instance(type=class_read,args=args) couchdb = factory.instance(type=class_read,args=args)
document = couchdb.read() document = couchdb.read()
print args,document
r = list(set(document['emails']) - set(body['uid'])) r = list(set(document['emails']) - set(body['uid']))
r = [item for item in r if len(item) == 36] r = [item for item in r if len(item) == 36]
if len(r) > 0 : if len(r) > 0 :
@ -193,8 +188,9 @@ def get_nodes():
""" """
r = [] r = []
try: try:
app_key = request.headers['key']
gReader = factory.instance(type=class_read,args=p) gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/nodes',key=p['uid']) r = gReader.view('summary/nodes',key=app_key)
session['default.node'] = r[0] session['default.node'] = r[0]
except Exception,e: except Exception,e:
print (e) print (e)
@ -217,6 +213,37 @@ def get_apps():
print (e) print (e)
return json.dumps(r) return json.dumps(r)
@app.route('/1/get/logs')
def get_logs() :
r = {}
#session['key'] = 'c259e8b1-e2fb-40df-bf03-f521f8ee352d'
key = session['key'] if 'key' in session else None
if key is None and 'key' in request.headers:
key = request.headers['key']
if key is None :
return json.dumps(r)
else:
try:
gReader = factory.instance(type=class_read,args=p)
plan = gReader.view('plans/active',key=key)
if plan :
dbname = plan['name']
args = str(json.dumps(p))
args = json.loads(args)
args['dbname'] = dbname
scope = ['app_status','app_resources','folder_size','app_status_details']
for id in scope :
gReader = factory.instance(type=class_read,args=args)
view = ('summary/'+id).strip()
r[id] = gReader.view(view,key=key)
# r[id] = r[node_id]
except Exception,e:
print (e)
return json.dumps(r)
@app.route('/1/get/summary/<id>') @app.route('/1/get/summary/<id>')
def get_summary(id): def get_summary(id):

@ -29,7 +29,6 @@ class Register :
def register(self,pid): def register(self,pid):
if pid is None : if pid is None :
pid = self.default_plan pid = self.default_plan
if self.is_registered(pid) == False: if self.is_registered(pid) == False:
plan_info = self.__signup(pid) plan_info = self.__signup(pid)
return self.__update(pid,plan_info) return self.__update(pid,plan_info)
@ -38,7 +37,7 @@ class Register :
# If the user is already registered for this plan, there is nothing much to do # If the user is already registered for this plan, there is nothing much to do
# @TODO: Consider plan migration functionality {upgrade,downgrade} # @TODO: Consider plan migration functionality {upgrade,downgrade}
# #
return None return self.get_info()
def __signup(self,pid): def __signup(self,pid):
auid = str(uuid.uuid4()) auid = str(uuid.uuid4())
@ -71,7 +70,7 @@ class Register :
key = self.get_key() key = self.get_key()
return {"key":key,"name":plan['name'],"info":[plan['metadata']]} return {"key":key,"name":plan['name'],"info":[plan['metadata']]}
except Exception as e: except Exception as e:
print (str(e)) print "get_info ** ",(str(e))
return None return None
def get_key(self) : def get_key(self) :
store = self.factory.instance(type=self.class_read,args=self.store_args) store = self.factory.instance(type=self.class_read,args=self.store_args)

Loading…
Cancel
Save