first commit

This commit is contained in:
root
2023-06-22 15:30:22 +02:00
commit 4d9979354c
3294 changed files with 445677 additions and 0 deletions

77
web/templates/backup.html Normal file
View File

@@ -0,0 +1,77 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<div class="card">
<div class="card-header">
Containers
</div>
<div class="card-body">
<table class="table table-responsive table-hover table-condensed align-middle mb-0 bg-white">
<tr><th>Name</th><th>Snapshot list</th><th>Create Snapshot</th></tr>
{%for lxc in listlxc %}
<tr><td>{{ lxc[0] | safe }}</td><td><div class="snaplist">
{%for lxc_snap in lxc[1] %}
<table><tr><td>
{{ lxc_snap | safe }}
</td><td>
<form action="/del_snap_lxc" method="post">
<input type="hidden" name="cont" value="{{ lxc[0] | safe }}">
<button type="submit" name="delete" value="{{ lxc_snap | safe }}"><span class="fas fa-trash"></span></button>
</form>
</td><td>
<form action="/rest_snap_lxc" method="post">
<input type="hidden" name="cont" value="{{ lxc[0] | safe }}">
<button type="submit" name="restore" value="{{ lxc_snap | safe }}"><span class="fas fa-arrow-circle-down"></span></button>
</form>
</td></tr></table>
{%endfor%}
</div>
</td><td><form action="/snap_lxc" method="post"><button type="submit" value="{{ lxc[0] }}" name="nom" onclick="loading();" class="deliso"><span class="fas fa-play"> Save</button></form>
</td></tr>
{%endfor%}
</table>
</div></div></div>
<div class="qard">
<div class="card">
<div class="card-header">
Virtual Servers
</div>
<div class="card-body">
<table class="table table-responsive table-hover table-condensed align-middle mb-0 bg-white">
<tr><th>Name</th><th>Snapshot list</th><th>Create Snapshot</th></tr>
{%for vm in listvm %}
<tr><td>{{ vm[0] | safe }}</td><td><div class="snaplist">
{%for vm_snap in vm[1] %}
<table>
<tr>
<td>
{{ vm_snap | safe }}
</td>
<td>
<form action="/del_snap_vm" method="post">
<input type="hidden" name="cont" value="{{ vm[0] | safe }}">
<button type="submit" name="delete" value="{{ vm_snap | safe }}"><span class="fas fa-trash"></span></button>
</form>
</td>
<td>
<form action="/rest_snap_vm" method="post">
<input type="hidden" name="cont" value="{{ vm[0] | safe }}">
<button type="submit" name="restore" value="{{ vm_snap | safe }}"><span class="fas fa-arrow-circle-down"></span></button>
</form>
</td>
</tr>
</table>
{%endfor%}
</td><td><form action="/snap_vm" method="post"><button type="submit" value="{{ vm[0] }}" name="nom" onclick="loading();" class="deliso"><span class="fas fa-play"> Save</button></form>
</td></tr>
{%endfor%}
</table>
</div></div></div>
{% endblock %}
{% include 'foot.html' %}

46
web/templates/base.html Normal file
View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<!-- -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<!-- -->
<link href="{{url_for('static', filename = 'style.css')}}" rel="stylesheet">
{{ fontawesome_css() }}
{{ dropzone.load_css() }}
{{ dropzone.style('border: 2px dashed #000; min-height: 200px;text-align:center;') }}
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<title>{{ title }}</title>
<br>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/css">
<body>
<div class="logout">
<ul>
{% for item in nav.top %}
<li class="{{ 'active' if item.is_active else '' }}">
<a href="{{ item.url }}">{{ item.label }}</a>
</li>
{% endfor %}
<li style="float:right;">
<a href="logout"><span class="fas fa-user" style="display: inline;"></span> Logout</a>
</li>
<li style="float:right;">
<a href="javascript:window.location.href=window.location.href"><span class="fas fa-sync" style="display: inline;"></span></a>
</li>
</ul>
</div>
<!-- <div id="titre">{{ title }}</div> -->
<div class="space"></div>
{{ alertmessage | safe }}
<div id="loading"><center><img src="{{url_for('static', filename = 'logo.gif')}}"></center></div>
<div id="content">
<center>

