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):
|
def get(self):
|
||||||
user_id = self.get_secure_cookie("user")
|
user_id = self.get_secure_cookie("user")
|
||||||
ws = config("ws")
|
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')
|
my_status = zk_fetch("/rbmd/log/health") #action('status', 'get')
|
||||||
dct = {'ws': ws, 'metrics': metrics, 'status': my_status}
|
dct = {'ws': ws, 'metrics': metrics, 'status': my_status}
|
||||||
self.render("index.html", **dct)
|
self.render("index.html", **dct)
|
||||||
|
@ -107,23 +108,21 @@ class MountHandler(tornado.web.RequestHandler):
|
||||||
if self.get_secure_cookie("user"):
|
if self.get_secure_cookie("user"):
|
||||||
data = {k: v[0] for k, v in self.request.arguments.items()}
|
data = {k: v[0] for k, v in self.request.arguments.items()}
|
||||||
res = action('mount', 'post', json.dumps(data))
|
res = action('mount', 'post', json.dumps(data))
|
||||||
logging.info(res)
|
|
||||||
|
|
||||||
|
|
||||||
class UnmountHandler(tornado.web.RequestHandler):
|
class UnmountHandler(tornado.web.RequestHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
data = self.request.arguments
|
#data = self.request.arguments
|
||||||
logging.info(data)
|
data = {k: v[0] for k, v in self.request.arguments.items()}
|
||||||
res = action('mount', 'post', json.dumps(data))
|
res = action('umount', 'post', json.dumps(data))
|
||||||
logging.info(res)
|
|
||||||
|
|
||||||
class ResolveHandler(tornado.web.RequestHandler):
|
class ResolveHandler(tornado.web.RequestHandler):
|
||||||
#my_status = action('status', 'get')
|
#my_status = action('status', 'get')
|
||||||
def get(self):
|
def get(self):
|
||||||
data = self.request.arguments
|
#data = self.request.arguments
|
||||||
logging.info(data)
|
data = {k: v[0] for k, v in self.request.arguments.items()}
|
||||||
res = action('resolve', 'post', json.dumps(data))
|
res = action('resolve', 'post', json.dumps(data))
|
||||||
logging.info(res)
|
|
||||||
|
|
||||||
class StatusHandler(tornado.web.RequestHandler):
|
class StatusHandler(tornado.web.RequestHandler):
|
||||||
pass
|
pass
|
||||||
|
@ -166,6 +165,8 @@ def config(point):
|
||||||
def action(name, method, data=None):
|
def action(name, method, data=None):
|
||||||
with open('conf.json') as conf:
|
with open('conf.json') as conf:
|
||||||
url = json.load(conf)["api"] + '/' + name
|
url = json.load(conf)["api"] + '/' + name
|
||||||
|
logging.info(url)
|
||||||
|
logging.info(data)
|
||||||
if method == 'get':
|
if method == 'get':
|
||||||
try:
|
try:
|
||||||
res = requests.get(url).content
|
res = requests.get(url).content
|
||||||
|
|
|
@ -30,10 +30,12 @@ $(function() {
|
||||||
function unmount(a, b, c) {
|
function unmount(a, b, c) {
|
||||||
var u = confirm(a + ": confirm unmount of " + b);
|
var u = confirm(a + ": confirm unmount of " + b);
|
||||||
if (u == true) {
|
if (u == true) {
|
||||||
|
console.log('1');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"unmount",
|
url:"unmount",
|
||||||
data:{"node":a, "mountpoint":b, "block":c},
|
data:{"node":a, "mountpoint":b, "block":c},
|
||||||
success:function(data){
|
success:function(data){console.log(data);
|
||||||
|
|
||||||
var res = JSON.parse(data);
|
var res = JSON.parse(data);
|
||||||
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
|
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
|
||||||
$("#rspContainer").css("display", "block");
|
$("#rspContainer").css("display", "block");
|
||||||
|
@ -81,13 +83,15 @@ $(function() {
|
||||||
var mnt_block = "";
|
var mnt_block = "";
|
||||||
for (i in selected_node_body.mounts) {
|
for (i in selected_node_body.mounts) {
|
||||||
var mnt = selected_node_body.mounts[i];
|
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_block += '<a href=\'javascript:void(0)\' onClick=\'unmount("' + selected_node + '", "'
|
||||||
+ mnt.mountpoint + "<br>Mountopts: "
|
+ selected_node_body.mounts[i].mountpoint + '", "'
|
||||||
+ mnt.mountopts + "<br>Fstype: "
|
+ selected_node_body.mounts[i].block + '")\' >unmount</a><br>Mountpoint: '
|
||||||
+ mnt.fstype +
|
+ mnt.mountpoint + '<br>Mountopts: '
|
||||||
"<br>Pool: " + mnt.pool +
|
+ mnt.mountopts + '<br>Fstype: '
|
||||||
"<br>Image: " + mnt.image +
|
+ mnt.fstype
|
||||||
"<br>Block: " + mnt.block +"<br>";
|
+ '<br>Pool: ' + mnt.pool
|
||||||
|
+ '<br>Image: ' + mnt.image
|
||||||
|
+ '<br>Block: ' + mnt.block + '<br>';
|
||||||
}
|
}
|
||||||
$("#mon").html(mnt_block);
|
$("#mon").html(mnt_block);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user