This commit is contained in:
Anna Sudnitsina 2018-03-19 18:48:29 +00:00
parent fac8d663a4
commit 76d402d07d
2 changed files with 22 additions and 17 deletions

19
rbmd.py
View File

@ -51,7 +51,8 @@ class MainHandler(tornado.web.RequestHandler):
def get(self):
user_id = self.get_secure_cookie("user")
ws = config("ws")
metrics = json.loads(action('metrics', 'get'))
try: metrics = json.loads(action('metrics', 'get'))
except ValueError: metrics = {}
my_status = zk_fetch("/rbmd/log/health") #action('status', 'get')
dct = {'ws': ws, 'metrics': metrics, 'status': my_status}
self.render("index.html", **dct)
@ -107,23 +108,21 @@ class MountHandler(tornado.web.RequestHandler):
if self.get_secure_cookie("user"):
data = {k: v[0] for k, v in self.request.arguments.items()}
res = action('mount', 'post', json.dumps(data))
logging.info(res)
class UnmountHandler(tornado.web.RequestHandler):
def get(self):
data = self.request.arguments
logging.info(data)
res = action('mount', 'post', json.dumps(data))
logging.info(res)
#data = self.request.arguments
data = {k: v[0] for k, v in self.request.arguments.items()}
res = action('umount', 'post', json.dumps(data))
class ResolveHandler(tornado.web.RequestHandler):
#my_status = action('status', 'get')
def get(self):
data = self.request.arguments
logging.info(data)
#data = self.request.arguments
data = {k: v[0] for k, v in self.request.arguments.items()}
res = action('resolve', 'post', json.dumps(data))
logging.info(res)
class StatusHandler(tornado.web.RequestHandler):
pass
@ -166,6 +165,8 @@ def config(point):
def action(name, method, data=None):
with open('conf.json') as conf:
url = json.load(conf)["api"] + '/' + name
logging.info(url)
logging.info(data)
if method == 'get':
try:
res = requests.get(url).content

View File

@ -30,10 +30,12 @@ $(function() {
function unmount(a, b, c) {
var u = confirm(a + ": confirm unmount of " + b);
if (u == true) {
console.log('1');
$.ajax({
url:"unmount",
data:{"node":a, "mountpoint":b, "block":c},
success:function(data){
success:function(data){console.log(data);
var res = JSON.parse(data);
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
$("#rspContainer").css("display", "block");
@ -81,13 +83,15 @@ $(function() {
var mnt_block = "";
for (i in selected_node_body.mounts) {
var mnt = selected_node_body.mounts[i];
mnt_block += "<a href='javascript:void(0)' onClick='unmount(selected_node, selected_node_body.mounts[i].mountpoint, selected_node_body.mounts[i].block)' >unmount</a><br>Mountpoint: "
+ mnt.mountpoint + "<br>Mountopts: "
+ mnt.mountopts + "<br>Fstype: "
+ mnt.fstype +
"<br>Pool: " + mnt.pool +
"<br>Image: " + mnt.image +
"<br>Block: " + mnt.block +"<br>";
mnt_block += '<a href=\'javascript:void(0)\' onClick=\'unmount("' + selected_node + '", "'
+ selected_node_body.mounts[i].mountpoint + '", "'
+ selected_node_body.mounts[i].block + '")\' >unmount</a><br>Mountpoint: '
+ mnt.mountpoint + '<br>Mountopts: '
+ mnt.mountopts + '<br>Fstype: '
+ mnt.fstype
+ '<br>Pool: ' + mnt.pool
+ '<br>Image: ' + mnt.image
+ '<br>Block: ' + mnt.block + '<br>';
}
$("#mon").html(mnt_block);
}