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