VM snapshot add/delete

main
root 2024-02-29 16:12:31 +01:00
parent 1be2e77d8a
commit 617a6481e9
3 changed files with 45 additions and 2 deletions

38
app.py
View File

@ -376,6 +376,43 @@ def restsnap_lxc():
flash('Error restoring '+item+':'+str(e), category='danger')
return redirect(url_for('backup'))
###LAPIN
@app.route('/snapvm', methods = ['POST'])
@login_required
def snapvm():
vm_name=request.form['snap']
try:
create_snap_vm(vm_name)
flash('Snapshot '+vm_name+' done', category='success')
except Exception as e:
flash('Error on snapshoting '+vm_name+':'+str(e), category='danger')
return redirect(url_for('backup'))
@app.route('/del_snap_vm', methods = ['POST'])
@login_required
def delsnapvm():
vm_name=request.form['vm_name']
item=request.form['item']
try:
del_snap_vm(vm_name,item)
flash(item+' deleted', category='success')
except Exception as e:
flash('Error on deleting '+item+':'+str(e), category='danger')
return redirect(url_for('backup'))
"""
@app.route('/rest_snap_vm', methods = ['POST'])
@login_required
def restsnap_lxc():
vm_name=request.form['lxc_name']
item=request.form['item']
try:
rest_snap_lxc(lxc_name,item)
flash('Restore '+item+' done', category='success')
except Exception as e:
flash('Error restoring '+item+':'+str(e), category='danger')
return redirect(url_for('backup'))
"""
##PINE LA
############################
## BUILD ##
@ -417,7 +454,6 @@ def create_VM():
####################################
## WINDOWS ##
####################################
if ose.startswith('win'):
try:
cmd = "qemu-img create -f qcow2 "+str(virtuo_path)+str(nom)+".qcow2 "+str(disk)+"G"

View File

@ -50,3 +50,8 @@ def get_snap_list_vm(vm_name):
for snap in list_snap_vm:
out.append(snap)
return out
def del_snap_vm(vm_name,item):
dom=conn.lookupByName(vm_name)
snap_del=dom.snapshotLookupByName(item)
snap_del.delete()

View File

@ -26,7 +26,9 @@
{{ snap_vm }}</th><th>
<button type="submit" class="btn btn-outline-secondary btn-hype" value="{{ snap }}" name="start" onclick="loading();"><i class="fa-solid fa-rotate-left"></i></button>
</th><th>
<button type="submit" class="btn btn-outline-danger btn-hype" value="{{ snap }}" name="start" onclick="loading();"><i class="fa-solid fa-trash"></i></button>
<form action="/del_snap_vm" method="post"><input type="hidden" name="vm_name" value="{{ vm[0] }}">
<button type="submit" class="btn btn-outline-danger btn-hype" value="{{ snap_vm }}" name="item" onclick="loading();"><i class="fa-solid fa-trash"></i></button>
</form>
</th></tr></table>
{% endfor %}
</td></tr>