152
web/templates/build.html Normal file
View File

@@ -0,0 +1,152 @@
{% include 'base.html' %}
{% block main %}
<div class="miniform">
<div class="card">
<div class="card-header">
ISO
</div>
<div class="card-body">
<table class="table table-responsive table-hover table-condensed align-middle mb-0 bg-white">
<tr><th>ISO list</th><th>Delete</th></tr>
{%for iso in listvm_iso %}
<tr><td>{{ iso[0] }} ( {{ iso[1] }} )
</td><td><form action="/deliso" method="post"><button type="submit" value="{{ iso[0] }}" name="fichier" onclick="loading();" class="deliso"><span class="fas fa-trash"></span></button></form>
</td></tr>
{%endfor%}
</table>
</div></div>
</div>
<div class="miniform">
<div class="card">
<div class="card-header">
Upload ISO
</div>
<div class="card-body">
{{ dropzone.create(action='upload') }}
</div>
</div></div><br>
<div><hr></div>
<!-- Avoid a Misalignment -->
<div style="clear: both;"></div>
<!-- -->
<div class="quard">
<div class="card">
<div class="card-header">
Mount ISO on Virtual Server
</div>
<div class="card-body">
<form action="/mountiso" method="post">
<table class="table table-responsive table-hover table-condensed align-middle mb-0 bg-white">
<tr><td>ISO</td><td>Virtual Server</td><td></td></tr>
<tr><td>
<select id="isolist" class="form-control" name="iso" required>
{%for iso in list_iso_mount %}
<option value={{ iso[0] }}>{{ iso[0] }}</option>
{%endfor%}
</select>
</td><td>
<select id="vmlist" class="form-control" name="vm" required>
{%for vm in listvm %}
<option value={{ vm }}>{{ vm }}</option>
{%endfor%}
</select>
</td><td>
<button name="mountiso" type="submit"><span class="fas fa-compact-disc"></span></button>
</td></tr></table>
</form>
</div>
</div>
<!-- Avoid a Misalignment -->
<div style="clear: both;"></div>
<!-- -->
<div class="miniform">
<div class="card">
<div class="card-header">
Create Virtual Server
</div>
<div class="card-body">
<form action="/creationvm" method="post">
<label for="nom">Name</label>
<input type="text" name="nom" class="form-control" placeholder="Server" required><br>
<label for="ram">Memory (in MiB)</label>
<input type="text" name="ram" class="form-control" placeholder="1024" required><br>
<label for="cpu">vCPU</label>
<input type="text" name="cpu" class="form-control" placeholder="1" required><br>
<label for="disk">Disk (in GB)</label>
<input type="text" class="form-control" name="disk" placeholder="10" required><br>
<label for="os">OS</label>
<select id="profilelist" class="form-control" name="os" placeholder="Profile" required>
{%for profile in list_profiles %}
<option value={{ profile }}>{{ profile }}</option>
{%endfor%}
</select><br>
<label for="iso">ISO</label>
<select id="isolist" class="form-control" name="iso" required>
{%for iso in list_iso %}
<option value={{ iso[0] }}>{{ iso[0] }}</option>
{%endfor%}
</select><br>
<label for="net">Network</label>
<select id="netlist" class="form-control" name="net" required>
{%for net in list_net %}
<option value={{ net }}>{{ net }}</option>
{%endfor%}
</select><br>
<button name="creation" type="submit"><span class="fas fa-cube"></span></button>
</form>
</div>
</div></div>
<div class="miniform">
<div class="card">
<div class="card-header">
Create Container
</div>
<div class="card-body">
<form action="/creation" method="post">
<label for="cnom">Name</label>
<input type="text" id="cnom" name="nom" class="form-control" placeholder="Container" required><br>
<label for="cip">Optional static IP</label>
<input type="text" id="cip" name="ip" class="form-control" placeholder="192.168.XX.XX/YY"><br>
<label for="oslist">OS</label>
<select id="oslist" name="os" class="form-control">
{%for dist in listdistrib %}
<option value={{ dist[1] }}>{{ dist[0] }}</option>
{%endfor%}
</select><br>
<button name="creation" type="submit"><span class="fas fa-cube" onclick="loading();"></span></button>
</form>
</div>
</div></div>
<div class="miniform">
<div class="card">
<div class="card-header">
Rename Container
</div>
<div class="card-body">
<form action="/renamect" method="post">
<p>Be carefull, the container will be stop in order to rename it !</p>
<label for="ctlist">Container</label>
<select id="ctlist" name="nom" class="form-control">
{%for lxc in listlxc%}
<option value={{ lxc }}>{{ lxc }}</option>
{%endfor%}
</select><br>
<label for="fnom">New name</label>
<input class="form-control" id="fnom" type="text" name="newname" placeholder="New Name" required><br>
<button name="renamect" type="submit" onclick="loading();"><span class="fas fa-sort"></span></button>
</form>
</div>
{% endblock %}
{% include 'foot.html' %}

View File

@@ -0,0 +1,26 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<h5>ISO</h5>
<table id="affiche">
<tr><th>ISO list</th><th>Delete</th></tr>
{%for iso in list_iso %}
<tr><td style="height:60px;">{{ iso[0] }} ( {{ iso[1] }} )
</td><td><form action="/deliso" method="post"><button type="submit" value="{{ iso[0] }}" name="fichier" onclick="loading();" class="deliso"><span class="fas fa-trash"></span></button></form>
</td></tr>
{%endfor%}
</table>
</div>
<div class="space"></div>
<div class="qard">
<h5>Upload ISO</h5>
{{ dropzone.create(action='upload') }}
</body>
</div>
<div class="space"></div>
</div>
{% endblock %}
{% include 'foot.html' %}

81
web/templates/foot.html Normal file
View File

@@ -0,0 +1,81 @@
</div>
<div id="Modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<center>
<script language="JavaScript">
document.write('<iframe src="' + window.location.protocol + '//' + window.location.hostname + '/console/" title="Console" width="1024" height="768" style="border:none;"></iframe>' );
</script>
</center>
</div>
</div>
</div>
{{ fontawesome_js() }}
<script type="text/javascript">// <![CDATA[
function loading(){
$("#loading").show();
$("#content").hide();
}
// ]]></script>
<script
src="https://code.jquery.com/jquery-3.6.1.slim.min.js"
integrity="sha256-w8CvhFs7iHNVUtnSP0YKEg00p9Ih13rlL9zGqvLdePA="
crossorigin="anonymous"></script>
</div>
<div style="position:fixed;bottom:0;right:0">Version Beta 2.7</div>
<script>
var modal = document.getElementById("Modal");
var btn = document.getElementById("ModalBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<script>
var opacity=0;
var intervalID=0;
// window.onload=fadeout;
function fadeout(){
setInterval(hide, 100);
}
setTimeout(function(){
fadeout();
}, 3000);
function hide(){
var body=document.getElementById("alert");
opacity =
Number(window.getComputedStyle(body).getPropertyValue("opacity"))
if(opacity>0){
opacity=opacity-0.1;
body.style.opacity=opacity
}
else{
clearInterval(intervalID);
}
}
</script>
{{ dropzone.load_js() }}
{{ dropzone.config() }}
</body>
</html>

10
web/templates/host.html Normal file
View File

@@ -0,0 +1,10 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<h5>{{ hostname | safe }}</h5>
<div class="space"></div>
{{ hostlist | safe }}
</div>
{% endblock %}
{% include 'foot.html' %}

190
web/templates/index.html Normal file
View File

@@ -0,0 +1,190 @@
{% include 'base.html' %}
{% block main %}
<div class="dashform">
<div class="card">
<div class="card-header">
Hostname
</div>
<div class="card-body">
{{ hostname | safe }}
</div>
</div>
</div>
<div class="dashform">
<div class="card">
<div class="card-header">
User
</div>
<div class="card-body">
{{ loguser | safe }}
</div>
</div>
</div>
<div class="dashform">
<div class="card">
<div class="card-header">
Containers
</div>
<div class="card-body">
<span style="color:green;">{{ activ_ct | safe }} up</span>
<span style="color:red;">{{ inactiv_ct | safe }} down</span>
</div>
</div>
</div>
<div class="dashform">
<div class="card">
<div class="card-header">
Virtual Servers
</div>
<div class="card-body">
<span style="color:green;">{{ activ_vm | safe}} up</span>
<span style="color:red;">{{ inactiv_vm | safe}} down</span>
</div>
</div>
</div>
<!-- Avoid a Misalignment -->
<div style="clear: both;"></div>
<!-- -->
<div class="dashform">
<div class="card">
<div class="card-header">
CPU
</div>
<div class="card-body">
<div style="width:200px;height:200px;margin:auto;">
<canvas id="cpuChart" width="50" height="50"></canvas>
</div>
</div>
</div>
</div>
<div class="dashform">
<div class="card">
<div class="card-header">
RAM
</div>
<div class="card-body">
<div style="width:200px;height:200px;margin:auto;">
<canvas id="ramChart" width="50" height="50"></canvas>
</div>
Buffers:{{ memory_buffers | safe }} Cached:{{ memory_cached | safe }}<br>Free :{{ memory_free | safe }} Total :{{ memory_total | safe }}
</div>
</div>
</div>
<div class="dashform">
<div class="card">
<div class="card-header">
Disk
</div>
<div class="card-body">
<div style="width:200px;height:200px;margin:auto;">
<canvas id="diskChart" width="50" height="50"></canvas>
</div>
Used :{{ host_disk_used | safe }}GB / Total :{{ host_disk_total | safe }}GB
</div>
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.bundle.min.js"></script>
<script>
var datadisk = {
labels: [
"Use ({{ host_disk_percent | safe}}%)",
"Free"
],
datasets: [
{
data: [{{ host_disk_percent | safe}}, {{ host_disk_free_percent | safe}}],
backgroundColor: [
"#008000",
"#C0C0C0"
],
hoverBackgroundColor: [
"#008000",
"#C0C0C0"
]
}]
};
var ctx3 = document.getElementById("diskChart");
var myDoughnutChart = new Chart(ctx3, {
type: 'doughnut',
data: datadisk,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});
var datacpu = {
labels: [
"Use ({{ cpu_percent_used | safe}}%)",
"Free"
],
datasets: [
{
data: [{{ cpu_percent_used | safe}}, {{ cpu_percent_free | safe}}],
backgroundColor: [
"#008000",
"#C0C0C0"
],
hoverBackgroundColor: [
"#008000",
"#C0C0C0"
]
}]
};
var ctx = document.getElementById("cpuChart");
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: datacpu,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});
var dataram = {
labels: [
"Use ({{ mem_percent_used | safe}}%)",
"Free"
],
datasets: [
{
data: [{{ mem_percent_used | safe}}, {{ mem_percent_free | safe}}],
backgroundColor: [
"#008000",
"#C0C0C0"
],
hoverBackgroundColor: [
"#008000",
"#C0C0C0"
]
}]
};
var ctx2 = document.getElementById("ramChart");
// And for a doughnut chart
var myDoughnutChart2 = new Chart(ctx2, {
type: 'doughnut',
data: dataram,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});
</script>
{% endblock %}
{% include 'foot.html' %}

