mirror of
https://github.com/retspen/webvirtcloud
synced 2026-07-07 12:05:42 +00:00
Compare commits
11 commits
edd265d5a5
...
6e76eb2cd9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e76eb2cd9 | ||
|
|
c099cd06ef | ||
|
|
beb13cdea1 | ||
|
|
2941840f0d | ||
|
|
5880b91c7a | ||
|
|
3cd4212cdd | ||
|
|
96ea999926 | ||
|
|
3403d21fea | ||
|
|
907d47ab78 | ||
|
|
da9fbeaff4 | ||
|
|
407605761f |
25 changed files with 8705 additions and 11594 deletions
|
|
@ -1,30 +1,37 @@
|
||||||
{% extends 'base.html' %}
|
{% extends "base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load django_bootstrap5 %}
|
{% load django_bootstrap5 %}
|
||||||
|
|
||||||
{% block title %}WebVirtCloud{% endblock title %}
|
{% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign In with OTP" %}{% endblock title %}
|
||||||
|
|
||||||
{% block page_heading %}WebVirtCloud{% endblock page_heading %}
|
{% block style %}
|
||||||
|
<link href="{% static "css/signin.css" %}" rel="stylesheet">
|
||||||
|
{% endblock style %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="login-box">
|
||||||
<div class="col-6 offset-3" role="main">
|
<div class="page-header">
|
||||||
<div class="card">
|
<a href="/"><h1>WebVirtCloud</h1></a>
|
||||||
<div class="card-body">
|
</div>
|
||||||
{% if form.errors %}
|
<hr>
|
||||||
{% bootstrap_form_errors form %}
|
<div class="col-12" role="main">
|
||||||
{% endif %}
|
{% if form.errors %}
|
||||||
<form class="form-signin" method="post" role="form" aria-label="Login form">
|
<div class="alert alert-danger" role="alert">
|
||||||
{% csrf_token %}
|
{% bootstrap_form_errors form %}
|
||||||
{% bootstrap_field form.username layout='horizontal' %}
|
|
||||||
{% bootstrap_field form.password layout='horizontal' %}
|
|
||||||
{% bootstrap_field form.otp_token layout='horizontal' %}
|
|
||||||
<a href="{% url 'accounts:email_otp' %}" class="float-end mb-2">{% trans "I do not have/lost my OTP!" %}</a>
|
|
||||||
<button class="btn btn-lg btn-success btn-block" type="submit">{% trans "Sign In" %}</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
|
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||||
|
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
|
||||||
|
{% bootstrap_field form.username layout='inline' %}
|
||||||
|
{% bootstrap_field form.password layout='inline' %}
|
||||||
|
{% bootstrap_field form.otp_token layout='inline'%}
|
||||||
|
<a href="{% url 'accounts:email_otp' %}" class="float-end">{% trans "I do not have/lost my OTP!" %}</a>
|
||||||
|
<br>
|
||||||
|
<div class="d-grid">
|
||||||
|
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
@ -2,31 +2,35 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign In" %}{% endblock %}
|
|
||||||
|
{% block title %}{% trans "WebVirtCloud" %} - {% trans "Sign In" %}{% endblock title %}
|
||||||
|
|
||||||
{% block style %}
|
{% block style %}
|
||||||
<link href="{% static "css/signin.css" %}" rel="stylesheet">
|
<link href="{% static "css/signin.css" %}" rel="stylesheet">
|
||||||
{% endblock style %}
|
{% endblock style %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="page-header">
|
<div class="login-box">
|
||||||
<a class="" href="/"><h1>WebVirtCloud</h1></a>
|
<div class="page-header">
|
||||||
</div>
|
<a href="/"><h1>WebVirtCloud</h1></a>
|
||||||
<div class="col-12" role="main">
|
</div>
|
||||||
{% if form.errors %}
|
<hr>
|
||||||
<div class="alert alert-danger">
|
<div class="col-12" role="main">
|
||||||
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
|
{% if form.errors %}
|
||||||
{% trans "Incorrect username or password." %}
|
<div class="alert alert-danger" role="alert">
|
||||||
</div>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
{% endif %}
|
{% trans "Incorrect username or password." %}
|
||||||
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
</div>
|
||||||
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
|
{% endif %}
|
||||||
<input type="text" class="form-control" name="username" placeholder="{% trans "User" %}" autocapitalize="none" autocorrect="off" autofocus>
|
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||||
<input type="password" class="form-control" name="password" placeholder="{% trans "Password" %}">
|
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
|
||||||
<input type="hidden" name="next" value="{{ next }}">
|
<input type="text" class="form-control" name="username" placeholder="{% trans 'User' %}" autocapitalize="none" autocorrect="off" autofocus required>
|
||||||
<div class="d-grid">
|
<input type="password" class="form-control" name="password" placeholder="{% trans 'Password' %}" required>
|
||||||
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
<input type="hidden" name="next" value="{{ next }}">
|
||||||
</div>
|
<div class="d-grid">
|
||||||
</form>
|
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -5,7 +5,7 @@ from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_noop as _
|
||||||
from logs.views import addlogmsg
|
from logs.views import addlogmsg
|
||||||
|
|
||||||
from appsettings.models import AppSettings
|
from appsettings.models import AppSettings
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ class Compute(Model):
|
||||||
def cpu_count(self):
|
def cpu_count(self):
|
||||||
return self.proxy.get_node_info()[3]
|
return self.proxy.get_node_info()[3]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def cpu_usage(self):
|
||||||
|
return round(self.proxy.get_cpu_usage().get('usage'))
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def ram_size(self):
|
def ram_size(self):
|
||||||
return self.proxy.get_node_info()[2]
|
return self.proxy.get_node_info()[2]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
Django==3.2.18
|
Django==3.2.19
|
||||||
django_bootstrap5==23.1
|
django_bootstrap5==23.1
|
||||||
django-login-required-middleware==0.9.0
|
django-login-required-middleware==0.9.0
|
||||||
django-otp==1.1.6
|
django-otp==1.1.6
|
||||||
django-icons==23.1
|
django-icons==23.2
|
||||||
django-qr-code==3.1.1
|
django-qr-code==3.1.1
|
||||||
gunicorn==20.1.0
|
gunicorn==20.1.0
|
||||||
libsass==0.22.0
|
libsass==0.22.0
|
||||||
libvirt-python==9.2.0
|
libvirt-python==9.3.0
|
||||||
lxml==4.9.2
|
lxml==4.9.2
|
||||||
qrcode==7.4.2
|
qrcode==7.4.2
|
||||||
rwlock==0.0.7
|
rwlock==0.0.7
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
-r ../conf/requirements.txt
|
-r ../conf/requirements.txt
|
||||||
coverage==7.2.3
|
coverage==7.2.5
|
||||||
django-debug-toolbar==4.0.0
|
django-debug-toolbar==4.0.0
|
||||||
pycodestyle==2.10.0
|
pycodestyle==2.10.0
|
||||||
pyflakes==3.0.1
|
pyflakes==3.0.1
|
||||||
pylint==2.17.3
|
pylint==2.17.4
|
||||||
yapf==0.33.0
|
yapf==0.33.0
|
||||||
black==23.3.0
|
black==23.3.0
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@
|
||||||
<script src="{% static 'js/filter-table.js' %}"></script>
|
<script src="{% static 'js/filter-table.js' %}"></script>
|
||||||
{% if request.user.is_superuser %}
|
{% if request.user.is_superuser %}
|
||||||
<script>
|
<script>
|
||||||
function goto_compute() {
|
function goto_compute(compute) {
|
||||||
let compute = $("#compute_select").val();
|
//let compute = $("#compute_select").val();
|
||||||
window.location.href = "{% url 'instances:create_instance_select_type' 1 %}".replace(1, compute);
|
window.location.href = "{% url 'instances:create_instance_select_type' 1 %}".replace(1, compute);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<!-- Modal pool -->
|
<!-- Modal pool -->
|
||||||
<div class="modal fade" id="AddInstance" tabindex="-1" role="dialog" aria-labelledby="AddInstanceModal" aria-hidden="true">
|
<div class="modal fade" id="AddInstance" tabindex="-1" role="dialog" aria-labelledby="AddInstanceModal" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog modal-dialog-scrollable modal-lg">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">{% trans "Choose a compute for new instance" %}</h5>
|
<h5 class="modal-title">{% trans "Choose a compute for new instance" %}</h5>
|
||||||
|
|
@ -15,34 +15,51 @@
|
||||||
<form method="post" aria-label="Select compute for instance create form">
|
<form method="post" aria-label="Select compute for instance create form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-4 col-form-label">{% trans "Compute" %}</label>
|
<table class="table">
|
||||||
<div class="col-sm-6">
|
<thead>
|
||||||
<select class="form-select" id="compute_select">
|
<tr style="cursor:default;pointer-events:none">
|
||||||
<option>{% trans "Please select" %}</option>
|
<th>{% trans "Name" %}</th>
|
||||||
|
<th>{% trans "VCPU" %}
|
||||||
|
<th>{% trans "Cpu Usage" %}</th>
|
||||||
|
<th>{% trans "Memory" %}</th>
|
||||||
|
<th>{% trans "Mem Usage" %}</th>
|
||||||
|
<th>{% trans "Action" %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for compute in computes %}
|
{% for compute in computes %}
|
||||||
<option {% if compute.status is not True %} class="font-italic text-muted" {% else %} value="{{ compute.id }}" {% endif %}>{{ compute.name }}</option>
|
{% if compute.status is True %}
|
||||||
{% empty %}
|
<tr style="text-decoration: none">
|
||||||
<option value="None">{% trans "None" %}</option>
|
<td>{{ compute.name }}</td>
|
||||||
|
<td>{{ compute.cpu_count }}</td>
|
||||||
|
<td>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar" style="width: {{ compute.cpu_usage }}%"
|
||||||
|
aria-valuenow="{{ compute.cpu_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.cpu_usage }}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>{{ compute.ram_size|filesizeformat }}</td>
|
||||||
|
<td>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar" style="width: {{ compute.ram_usage }}%"
|
||||||
|
aria-valuenow="{{ compute.ram_usage }}" aria-valuemin="0" aria-valuemax="100">{{ compute.ram_usage }}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="col-1">
|
||||||
|
<button class="btn btn-success btn-sm" type="button" onclick="goto_compute('{{ compute.id }}');">
|
||||||
|
{% trans "Choose" %}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</tbody>
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
|
||||||
{% trans "Close" %}
|
|
||||||
</button>
|
|
||||||
{% if computes %}
|
|
||||||
<button type="submit" class="btn btn-primary" name="choose" onclick='goto_compute()'>
|
|
||||||
{% trans "Choose" %}
|
|
||||||
</button>
|
|
||||||
{% else %}
|
|
||||||
<button class="btn btn-primary disabled">
|
|
||||||
{% trans "Choose" %}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div> <!-- /.modal-content -->
|
</div> <!-- /.modal-content -->
|
||||||
</div> <!-- /.modal-dialog -->
|
</div> <!-- /.modal-dialog -->
|
||||||
</div> <!-- /.modal -->
|
</div> <!-- /.modal -->
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,10 @@
|
||||||
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="takeextsnapshot">
|
<div role="tabpanel" class="tab-pane tab-pane-bordered" id="takeextsnapshot">
|
||||||
{% if instance.status != 5 %}
|
{% if instance.status != 5 %}
|
||||||
<p>{% trans "You can get external snapshots within this tab." %}</p>
|
<p>{% trans "You can get external snapshots within this tab." %}</p>
|
||||||
<p class="text-primary">{% trans "External snapshots are experimental in this stage, use it if you know what you are doing. It may require manual intervention." %}</p>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "Create an external snapshot" %}</p>
|
<p>{% trans "Create an external snapshot" %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p class="text-danger">{% trans "Give your External Snapshot a <b>distinctive description</b> so it wouldn't get mixed with other snapshots." %}</p>
|
<p class="fst-italic">{% trans "External snapshots are experimental in this stage, use it if you know what you are doing. 'Revert Snapshot' may require manual operation with CLI." %}</p>
|
||||||
<form action="{% url 'instances:create_external_snapshot' instance.id %}" method="post" role="form" aria-label="Create snapshot form">
|
<form action="{% url 'instances:create_external_snapshot' instance.id %}" method="post" role="form" aria-label="Create snapshot form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
|
|
@ -63,7 +62,7 @@
|
||||||
<input type="submit" class="btn btn-lg btn-success float-end" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
|
<input type="submit" class="btn btn-lg btn-success float-end" name="snapshot" value="{% trans "Take Snapshot" %}" onclick="showPleaseWaitDialog();">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-danger">{% trans "WebVirtCloud supports only one external snapshot at the moment." %}</p>
|
<p class="text-danger font-monospace small">{% trans "WebVirtCloud supports only one external snapshot at the moment." %}</p>
|
||||||
</form>
|
</form>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div> <!--tab pane takeextsnapshot-->
|
</div> <!--tab pane takeextsnapshot-->
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="false">
|
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="false" onclick="update_logs_table(vname);">
|
||||||
{% trans "Logs" %}
|
{% trans "Logs" %}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from django.contrib.auth.models import User
|
||||||
from django.http import Http404, HttpResponse, JsonResponse
|
from django.http import Http404, HttpResponse, JsonResponse
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_noop as _
|
||||||
from libvirt import (VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,
|
from libvirt import (VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,
|
||||||
VIR_DOMAIN_UNDEFINE_NVRAM,
|
VIR_DOMAIN_UNDEFINE_NVRAM,
|
||||||
VIR_DOMAIN_START_PAUSED,
|
VIR_DOMAIN_START_PAUSED,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@ from computes.models import Compute
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_noop as _
|
||||||
from libvirt import libvirtError
|
from libvirt import libvirtError
|
||||||
from logs.views import addlogmsg
|
from logs.views import addlogmsg
|
||||||
from vrtManager import util
|
from vrtManager import util
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
/* body {
|
||||||
|
background: rgba(203,203,203,1)
|
||||||
|
} */
|
||||||
|
.login-box {
|
||||||
|
margin-top: 25%;
|
||||||
|
display: block;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0px 0px 20px black;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding-top: 5%;
|
||||||
|
padding-bottom: 1%;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color:#212529;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color:#212529;
|
||||||
|
}
|
||||||
|
|
||||||
.form-signin {
|
.form-signin {
|
||||||
max-width: 330px;
|
max-width: 330px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
|
@ -29,15 +49,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-signin input[type="text"] {
|
.form-signin input[type="text"] {
|
||||||
margin-bottom: -1px;
|
margin-bottom: 10px;
|
||||||
border-bottom-left-radius: 0;
|
border-radius: 5px;
|
||||||
border-bottom-right-radius: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-signin input[type="password"] {
|
.form-signin input[type="password"] {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
border-top-left-radius: 0;
|
border-radius: 5px;
|
||||||
border-top-right-radius: 0;
|
}
|
||||||
|
|
||||||
|
.btn-success {
|
||||||
|
border-width: 2px;
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
.btn-success:hover {
|
||||||
|
border-width: 2px;
|
||||||
|
border-style: solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout {
|
.logout {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import contextlib
|
||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
import subprocess
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from libvirt import (
|
from libvirt import (
|
||||||
|
|
@ -1255,6 +1254,7 @@ class wvmInstance(wvmConnect):
|
||||||
return iso
|
return iso
|
||||||
|
|
||||||
def delete_all_disks(self):
|
def delete_all_disks(self):
|
||||||
|
self.refresh_instance_pools()
|
||||||
disks = self.get_disk_devices()
|
disks = self.get_disk_devices()
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
vol = self.get_volume_by_path(disk.get("path"))
|
vol = self.get_volume_by_path(disk.get("path"))
|
||||||
|
|
@ -1318,7 +1318,7 @@ class wvmInstance(wvmConnect):
|
||||||
</domainsnapshot>"""
|
</domainsnapshot>"""
|
||||||
|
|
||||||
self._snapshotCreateXML(xml, VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY)
|
self._snapshotCreateXML(xml, VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY)
|
||||||
|
self.refresh_instance_pools()
|
||||||
|
|
||||||
def get_external_snapshots(self):
|
def get_external_snapshots(self):
|
||||||
return self.get_snapshot(VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL)
|
return self.get_snapshot(VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL)
|
||||||
|
|
@ -1350,29 +1350,23 @@ class wvmInstance(wvmConnect):
|
||||||
|
|
||||||
|
|
||||||
def revert_external_snapshot(self, name, date, desc):
|
def revert_external_snapshot(self, name, date, desc):
|
||||||
pool = None
|
|
||||||
snap = self.instance.snapshotLookupByName(name, 0)
|
snap = self.instance.snapshotLookupByName(name, 0)
|
||||||
snap_xml = snap.getXMLDesc(0)
|
snap_xml = snap.getXMLDesc(0)
|
||||||
snapXML = ElementTree.fromstring(snap_xml)
|
snapXML = ElementTree.fromstring(snap_xml)
|
||||||
disks = snapXML.findall('inactiveDomain/devices/disk')
|
|
||||||
if not disks: disks = snapXML.findall('domain/devices/disk')
|
|
||||||
|
|
||||||
self.start(flags=VIR_DOMAIN_START_PAUSED) if self.get_status() == 5 else None
|
self.start(flags=VIR_DOMAIN_START_PAUSED) if self.get_status() == 5 else None
|
||||||
|
self.delete_all_disks()
|
||||||
|
|
||||||
disk_info = self.get_disk_devices()
|
|
||||||
for disk in disk_info:
|
|
||||||
vol_snap = self.get_volume_by_path(disk["path"])
|
|
||||||
pool = vol_snap.storagePoolLookupByVolume()
|
|
||||||
pool.refresh(0)
|
|
||||||
vol_snap.delete(0)
|
|
||||||
self.force_shutdown()
|
self.force_shutdown()
|
||||||
|
|
||||||
snap.delete(VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY)
|
snap.delete(VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY)
|
||||||
|
|
||||||
|
disks = snapXML.findall('inactiveDomain/devices/disk')
|
||||||
|
if not disks: disks = snapXML.findall('domain/devices/disk')
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
self.instance.updateDeviceFlags(ElementTree.tostring(disk).decode("UTF-8"))
|
self.instance.updateDeviceFlags(ElementTree.tostring(disk).decode("UTF-8"))
|
||||||
name = name.replace("s1", "s2")
|
name = name.replace("s1", "s2")
|
||||||
self.create_external_snapshot(name, date, desc)
|
self.create_external_snapshot(name, date, desc)
|
||||||
pool.refresh() if pool else None
|
|
||||||
|
|
||||||
def get_snapshot(self, flag=VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL):
|
def get_snapshot(self, flag=VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL):
|
||||||
snapshots = []
|
snapshots = []
|
||||||
|
|
@ -1413,6 +1407,15 @@ class wvmInstance(wvmConnect):
|
||||||
def get_wvmStorages(self):
|
def get_wvmStorages(self):
|
||||||
return wvmStorages(self.host, self.login, self.passwd, self.conn)
|
return wvmStorages(self.host, self.login, self.passwd, self.conn)
|
||||||
|
|
||||||
|
def refresh_instance_pools(self):
|
||||||
|
disks = self.get_disk_devices()
|
||||||
|
target_paths = set()
|
||||||
|
for disk in disks:
|
||||||
|
disk_path = disk.get("path")
|
||||||
|
target_paths.add(os.path.dirname(disk_path))
|
||||||
|
for target_path in target_paths:
|
||||||
|
self.get_wvmStorages().get_pool_by_target(target_path).refresh(0)
|
||||||
|
|
||||||
def fix_mac(self, mac):
|
def fix_mac(self, mac):
|
||||||
if ":" in mac:
|
if ":" in mac:
|
||||||
return mac
|
return mac
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,14 @@ class wvmStorages(wvmConnect):
|
||||||
def define_storage(self, xml, flag):
|
def define_storage(self, xml, flag):
|
||||||
self.wvm.storagePoolDefineXML(xml, flag)
|
self.wvm.storagePoolDefineXML(xml, flag)
|
||||||
|
|
||||||
|
def get_pool_by_target(self, target):
|
||||||
|
pool_names = self.get_storages()
|
||||||
|
for pool_name in pool_names:
|
||||||
|
stg = wvmStorage(self.host, self.login, self.passwd, self.conn, pool_name)
|
||||||
|
if stg.get_target_path() == target:
|
||||||
|
return self.get_storage(pool_name)
|
||||||
|
return None
|
||||||
|
|
||||||
def create_storage(self, stg_type, name, source, target):
|
def create_storage(self, stg_type, name, source, target):
|
||||||
xml = f"""<pool type='{stg_type}'>
|
xml = f"""<pool type='{stg_type}'>
|
||||||
<name>{name}</name>"""
|
<name>{name}</name>"""
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,8 @@ LOGIN_URL = "/accounts/login/"
|
||||||
|
|
||||||
LOGOUT_REDIRECT_URL = "/accounts/login/"
|
LOGOUT_REDIRECT_URL = "/accounts/login/"
|
||||||
|
|
||||||
|
LOGIN_REDIRECT_URL="/instances/"
|
||||||
|
|
||||||
LANGUAGE_CODE = "en-us"
|
LANGUAGE_CODE = "en-us"
|
||||||
|
|
||||||
TIME_ZONE = "UTC"
|
TIME_ZONE = "UTC"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue