Version 2 of my LXC/Qemu management tool for lab https://pierre.porcheret.org/computer/395/
 
 
 
 
 
Go to file
root bdf2c92951 README update 2023-10-17 14:44:18 +02:00
functions first commit 2023-10-17 10:03:51 +02:00
static first commit 2023-10-17 10:03:51 +02:00
storage/iso first commit 2023-10-17 10:03:51 +02:00
templates first commit 2023-10-17 10:03:51 +02:00
README.md README update 2023-10-17 14:44:18 +02:00
app.py first commit 2023-10-17 10:03:51 +02:00
bridged.xml first commit 2023-10-17 10:03:51 +02:00
config.py first commit 2023-10-17 10:03:51 +02:00
db.db.admin_example README update 2023-10-17 14:44:18 +02:00
pyxterm.py first commit 2023-10-17 10:03:51 +02:00

README.md

Hype²

graph LR
Webpage[Web page] <--Flask--> Server[Server]
Server[Server] <----> Qemu((Qemu))
Server[Server] <----> LXC((LXC))

Install requirement

1 - Update and Install packages :

apt-get update -y -qq
apt-get install lxc lxcfs lxc-templates qemu qemu-utils qemu-kvm virtinst bridge-utils virt-manager libvirt-daemon libvirt-daemon-system virt-viewer libvirt-clients libosinfo-bin websockify sqlite3 novnc
apt-get install python3 python3-flask python3-flask-login python3-flask-sqlalchemy python3-requests python3-lxc python3-libvirt python3-psutil python3-werkzeug python3-websockify python3-novnc

2 - Configure Libvirst to start on boot

systemctl --quiet enable --now libvirtd
systemctl --quiet  start libvirtd

3 - Create a bridge nework

cp ./bridged.xml /usr/share/libvirt/networks/
virsh net-define bridged.xml
virsh net-start bridged
virsh net-autostart bridged

Database for users

A default Database is provided in the git (db.db.admin_example), the default user is admin / admin. To use this database, just change the name from db.db.admin_example to db.db.

If you want to create this database by yourself, you can :

Create Database for users

sqlite3 db.db

CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, username NVARCHAR(200) NULL, email NVARCHAR(200) NULL, password NVARCHAR(200) NULL);

Create first user

1 - Generate encrypted password :

python3
import app
app.encrypt('Password')

2 - Fill Database with user info :

sqlite3 db.db

INSERT INTO user (id,username,email,password) VALUES (1,'<you_username>','<your_email>','<your_previous_encrypted_password');

Configure Reverse Proxy to get access to Consoles

ProxyPass /websockify ws://<server_ip>:6080/websockify retry=3
ProxyPassReverse /websockify ws://<server_ip>:6080/websockify retry=3

ProxyPass /socket.io ws://<server_ip>:5008/socket.io retry=3
ProxyPassReverse /socket.io ws://<server_ip>:5008/socket.io retry=3

Run and use

python3 app

and go to https://<server_ip>:5007 with your credentials (mail and normal password)

Systemd

You can manage hype using Systemd management:

[Unit]
Description= Hype2 service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 <path_to_change>/app.py
[Install]
WantedBy=multi-user.target

put this file in /etc/systemd/system/ and you can then enable it for autostart on boot and/or start/stop the app.

Configuration

You can also change some configuration in the file configuration.py such as flask port, storage location...use it at your own risk.