Storage reviewed
parent
2f113ad01b
commit
93f2a5379f
|
@ -10,6 +10,22 @@ Please refer to the README file, all install steps are described.
|
||||||
|
|
||||||
Not refered in the install, but you can pipx for you install.
|
Not refered in the install, but you can pipx for you install.
|
||||||
|
|
||||||
|
# Storage
|
||||||
|
|
||||||
|
The server storage are in *{HYPE}/storage/*
|
||||||
|
You will find a folder *win* for the virtio image, *disks* for the VM images (qcow2) and iso for iso install images.
|
||||||
|
|
||||||
|
You can change these storage in *config.py* file.
|
||||||
|
|
||||||
|
For the *disks*,if you prefer to use the default libvirt pool storage (*/var/lib/libvirt/images*)
|
||||||
|
You can modify :
|
||||||
|
|
||||||
|
*--disk path='+str(disk_path)+str(nom)+'.qcow2,size='+str(disk)+',bus=virtio*
|
||||||
|
|
||||||
|
by
|
||||||
|
|
||||||
|
*--disk pool=default,size='+str(disk)+',bus=virtio,format=qcow2*
|
||||||
|
|
||||||
# Virtual Server Creation
|
# Virtual Server Creation
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
|
@ -24,7 +40,7 @@ For the moment, no issue with tested distribution:
|
||||||
## Other install
|
## Other install
|
||||||
|
|
||||||
Tested succeffully :
|
Tested succeffully :
|
||||||
- Pfsense,Dynfi,Open
|
- Pfsense,Dynfi,Opnsense
|
||||||
|
|
||||||
## Windows
|
## Windows
|
||||||
|
|
||||||
|
@ -56,6 +72,16 @@ Failed with :
|
||||||
Never Tested :
|
Never Tested :
|
||||||
- Win 7 and Vista
|
- Win 7 and Vista
|
||||||
|
|
||||||
|
#OTHER
|
||||||
|
|
||||||
|
Please report your bugs to improve this dev.
|
||||||
|
|
||||||
|
#SOURCES
|
||||||
|
|
||||||
|
https://libvirt.gitlab.io/libvirt-appdev-guide-python/index.html
|
||||||
|
https://libvirt-python.readthedocs.io/
|
||||||
|
https://linuxcontainers.org/lxc/documentation/
|
||||||
|
|
||||||
|
|
||||||
# ERROR and SOLUTION
|
# ERROR and SOLUTION
|
||||||
|
|
||||||
|
@ -63,8 +89,13 @@ You may incounter some error in specific case, please report them if they are no
|
||||||
They will be consider on nexts releases.
|
They will be consider on nexts releases.
|
||||||
|
|
||||||
ERROR: Error destroying Requested operation is not valid: cannot undefine domain with nvram :
|
ERROR: Error destroying Requested operation is not valid: cannot undefine domain with nvram :
|
||||||
|
|
||||||
SOLUTION (on CLI): virsh undefine --nvram VM_NAME
|
SOLUTION (on CLI): virsh undefine --nvram VM_NAME
|
||||||
|
|
||||||
|
|
||||||
ERROR: Error stoping NOM_VM:Requested operation is not valid: domain is not running
|
ERROR: Error stoping NOM_VM:Requested operation is not valid: domain is not running
|
||||||
|
|
||||||
SOLUTION 1 (on CLI): virsh reset VM_NAME
|
SOLUTION 1 (on CLI): virsh reset VM_NAME
|
||||||
|
|
||||||
SOLUTION 2 (on CLI): virsh destroy VM_NAME (destroy the VM)
|
SOLUTION 2 (on CLI): virsh destroy VM_NAME (destroy the VM)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Hype²
|
# Hype²
|
||||||
|
|
||||||
Now compatible with Windows Install, just take care to launch the driver before scanning disks.
|
##News
|
||||||
|
- Now compatible with Windows Install, just take care to launch the driver before scanning disks.
|
||||||
|
- Screenshot and VM live edition (RAM and vCPU) added
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
graph LR
|
graph LR
|
||||||
|
|
51
app.py
51
app.py
|
@ -17,7 +17,6 @@ from functions.fvnc import *
|
||||||
from functions.fbackup import *
|
from functions.fbackup import *
|
||||||
from functions.fpool import *
|
from functions.fpool import *
|
||||||
from functions.fedit import *
|
from functions.fedit import *
|
||||||
from functions.fscreen import *
|
|
||||||
|
|
||||||
app = Flask(__name__,static_url_path='',static_folder='static',template_folder='templates')
|
app = Flask(__name__,static_url_path='',static_folder='static',template_folder='templates')
|
||||||
|
|
||||||
|
@ -263,7 +262,6 @@ def get_users():
|
||||||
list_users.append(single)
|
list_users.append(single)
|
||||||
return list_users
|
return list_users
|
||||||
|
|
||||||
|
|
||||||
@app.route('/param',methods=['GET'])
|
@app.route('/param',methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def param():
|
def param():
|
||||||
|
@ -293,28 +291,36 @@ def edit():
|
||||||
vm_name = request.form['edit']
|
vm_name = request.form['edit']
|
||||||
state, maxmem, mem, cpus, cput = get_info_vm(vm_name)
|
state, maxmem, mem, cpus, cput = get_info_vm(vm_name)
|
||||||
#Memory in MB
|
#Memory in MB
|
||||||
return render_template('edit.html', vm_name=vm_name, max_Mermory=conn.getInfo()[1],max_vCPU= conn.getMaxVcpus(None),actual_vCPU=cpus, actual_ram=int(mem/1024),screen_64=get_screenshot(vm_name).decode('ASCII'))
|
return render_template('edit.html', vm_name=vm_name, max_Mermory=conn.getInfo()[1],max_vCPU= conn.getMaxVcpus(None),actual_vCPU=cpus, actual_ram=int(mem/1024),screen_64=get_screenshot(vm_name).decode('ASCII'),actual_autostart=get_autostart(vm_name))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/editressources',methods=['POST'])
|
@app.route('/editressources',methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def editressources():
|
def editressources():
|
||||||
vm_name = request.form['vm_name']
|
vm_name = request.form['vm_name']
|
||||||
new_ram = int(request.form['new_mem'])
|
new_ram = int(request.form['new_mem'])
|
||||||
new_cpu = int(request.form['new_cpu'])
|
new_cpu = int(request.form['new_cpu'])
|
||||||
print("vm:"+vm_name)
|
new_autostart = request.form.get('new_autostart')
|
||||||
print("ram:"+str(new_ram))
|
try:
|
||||||
print("vcpu:"+str(new_cpu))
|
set_memory(vm_name,int(new_ram*1024))
|
||||||
|
except Exception as e:
|
||||||
try:
|
flash('Error editing Memory for '+vm_name+': '+str(e), category='danger')
|
||||||
set_memory(vm_name,int(new_ram*1024))
|
try:
|
||||||
except Exception as e:
|
set_vcpu(vm_name,new_cpu)
|
||||||
flash('Error editing '+vm_name+': '+str(e), category='danger')
|
except Exception as e:
|
||||||
try:
|
flash('Error editing CPU for '+vm_name+': '+str(e), category='danger')
|
||||||
set_vcpu(vm_name,new_cpu)
|
#Autostart
|
||||||
except Exception as e:
|
if request.form.get('new_autostart')=='auto_check':
|
||||||
flash('Error editing '+vm_name+': '+str(e), category='danger')
|
try:
|
||||||
return redirect(url_for('state'))
|
set_autostart(vm_name)
|
||||||
|
except Exception as e:
|
||||||
|
flash('Error editing Autostart for '+vm_name+': '+str(e), category='danger')
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
unset_autostart(vm_name)
|
||||||
|
except Exception as e:
|
||||||
|
flash('Error editing Autostart for '+vm_name+': '+str(e), category='danger')
|
||||||
|
return redirect(url_for('state'))
|
||||||
|
|
||||||
############################
|
############################
|
||||||
## ISO ##
|
## ISO ##
|
||||||
|
@ -509,17 +515,16 @@ def create_VM():
|
||||||
####################################
|
####################################
|
||||||
if ose.startswith('win'):
|
if ose.startswith('win'):
|
||||||
try:
|
try:
|
||||||
cmd = "qemu-img create -f qcow2 "+str(virtuo_path)+str(nom)+".qcow2 "+str(disk)+"G"
|
cmd = "qemu-img create -f qcow2 "+str(disk_path)+str(nom)+".qcow2 "+str(disk)+"G"
|
||||||
subprocess.call(cmd, shell=True)
|
subprocess.call(cmd, shell=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
flash('Error on creating '+str(nom)+':'+str(e),category='danger')
|
flash('Error on creating '+str(nom)+':'+str(e),category='danger')
|
||||||
return redirect(url_for('state'))
|
return redirect(url_for('state'))
|
||||||
opt = " --disk path="+virtuo_path+virtuo_file+",device=cdrom"
|
opt = " --disk path="+virtuo_path+virtuo_file+",device=cdrom"
|
||||||
ostype = 'windows'
|
ostype = 'windows'
|
||||||
diskpath = " --disk path="+str(virtuo_path)+str(nom)+".qcow2,size="+str(disk)+",bus=virtio"
|
creationcmd='--name '+str(nom)+' --ram '+str(ram)+' --disk path='+str(disk_path)+str(nom)+'.qcow2,bus=virtio,format=qcow2 --vcpus '+str(cpu)+' --os-type '+str(ostype)+' --os-variant '+str(ose)+' --network network:bridged --graphics vnc,listen=0.0.0.0 --noautoconsole --console pty,target_type=serial '+opt+' --cdrom '+str(iso)+' --force --debug '
|
||||||
creationcmd='--name '+str(nom)+' --ram '+str(ram)+' --disk path='+str(virtuo_path)+str(nom)+'.qcow2,bus=virtio,format=qcow2 --vcpus '+str(cpu)+' --os-type '+str(ostype)+' --os-variant '+str(ose)+' --network network:bridged --graphics vnc,listen=0.0.0.0 --noautoconsole --console pty,target_type=serial '+opt+' --cdrom '+str(iso)+' --force --debug '
|
|
||||||
else:
|
else:
|
||||||
creationcmd='--name '+str(nom)+' --ram '+str(ram)+' --disk pool=default,size='+str(disk)+',bus=virtio,format=qcow2 --vcpus '+str(cpu)+' --os-type '+str(ostype)+' --os-variant '+str(ose)+' --network network:bridged --graphics vnc,listen=0.0.0.0 --noautoconsole --console pty,target_type=serial '+opt+' --cdrom '+str(iso)+' --force --debug '
|
creationcmd='--name '+str(nom)+' --ram '+str(ram)+' --disk path='+str(disk_path)+str(nom)+'.qcow2,size='+str(disk)+',bus=virtio --vcpus '+str(cpu)+' --os-type '+str(ostype)+' --os-variant '+str(ose)+' --network network:bridged --graphics vnc,listen=0.0.0.0 --noautoconsole --console pty,target_type=serial '+opt+' --cdrom '+str(iso)+' --force --debug '
|
||||||
try:
|
try:
|
||||||
os.system('virt-install '+creationcmd+' ')
|
os.system('virt-install '+creationcmd+' ')
|
||||||
flash(str(nom)+' created', category='success')
|
flash(str(nom)+' created', category='success')
|
||||||
|
|
|
@ -2,6 +2,7 @@ import os
|
||||||
import libvirt
|
import libvirt
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
hype_version = '2.7'
|
||||||
#Flask config
|
#Flask config
|
||||||
class flask_config:
|
class flask_config:
|
||||||
port=5007
|
port=5007
|
||||||
|
@ -12,7 +13,9 @@ class flask_config:
|
||||||
#Path
|
#Path
|
||||||
path = os.path.abspath(os.path.dirname(__file__))
|
path = os.path.abspath(os.path.dirname(__file__))
|
||||||
iso_path= path+'/storage/iso/'
|
iso_path= path+'/storage/iso/'
|
||||||
|
disk_path = path+'/storage/disks/'
|
||||||
|
virtuo_path= path+'/storage/win/'
|
||||||
|
virtuo_file='virtio-win-0.1.229.iso'
|
||||||
#Qemu connection
|
#Qemu connection
|
||||||
try:
|
try:
|
||||||
conn = libvirt.open("qemu:///system")
|
conn = libvirt.open("qemu:///system")
|
||||||
|
|
Loading…
Reference in New Issue