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["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