From ca71c554b4aeb9dc017a507308b08dee7eecd787 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Feb 2024 15:08:24 +0100 Subject: [PATCH] Added Windows --- DOCUMENTATION.md | 41 +++++++++++++++++++++++++++++++++++++ README.md | 1 + app.py | 53 ++++++++++++++++++++++-------------------------- 3 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 DOCUMENTATION.md diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md new file mode 100644 index 0000000..ea6e7e9 --- /dev/null +++ b/DOCUMENTATION.md @@ -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 + + diff --git a/README.md b/README.md index 0e9f9b0..7628c5c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Hype² +Now compatible with Windows Install, just take care to lauch the driver before scanning disks. diff --git a/app.py b/app.py index 4e957ea..32bb22e 100644 --- a/app.py +++ b/app.py @@ -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 ## ############################