From 76d402d07d74b23746a19508f7a8670901cd6342 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 19 Mar 2018 18:48:29 +0000 Subject: [PATCH] upd --- rbmd.py | 19 ++++++++++--------- static/rbmd/script.js | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/rbmd.py b/rbmd.py index 8beabd0..2b9ecbb 100644 --- a/rbmd.py +++ b/rbmd.py @@ -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 diff --git a/static/rbmd/script.js b/static/rbmd/script.js index 8ac5ad9..72a09ea 100644 --- a/static/rbmd/script.js +++ b/static/rbmd/script.js @@ -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 = "

" + res["state"] + "

"+ res["message"] +"

"; $("#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 += "unmount
Mountpoint: " - + mnt.mountpoint + "
Mountopts: " - + mnt.mountopts + "
Fstype: " - + mnt.fstype + - "
Pool: " + mnt.pool + - "
Image: " + mnt.image + - "
Block: " + mnt.block +"
"; + mnt_block += 'unmount
Mountpoint: ' + + mnt.mountpoint + '
Mountopts: ' + + mnt.mountopts + '
Fstype: ' + + mnt.fstype + + '
Pool: ' + mnt.pool + + '
Image: ' + mnt.image + + '
Block: ' + mnt.block + '
'; } $("#mon").html(mnt_block); }