fix conflict
This commit is contained in:
commit
221db0c1b0
|
@ -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,"")
|
||||
|
|
|
@ -529,9 +529,12 @@ class NetworkMgr(object):
|
|||
|
||||
def check_usergw(self, username, uid, nodemgr, distributedgw=False):
|
||||
logger.info("Check %s(%s) user gateway."%(username, str(uid)))
|
||||
if not self.has_user(username):
|
||||
return [False,"user doesn't exist."]
|
||||
self.load_usrgw(username)
|
||||
if username not in self.usrgws.keys():
|
||||
return [False, 'user does not exist.']
|
||||
self.usrgws[username] = self.masterip
|
||||
self.dump_usrgw(username)
|
||||
ip = self.usrgws[username]
|
||||
self.load_user(username)
|
||||
if not distributedgw:
|
||||
|
|
|
@ -465,14 +465,14 @@ class VclusterMgr(object):
|
|||
[status, info] = self.get_clusterinfo(clustername, username)
|
||||
if not status:
|
||||
return [False, "cluster not found"]
|
||||
if info['status'] == 'stopped':
|
||||
return [True, "cluster no need to start"]
|
||||
# need to check and recover gateway of this user
|
||||
self.networkmgr.check_usergw(username, uid, self.nodemgr,self.distributedgw=='True')
|
||||
# recover proxy of cluster
|
||||
if not "proxy_server_ip" in info.keys():
|
||||
info['proxy_server_ip'] = self.addr
|
||||
self.write_clusterinfo(info,clustername,username)
|
||||
if info['status'] == 'stopped':
|
||||
return [True, "cluster no need to start"]
|
||||
try:
|
||||
target = 'http://'+info['containers'][0]['ip'].split('/')[0]+":10000"
|
||||
if self.distributedgw == 'True':
|
||||
|
|
|
@ -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
|
||||
|
@ -59,6 +60,19 @@ class dockletRequest():
|
|||
return result
|
||||
#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={}):
|
||||
|
|
Loading…
Reference in New Issue