stable
This commit is contained in:
parent
2a8e165efd
commit
deacb40cae
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"api": "http://10.8.0.34:9076/v1/",
|
"api": "http://10.8.0.34:9076/v1",
|
||||||
"ws": "ws://php.difrex.ru/ws"
|
"ws": "ws://php.difrex.ru/ws"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,22 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
$('#mountFormTrigger').click(function(event){
|
$('#mountFormTrigger').click(function(event){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"get_status.php",
|
url:"status",
|
||||||
success:function(data){
|
|
||||||
var status = JSON.parse(data);
|
|
||||||
var htmlSelect = '';
|
|
||||||
for (n in status["quorum"]) { htmlSelect += "<option value=" + n + ">" + n + "</option>";}
|
|
||||||
|
|
||||||
$('#selectNode').html(htmlSelect);
|
|
||||||
console.log(htmlSelect);}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#mountFormTrigger').click(function(event){
|
|
||||||
$.ajax({
|
|
||||||
url:"get_status.php",
|
|
||||||
success:function(data){
|
success:function(data){
|
||||||
var status = JSON.parse(data);
|
var status = JSON.parse(data);
|
||||||
var htmlSelect = '';
|
var htmlSelect = '';
|
||||||
for (n in status["quorum"]) { htmlSelect += "<option value=" + n + ">" + n + "</option>";}
|
for (n in status["quorum"]) { htmlSelect += "<option value=" + n + ">" + n + "</option>";}
|
||||||
|
|
||||||
$('#selectNode').html(htmlSelect);
|
$('#selectNode').html(htmlSelect);
|
||||||
console.log(htmlSelect);}
|
console.log(htmlSelect);}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
console.log( "ready!" );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function resolve() {
|
function resolve() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"resolve.php",
|
url:"/resolve",
|
||||||
data:{"node":deadNode},
|
data:{"node":deadNode},
|
||||||
success:function(data){$('#details').css("display", "none");}
|
success:function(data){$('#details').css("display", "none");}
|
||||||
})
|
})
|
||||||
@ -44,7 +26,7 @@ $(function() {
|
|||||||
var u = confirm(a + ": confirm unmount of " + b);
|
var u = confirm(a + ": confirm unmount of " + b);
|
||||||
if (u == true) {
|
if (u == true) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"unmount.php",
|
url:"unmount",
|
||||||
data:{"node":a, "mountpoint":b, "block":c},
|
data:{"node":a, "mountpoint":b, "block":c},
|
||||||
success:function(data){
|
success:function(data){
|
||||||
var res = JSON.parse(data);
|
var res = JSON.parse(data);
|
||||||
@ -58,6 +40,12 @@ $(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function displayData(a){
|
function displayData(a){
|
||||||
$("#status").html("<p>"+a.health+"</p>");
|
$("#status").html("<p>"+a.health+"</p>");
|
||||||
if (a.health == 'deadly.') {
|
if (a.health == 'deadly.') {
|
||||||
|
@ -15,12 +15,14 @@
|
|||||||
<a href='/'><img src={% static 'images-logo.png' %} class="w3-right w3-hover-opacity" height="33.82em" ></a>
|
<a href='/'><img src={% static 'images-logo.png' %} class="w3-right w3-hover-opacity" height="33.82em" ></a>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{% verbatim %}
|
||||||
<div class="w3-container">
|
<div class="w3-container">
|
||||||
<div class="w3-row">
|
<div class="w3-row">
|
||||||
<div class="sidenav w3-container w3-light-grey w3-col m3" id="id01">
|
<div class="sidenav w3-container w3-light-grey w3-col m3" id="id01">
|
||||||
<h4> Leader: </h4> <span id='leader' class="tablink"></span>
|
<h4> Leader: </h4> <span id='leader' class="tablink"></span>
|
||||||
<h4>Nodes: </h4>
|
<h4>Nodes: </h4>
|
||||||
<a w3-repeat="node in quorum" href="javascript:void(0)" class="tablink" onclick="openNode(event, '{{node}}')" style='display:none'>{{node}}</a>
|
<a w3-repeat="node in quorum" href="javascript:void(0)" class="tablink" onclick="openNode(event, '{{node}}')" style='display:none'>{{node}}</a>
|
||||||
|
{% endverbatim %}
|
||||||
<h4>Metrics: </h4>
|
<h4>Metrics: </h4>
|
||||||
|
|
||||||
{% for k,v in metrics.items %} {{k}} {{v}}<br> {% endfor %}
|
{% for k,v in metrics.items %} {{k}} {{v}}<br> {% endfor %}
|
||||||
@ -30,11 +32,13 @@
|
|||||||
<div class="w3-padding w3-display-left" id="status">Status... </div>
|
<div class="w3-padding w3-display-left" id="status">Status... </div>
|
||||||
<a href="javascript:void(0)" class="w3-right" id="showDeadlyDetails" onClick="openNode(event, 'dead')" style="display: none; padding:15px;">Show details</a>
|
<a href="javascript:void(0)" class="w3-right" id="showDeadlyDetails" onClick="openNode(event, 'dead')" style="display: none; padding:15px;">Show details</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="rspContainer" class="w3-container w3-animate-opacity" style="display:none">
|
|
||||||
|
<div id="rspContainer" class="w3-container w3-animate-opacity" style="display: none">
|
||||||
<span onclick="this.parentElement.style.display='none'" class="w3-closebtn">×</span>
|
<span onclick="this.parentElement.style.display='none'" class="w3-closebtn">×</span>
|
||||||
<div id="rsp">
|
<div id="rsp">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id = "details" class="w3-container" style="display:none;">
|
<div id = "details" class="w3-container" style="display:none;">
|
||||||
<table class='w3-table w3-bordered' id="id02">
|
<table class='w3-table w3-bordered' id="id02">
|
||||||
<tr><td> Node:</td> <td> <span id='name'></span></td> </tr>
|
<tr><td> Node:</td> <td> <span id='name'></span></td> </tr>
|
||||||
@ -54,7 +58,7 @@
|
|||||||
<span onclick="document.getElementById('mount').style.display='none'" class="w3-closebtn">×</span>
|
<span onclick="document.getElementById('mount').style.display='none'" class="w3-closebtn">×</span>
|
||||||
<h2>Mount</h2>
|
<h2>Mount</h2>
|
||||||
</header>
|
</header>
|
||||||
<form method="post" action="/" role="form" class="w3-container form">
|
<form method="post" action="/" role="form" class="w3-container form" id="mountForm"> {% csrf_token %}
|
||||||
<label class="w3-label w3-text-black">Node: <select name="node" class="w3-select" id='selectNode'></select> </label><br>
|
<label class="w3-label w3-text-black">Node: <select name="node" class="w3-select" id='selectNode'></select> </label><br>
|
||||||
<!--label class="w3-label w3-text-black">Node: <input name="node" class="w3-input" type="text" required> </label><br-->
|
<!--label class="w3-label w3-text-black">Node: <input name="node" class="w3-input" type="text" required> </label><br-->
|
||||||
<label class="w3-label w3-text-black">Pool: <input name="pool" class="w3-input" type="text"> </label><br>
|
<label class="w3-label w3-text-black">Pool: <input name="pool" class="w3-input" type="text"> </label><br>
|
||||||
@ -69,13 +73,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
console.log('{{status|escapejs}}')
|
//var res = '{{status|escapejs}}';
|
||||||
var res = '{{status|escapejs}}';
|
|
||||||
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
|
|
||||||
$("#rspContainer").css("display", "block");
|
|
||||||
$("#rsp").html(message)
|
|
||||||
if (res["state"] == 'OK'){$("#rspContainer").css("background-color", "#4CAF50" );}
|
|
||||||
else {$("#rspContainer").css("background-color", "#f44336" )}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -87,5 +85,28 @@
|
|||||||
a = JSON.parse(evt.data);
|
a = JSON.parse(evt.data);
|
||||||
displayData(a);
|
displayData(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$('#mountForm').submit(function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
$.ajax({
|
||||||
|
url:"mount",
|
||||||
|
data:$(this).serialize(),
|
||||||
|
method:'POST',
|
||||||
|
success:function(data){
|
||||||
|
console.log(data);
|
||||||
|
$('#mount').css('display', 'none');
|
||||||
|
$('input').val('');
|
||||||
|
var res = JSON.parse(data);
|
||||||
|
|
||||||
|
message = "<h3>" + res["state"] + "</h3> <p>"+ res["message"] +"</p>";
|
||||||
|
$("#rspContainer").css("display", "block");
|
||||||
|
$("#rsp").html(message)
|
||||||
|
if (res["state"] == 'OK'){$("#rspContainer").css("background-color", "#4CAF50" );}
|
||||||
|
else {$("#rspContainer").css("background-color", "#f44336" )}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -21,10 +21,8 @@ urlpatterns = [
|
|||||||
url(r'^admin/', admin.site.urls),
|
url(r'^admin/', admin.site.urls),
|
||||||
url(r'^$', views.panel),
|
url(r'^$', views.panel),
|
||||||
url(r'^status$', views.get_status),
|
url(r'^status$', views.get_status),
|
||||||
url(r'^node$', views.node),
|
|
||||||
url(r'^health$', views.health),
|
|
||||||
url(r'^mount$', views.mount),
|
url(r'^mount$', views.mount),
|
||||||
url(r'^unmount$', views.get_status),
|
url(r'^unmount$', views.unmount),
|
||||||
url(r'^resolve$', views.resolve),
|
url(r'^resolve$', views.resolve),
|
||||||
url(r'^metrics$', views.get_metrics),
|
url(r'^metrics$', views.get_metrics),
|
||||||
]
|
]
|
||||||
|
@ -1,51 +1,62 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
def get_status():
|
def status():
|
||||||
with open('conf.json') as conf:
|
with open('conf.json') as conf:
|
||||||
status = json.load(conf)["api"] + '/status'
|
status = json.load(conf)["api"] + '/status'
|
||||||
try: res = requests.get(status)
|
try: res = requests.get(status).content
|
||||||
except: res = 'connection can\'t be established'
|
except: res = 'connection can\'t be established'
|
||||||
return res.content
|
return res
|
||||||
|
|
||||||
def node():
|
def get_status(request):
|
||||||
pass
|
my_status = status()
|
||||||
|
return JsonResponse(my_status, safe=False)
|
||||||
|
|
||||||
def health():
|
def mount(request):
|
||||||
pass
|
if request.method == 'POST':
|
||||||
|
data = request.POST.dict()
|
||||||
|
#s = mount(data)
|
||||||
|
with open('conf.json') as conf:
|
||||||
|
url = json.load(conf)["api"] + '/mount'
|
||||||
|
res = requests.post(url, json.dumps(data))
|
||||||
|
print res
|
||||||
|
return JsonResponse(res.content, safe=False)
|
||||||
|
|
||||||
def mount():
|
def unmount(request):
|
||||||
pass
|
print request.GET.dict()
|
||||||
|
with open('conf.json') as conf:
|
||||||
def unmount():
|
url = json.load(conf)["api"] + '/umount'
|
||||||
pass
|
#data = json.dumps({'node': 'ceph1', 'mountpoint': '/mnt', 'block': 'rbd0'})
|
||||||
|
data = request.GET.dict()
|
||||||
|
try: res = requests.post(url, json.dumps(data)).content
|
||||||
|
except: res = 'connection can\'t be established'
|
||||||
|
return JsonResponse(res, safe=False)
|
||||||
|
|
||||||
def resolve():
|
def resolve():
|
||||||
pass
|
with open('conf.json') as conf:
|
||||||
|
url = json.load(conf)["api"] + '/resolve'
|
||||||
|
data = request.GET.dict()
|
||||||
|
res = requests.post(metrics, json.dumps(data))
|
||||||
|
return JsonResponse(res.content, safe=False)
|
||||||
|
|
||||||
def get_metrics():
|
def get_metrics():
|
||||||
#with open('conf.json') as conf:
|
|
||||||
# api = json.load(conf)["api"]
|
|
||||||
#try: res = requests.get(api + metrics)
|
|
||||||
#return api
|
|
||||||
with open('conf.json') as conf:
|
with open('conf.json') as conf:
|
||||||
metrics = json.load(conf)["api"] + '/metrics'
|
metrics = json.load(conf)["api"] + '/metrics'
|
||||||
res = requests.get(metrics)
|
try: res = requests.get(metrics).content
|
||||||
print res
|
except: res = 'connection can\'t be established'
|
||||||
#except: res = 'connection can\'t be established'
|
return res
|
||||||
return res.content
|
|
||||||
|
|
||||||
def panel(request):
|
def panel(request):
|
||||||
with open('conf.json') as conf:
|
with open('conf.json') as conf:
|
||||||
ws = json.load(conf)["ws"]
|
ws = json.load(conf)["ws"]
|
||||||
metrics = json.loads(get_metrics())
|
metrics = json.loads(get_metrics())
|
||||||
status = get_status()
|
my_status = status()
|
||||||
return render(request, 'rbmd/index.html', {'ws' : ws, 'metrics' : metrics, 'status' : status})
|
return render(request, 'rbmd/index.html', {'ws' : ws, 'metrics' : metrics, 'status' : my_status})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user