docklet/web/webViews/dashboard.py

39 lines
1.4 KiB
Python
Raw Normal View History

from flask import session,render_template
from webViews.view import normalView
from webViews.dockletrequest import dockletRequest
class dashboardView(normalView):
template_path = "dashboard.html"
@classmethod
def get(self):
2017-04-07 16:25:57 +08:00
result = dockletRequest.post_to_all('/cluster/list/')
desc = dockletRequest.getalldesc()
2017-04-07 16:25:57 +08:00
allclusters={}
for master in result:
clusters = result[master].get("clusters")
full_clusters = []
data={}
for cluster in clusters:
data["clustername"] = cluster
single_cluster = {}
single_cluster['name'] = cluster
2017-04-07 16:25:57 +08:00
message = dockletRequest.post("/cluster/info/", data , master.split("@")[0])
if(message):
message = message.get("message")
single_cluster['status'] = message['status']
single_cluster['id'] = message['clusterid']
2017-05-29 16:45:35 +08:00
single_cluster['proxy_public_ip'] = message['proxy_public_ip']
full_clusters.append(single_cluster)
else:
self.error()
2017-04-07 16:25:57 +08:00
allclusters[master] = full_clusters
return self.render(self.template_path, allclusters = allclusters, desc=desc)
2017-04-07 16:25:57 +08:00
#else:
# self.error()
@classmethod
def post(self):
return self.get()