upd
This commit is contained in:
parent
fac8d663a4
commit
76d402d07d
19
rbmd.py
19
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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user