32
web/templates/login.html Normal file
View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<link href="{{url_for('static', filename = 'style.css')}}" rel="stylesheet">
{{ fontawesome_css() }}
<div id="titre">{{ title }}</div>
<div class="space"></div>
{{ alertmessage | safe }}
<br>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/c>
<link href='https://fonts.googleapis.com/css?family=Dosis' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Nunito' rel='stylesheet' type='text/css'>
<body>
<center>
<div class="space"></div>
<center>
<div class="login">
<h3>Login</h3>
<form action="/login" method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button name="Login" type="submit"><span class="fas fa-user" onclick="loading();"></span></button>
</form>
</div>
</center>
{% include 'foot.html' %}

21
web/templates/logs.html Normal file
View File

@@ -0,0 +1,21 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<h3>Logs</h3>
<pre id="output" style="text-align:left"></pre>
<script>
var output = document.getElementById('output');
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ url_for('stream') }}');
xhr.send();
setInterval(function() {
output.textContent = xhr.responseText;
}, 1000);
</script>
{% endblock %}
{% include 'foot.html' %}

117
web/templates/monit.html Normal file
View File

@@ -0,0 +1,117 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<div class="card">
<div class="card-header">
Global Monitoring
</div>
<div class="card-body">
<table class="table table-responsive table-condensed align-middle">
<tr><th><span class="fas fa-microchip"></span></th><th><span class="fas fa-memory"></span></th></tr>
<tr><td>
<div style="width:240px;height:240px;margin:auto;">
<canvas id="cpuChart" width="50" height="50"></canvas>
</div>
</td><td>
<div style="width:240px;height:240px;margin:auto;">
<canvas id="ramChart" width="50" height="50"></canvas>
</div>
</td></tr><tr><td>
{{ global_cpu | safe}}
</td><td>
{{ global_memory | safe}}
</td></tr></table>
</div>
</div></div>
<div class="qard">
<div class="card">
<div class="card-header">
Containers
</div>
<div class="card-body">
{{ lxc_monit | safe}}
</div>
</div>
</div>
<div class="qard">
<div class="card">
<div class="card-header">
Virtual Servers
</div>
<div class="card-body">
{{ vm_monit | safe}}
</div>
</div>
</div>
</body>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.bundle.min.js"></script> -->
<script src="{{url_for('static', filename = 'Chart.bundle.min.js')}}" ></script>
<script>
var datacpu = {
labels: [
"Use ({{ cpu_percent_used | safe}}%)",
"Free"
],
datasets: [
{
data: [{{ cpu_percent_used | safe}}, {{ cpu_percent_free | safe}}],
backgroundColor: [
"#008000",
"#C0C0C0"
],
hoverBackgroundColor: [
"#008000",
"#C0C0C0"
]
}]
};
var ctx = document.getElementById("cpuChart");
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: datacpu,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});
var dataram = {
labels: [
"Use ({{ mem_percent_used | safe}}%)",
"Free"
],
datasets: [
{
data: [{{ mem_percent_used | safe}}, {{ mem_percent_free | safe}}],
backgroundColor: [
"#008000",
"#C0C0C0"
],
hoverBackgroundColor: [
"#008000",
"#C0C0C0"
]
}]
};
var ctx2 = document.getElementById("ramChart");
// And for a doughnut chart
var myDoughnutChart2 = new Chart(ctx2, {
type: 'doughnut',
data: dataram,
options: {
rotation: 1 * Math.PI,
circumference: 1 * Math.PI
}
});
</script>
{% endblock %}
{% include 'foot.html' %}

21
web/templates/pool.html Normal file
View File

@@ -0,0 +1,21 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<div class="card">
<div class="card-header">
Pool
</div>
<div class="card-body">
{{ pool_det | safe}}
</div></div>
<div class="card">
<div class="card-header">
Volumes
</div>
<div class="card-body">
{{ volumes_det | safe}}
</div>
</div></div>
</body>
{% endblock %}
{% include 'foot.html' %}

View File

@@ -0,0 +1,21 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
<div class="card">
<div class="card-header">
Pool
</div>
<div class="card-body">
{{ pool_det | safe}}
</div></div>
<div class="card">
<div class="card-header">
Volumes
</div>
<div class="card-body">
{{ volumes_det | safe}}
</div>
</div></div>
</body>
{% endblock %}
{% include 'foot.html' %}

11
web/templates/state.html Normal file
View File

@@ -0,0 +1,11 @@
{% include 'base.html' %}
{% block main %}
<div class="qard">
{{ state_all | safe }}
</div>
{% endblock %}
{% block second %}
{% endblock %}
{% include 'foot.html' %}