2016-03-31 16:03:38 +08:00
|
|
|
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/')
|
2017-05-21 16:08:12 +08:00
|
|
|
desc = dockletRequest.getalldesc()
|
2017-04-07 16:25:57 +08:00
|
|
|
allclusters={}
|
|
|
|
for master in result:
|
|
|
|
clusters = result[master].get("clusters")
|
2016-03-31 16:03:38 +08:00
|
|
|
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])
|
2016-03-31 16:03:38 +08:00
|
|
|
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']
|
2016-03-31 16:03:38 +08:00
|
|
|
full_clusters.append(single_cluster)
|
|
|
|
else:
|
|
|
|
self.error()
|
2017-04-07 16:25:57 +08:00
|
|
|
allclusters[master] = full_clusters
|
2017-05-21 16:08:12 +08:00
|
|
|
return self.render(self.template_path, allclusters = allclusters, desc=desc)
|
2017-04-07 16:25:57 +08:00
|
|
|
#else:
|
|
|
|
# self.error()
|
2016-03-31 16:03:38 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def post(self):
|
|
|
|
return self.get()
|