Merge pull request #245 from zhongyehong/master
add master description in dashboard and addcluster page
This commit is contained in:
commit
36d4813b3b
|
@ -149,6 +149,8 @@
|
|||
|
||||
# MASTER_IPS: all master ips in a cente, depart by ','.
|
||||
# e.g:192.168.192.191@master1,192.168.192.192@master2
|
||||
# you can also add description to each master.
|
||||
# e.g:master1_desc="this is master1"
|
||||
# defalut:0.0.0.0@docklet
|
||||
# MASTER_IPS=""
|
||||
|
||||
|
|
|
@ -65,4 +65,4 @@ def getenv(key):
|
|||
elif key =="AUTH_KEY":
|
||||
return os.environ.get("AUTH_KEY","docklet")
|
||||
else:
|
||||
return os.environ[key]
|
||||
return os.environ.get(key,"")
|
||||
|
|
|
@ -44,12 +44,16 @@
|
|||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<br/>
|
||||
<div class="form-group"><label class="col-sm-2 control-label">Center Choose</label>
|
||||
<div class="form-group"><label class="col-sm-2 control-label">Location</label>
|
||||
<div class="col-sm-10"><select id="masterselector" class="form-control">
|
||||
{% for master in masterips %}
|
||||
<option value="{{master.split("@")[0]}}">{{master.split("@")[1]}}</option>
|
||||
{% endfor %}
|
||||
</select></div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-group"><label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-10"><p id="masterdesc">{{masterdesc}}</p></div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-group"><label class="col-sm-2 control-label">Image Choose</label>
|
||||
|
@ -167,9 +171,13 @@
|
|||
<script type="text/javascript">
|
||||
$("select#masterselector").change(function() {
|
||||
var masterip=$(this).children('option:selected').val();
|
||||
var mastername=$(this).children('option:selected').html();
|
||||
console.log(masterip);
|
||||
document.getElementById("form").action="/workspace/add/"+masterip+"/";
|
||||
var host = window.location.host;
|
||||
$.post("http://"+host+"/getmasterdesc/"+mastername+"/", {}, function(data) {
|
||||
$("#masterdesc").html(data);
|
||||
});
|
||||
$.post("http://"+host+"/image/list/"+masterip+"/",{},function(data){
|
||||
var images = data.images;
|
||||
var imagehtml =
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<button type="button" class="btn btn-xs btn-default"> Go </button>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>{{master.split("@")[1]}}</td>
|
||||
<td><a href="/masterdesc/{{master.split("@")[1]}}/" target="_blank" title="{{desc[master.split("@")[1]]}}">{{master.split("@")[1]}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
13
web/web.py
13
web/web.py
|
@ -227,6 +227,17 @@ def deleteproxy(clustername,masterip):
|
|||
deleteproxyView.masterip = masterip
|
||||
return deleteproxyView.as_view()
|
||||
|
||||
@app.route("/getmasterdesc/<mastername>/", methods=['POST'])
|
||||
@login_required
|
||||
def getmasterdesc(mastername):
|
||||
return env.getenv(mastername+"_desc")[1:-1]
|
||||
|
||||
@app.route("/masterdesc/<mastername>/", methods=['GET'])
|
||||
@login_required
|
||||
def masterdesc(mastername):
|
||||
descriptionMasterView.desc=env.getenv(mastername+"_desc")[1:-1]
|
||||
return descriptionMasterView.as_view()
|
||||
|
||||
@app.route("/image/list/<masterip>/", methods=['POST'])
|
||||
@login_required
|
||||
def image_list(masterip):
|
||||
|
@ -662,4 +673,4 @@ if __name__ == '__main__':
|
|||
elif opt in ("-p", "--port"):
|
||||
webport = int(arg)
|
||||
|
||||
app.run(host = webip, port = webport, debug = False, threaded=True)
|
||||
app.run(host = webip, port = webport, debug = True, threaded=True)
|
||||
|
|
|
@ -12,6 +12,7 @@ class addClusterView(normalView):
|
|||
def get(self):
|
||||
masterips = dockletRequest.post_to_all()
|
||||
images = dockletRequest.post("/image/list/",{},masterips[0].split("@")[0]).get("images")
|
||||
desc = dockletRequest.getdesc(masterips[0].split("@")[1])
|
||||
result = dockletRequest.post("/user/usageQuery/")
|
||||
quota = result.get("quota")
|
||||
usage = result.get("usage")
|
||||
|
@ -46,7 +47,7 @@ class addClusterView(normalView):
|
|||
'disk': defaultdisk
|
||||
}
|
||||
if (result):
|
||||
return self.render(self.template_path, user = session['username'],masterips = masterips, images = images, quota = quota, usage = usage, defaultsetting = defaultsetting)
|
||||
return self.render(self.template_path, user = session['username'],masterips = masterips, images = images, quota = quota, usage = usage, defaultsetting = defaultsetting, masterdesc=desc)
|
||||
else:
|
||||
self.error()
|
||||
|
||||
|
@ -73,8 +74,15 @@ class createClusterView(normalView):
|
|||
else:
|
||||
return self.render(self.error_path, message = result.get('message'))
|
||||
|
||||
class descriptionMasterView(normalView):
|
||||
template_path = "description.html"
|
||||
|
||||
@classmethod
|
||||
def get(self):
|
||||
return self.render(self.template_path, description=self.desc)
|
||||
|
||||
class descriptionImageView(normalView):
|
||||
template_path = "image_description.html"
|
||||
template_path = "description.html"
|
||||
|
||||
@classmethod
|
||||
def get(self):
|
||||
|
|
|
@ -9,6 +9,7 @@ class dashboardView(normalView):
|
|||
@classmethod
|
||||
def get(self):
|
||||
result = dockletRequest.post_to_all('/cluster/list/')
|
||||
desc = dockletRequest.getalldesc()
|
||||
allclusters={}
|
||||
for master in result:
|
||||
clusters = result[master].get("clusters")
|
||||
|
@ -28,7 +29,7 @@ class dashboardView(normalView):
|
|||
else:
|
||||
self.error()
|
||||
allclusters[master] = full_clusters
|
||||
return self.render(self.template_path, allclusters = allclusters)
|
||||
return self.render(self.template_path, allclusters = allclusters, desc=desc)
|
||||
#else:
|
||||
# self.error()
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ def getip(masterip):
|
|||
def getname(masterip):
|
||||
return masterip.split("@")[1]
|
||||
|
||||
|
||||
class dockletRequest():
|
||||
|
||||
@classmethod
|
||||
|
@ -60,6 +61,19 @@ class dockletRequest():
|
|||
#except:
|
||||
#abort(500)
|
||||
|
||||
@classmethod
|
||||
def getdesc(self,mastername):
|
||||
return env.getenv(mastername+"_desc")[1:-1]
|
||||
|
||||
@classmethod
|
||||
def getalldesc(self):
|
||||
masterips = self.post_to_all()
|
||||
res={}
|
||||
for masterip in masterips:
|
||||
mastername = getname(masterip)
|
||||
res[mastername]=env.getenv(mastername+"_desc")
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def post_to_all(self, url = '/', data={}):
|
||||
if (url == '/'):
|
||||
|
|
Loading…
Reference in New Issue