Added Windows

main
root 2024-02-23 15:08:24 +01:00
parent e9c03c6c11
commit ca71c554b4
3 changed files with 66 additions and 29 deletions

41
DOCUMENTATION.md 100644
View File

@ -0,0 +1,41 @@
# Documentation
This is more a techincal documentation that how to use this tool.
# Install
Please refer to the README file,all install steps are described.
## Pipx
Not refered in the install, but you can pipx for you install.
# Virtual Server Creation
##List os update
##Linux
##Windows
Windows OS will need some extra-drivers to run.
For this during the install, the VM will mal a virtuo-win iso with all drivers.
Virtuo can be found here :
https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/?C=M;O=D
This iso is on ./storage/win/ and configured in **config.py** for upgrade.
Tested Windows Install:
Curent testing :
Windows Server 2022
Windows 11
Validate for :
Windows 8, 8,1 10
Windows Server 2019
Failed with :
Windows 98, Windows XP
Never Tested :
Win 7 and Vista

View File

@ -1,5 +1,6 @@
# Hype²
Now compatible with Windows Install, just take care to lauch the driver before scanning disks.

53
app.py
View File

@ -1,6 +1,7 @@
import os
import json
import requests
import subprocess
from flask import Flask , redirect , render_template, request, Response, stream_with_context, url_for, make_response, flash
from werkzeug.utils import secure_filename
from flask_sqlalchemy import SQLAlchemy
@ -183,11 +184,6 @@ def delvol():
## VNC ##
############################
####### TEST
####### ENDTEST
@app.route('/vnc',methods=['GET','POST',"DELETE"])
@login_required
def vnc_connect():
@ -208,29 +204,6 @@ def vnc_connect():
response = Response(resp.content, resp.status_code, headers)
return response
##TEST
@app.route('/ter',methods=['GET','POST',"DELETE"])
@login_required
def ter_connect():
if request.method=='GET':
resp = requests.get('http://localhost:5008/')
excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
elif request.method=='POST':
resp = requests.post('http://localhost:5008/',json=request.get_json())
excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
elif request.method=='DELETE':
resp = requests.delete('http://localhost:5008/').content
response = Response(resp.content, resp.status_code, headers)
return response
##ENDTEST
@app.route('/console_lxc',methods=['GET','POST','DELETE'])
@login_required
def consolelxc():
@ -438,7 +411,28 @@ def create_VM():
iso = iso_path+iso
net = request.form['net']
disk = request.form['disk']
creationcmd='--name '+str(nom)+' --ram '+str(ram)+' --disk pool=default,size='+str(disk)+',bus=virtio,format=qcow2 --vcpus '+str(cpu)+' --os-type linux --os-variant '+str(ose)+' --network network:bridged --graphics vnc,listen=0.0.0.0 --noautoconsole --console pty,target_type=serial --cdrom '+str(iso)+' --force --debug '
opt = ''
ostype = 'linux'
####################################
## WIN ##
####################################
if ose.startswith('win'):
try:
cmd = "qemu-img create -f qcow2 "+str(virtuo_path)+str(nom)+".qcow2 "+str(disk)+"G"
subprocess.call(cmd, shell=True)
except Exception as e:
flash('Error on creating '+str(nom)+':'+str(e),category='danger')
return redirect(url_for('state'))
opt = " --disk path="+virtuo_path+"virtio-win-0.1.229.iso,device=cdrom"
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(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 '
print("OS WINDOWS:"+creationcmd)
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 '
print("OS LINUX:"+creationcmd)
try:
os.system('virt-install '+creationcmd+' ')
flash(str(nom)+' created', category='success')
@ -446,6 +440,7 @@ def create_VM():
flash('Error on creating '+str(nom)+':'+str(e),category='danger')
return redirect(url_for('state'))
############################
## STATE ##
############################