1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00

docs: the README and doc/ checked against the code; an installer rerun keeps the noVNC port

A review of every Markdown file against the code found steps that would
fail and statements that are no longer true:

- RHEL computes set up by hand enabled only virtqemud: the storage,
  network and other host pages need their daemons' sockets too;
- moving to a new machine migrated without /etc/default/webvirtcloud
  (a PostgreSQL panel would migrate the wrong database), and needed a
  node_id an older backup may lack;
- a rollback left update.sh's marker of a stopped update, which the
  next update would have gone on with;
- the manual installs' group and mode lines failed on hosts without one
  of the groups or without sqlite; RHEL's CodeReady Builder repository;
- the NFS backup target was defined on the user's libvirt connection;
- the off-site restore picked a backup by name, not time;
- the features, the jobs list, the console token, the alert webhook
  (ntfy does not take it), the API's submission_key, WS_* in the update,
  the update's last failure, the doc/ API and app tables, permissions
  of templates, protected VMs, backups and the .vv file.

An installer rerun kept WS_PORT in data/local_settings.py but pointed
nginx at that run's answer: it now takes the kept port.
This commit is contained in:
catborise 2026-11-20 19:30:30 +03:00
parent 29d4bc2e7a
commit cdf1baed2e
4 changed files with 52 additions and 45 deletions

View file

@ -1,6 +1,6 @@
# WebVirtCloud architecture
WebVirtCloud is a web panel for libvirt hosts. libvirt is the source of truth: the panel reads a host's VMs, pools, networks and devices from libvirt when a page needs them, and its database holds what libvirt does not (users, permissions, quotas, compute connection details, jobs, the audit log, settings) and, per VM, the compute, name and UUID that permissions hang on. VMs keep running when the panel is stopped. Changes made with `virsh` or `virt-manager` reach those VM rows the next time a VM list page is loaded; the API's list of a compute's VMs reconciles them with libvirt first, its list of all VMs reads the rows as they are.
WebVirtCloud is a web panel for libvirt hosts. libvirt is the source of truth: the panel reads a host's VMs, pools, networks and devices from libvirt when a page needs them, and its database holds what libvirt does not (users, permissions, quotas, compute connection details, jobs, the audit log, settings) and, per VM, the compute, name and UUID that permissions hang on. VMs keep running when the panel is stopped. Changes made with `virsh` or `virt-manager` (VMs added, removed or renamed) reach those VM rows the next time a VM list is read: the VM list page and both API VM lists read first the hosts whose VMs the user may see.
## Stack
@ -22,13 +22,13 @@ browser ── nginx :80 (:443 with your TLS)
├── / → gunicorn 127.0.0.1:8000 (Django)
├── /static/ → staticfiles/
├── /novncd/ → novncd 127.0.0.1:6080 (VNC console, websockify)
└── /socket.io/ → socketiod 127.0.0.1:6081 (serial console)
└── /socket.io/ → socketiod 127.0.0.1:6081 (serial console, off by default)
worker (manage.py run_worker) long operations, one per installation
backup (manage.py backup) daily, from webvirt-backup.timer or cron in Docker
Django, worker, novncd, socketiod ── libvirt (TCP, SSH, TLS or local socket) ── compute hosts
panel ── gstfsd on each compute, at the compute's hostname, port 16510 (HMAC-signed requests; loopback only when the panel runs on the compute)
panel ── gstfsd on a compute, optional (root password and SSH key of a shut-off VM), port 16510 (HMAC-signed requests; loopback only unless set up for a remote panel)
```
| Unit (systemd) | supervisord program (Docker) | Runs |
@ -45,15 +45,15 @@ panel ── gstfsd on each compute, at the compute's hostname, port 16510 (HMAC
| App | What it holds |
|---|---|
| `accounts` | users' VM permissions (`UserInstance`), quotas (`UserAttributes`), SSH keys, API tokens, OTP, login |
| `admin` | users, groups and their permissions pages, the Tags page |
| `admin` | users, groups and their permissions pages, the Tags and Logs pages |
| `appsettings` | settings stored in the database, themes, `manage.py backup` |
| `computes` | compute hosts (`Compute`: hostname, type, login, password, gstfsd key, migration address, maintenance), tags (`Tag`) of VMs and hosts, host overview and capacity, Bulk Migrate and Balance |
| `instances` | VMs (`Instance`: compute, name, UUID), flavors, removed-VM records (`InstanceTombstone`), the VM pages and their jobs |
| `storages`, `networks`, `interfaces`, `nwfilters`, `virtsecrets` | the host's pools and volumes, networks, interfaces, network filters and secrets, read from libvirt |
| `nodedevs` | the host's PCI and USB devices and which VM has them |
| `console` | VNC and serial console pages, signed console tokens, `novncd`, `socketiod`, SSH tunnels to SSH computes |
| `datasource` | cloud-init metadata (OpenStack format), a VM found by its client address |
| `logs` | the audit log (`Logs`) and its page |
| `datasource` | cloud-init metadata (OpenStack format), a VM found by the reverse-DNS name of its client address |
| `logs` | the audit log (`Logs`), its helpers and the VM page's Logs tab |
| `operations` | jobs: `Operation`, `Claim`, `WorkerLease`, the worker and the Jobs pages |
| `vmbackups` | VM backups: targets (a storage pool per compute), backups and their files, schedules (`BackupPolicy`), their jobs and pages |
@ -72,10 +72,10 @@ The libvirt layer: the connections and the host objects the apps work on (the ap
## Jobs
Long operations (create, clone, migrate and delete VMs, move disks, clone volumes, snapshots, ISO uploads) are `Operation` rows. The worker claims queued jobs and runs them on a thread pool; an ISO upload runs in the web request and is only tracked.
Long operations (create, clone, migrate and delete VMs, bulk power, move disks, clone and download volumes, snapshots, VM backups, ISO uploads) are `Operation` rows. The worker claims queued jobs and runs them on a thread pool; an ISO upload runs in the web request and is only tracked.
- **Claims:** a job holds claims on what it changes (VM, volume, pool, name, quota); a conflicting request is refused at once.
- **Recovery:** a job whose worker died is never run again. The new worker reads what happened from libvirt and ends it as succeeded, failed or uncertain; an uncertain job keeps its claims until a superuser resolves it.
- **Recovery:** a job whose worker died is never run again. The new worker reads what happened from libvirt and ends it as succeeded, failed, cancelled or uncertain; an uncertain job keeps its claims until a superuser resolves it.
- **Hosts:** one host's jobs take at most half the worker's slots, with one progress read and one control task per host, so a host that does not answer cannot stop the others.
- **Pages:** the job panel on resource pages, the Jobs pages and `/api/v1/operations/` follow them.
@ -86,6 +86,6 @@ Long operations (create, clone, migrate and delete VMs, move disks, clone volume
- `computes/`, and per compute `instances/`, `instances/create/<arch>/<machine>/`, `networks/`, `interfaces/`, `storages/` (with `volumes/`), `archs/`
- `instances/`, `flavor/`, `migrate/`, `operations/`, `backups/`
- the VM and compute lists (also a compute's `instances/`) take `?tag=<name>`
- schema at `/api/schema/`, Swagger at `/swagger/`, ReDoc at `/redoc/`
- schema at `/api/schema/`, Swagger at `/swagger/`, ReDoc at `/redoc/`, all after a login
Create, migrate and delete answer 202 with the job.
VM create, migrate and delete need a `submission_key` and answer 202 with the job.

View file

@ -7,7 +7,8 @@ WebVirtCloud combines three kinds of access rights:
- `instances.view_instances` — **read-only auditor role**: sees every VM in lists and detail pages, but cannot change them and cannot open their consoles.
- `instances.clone_instances` — may clone VMs (see the table for which ones).
- `instances.snapshot_instances` — may create, revert and delete snapshots of VMs they may change.
- `instances.passwordless_console` — the console page fills in the VNC password automatically (ticked by default on the Users page's new-user form; a user made otherwise, such as from LDAP, does not get it).
- `instances.backup_instances` — may back up the VMs they may change (see the table).
- `instances.passwordless_console` — the console page fills in the VNC password automatically, and the `.vv` file holds it (ticked by default on the Users page's new-user form; a user made otherwise, such as from LDAP, does not get it).
- `accounts.change_password` — may change their own password.
- **Per-VM ownership** (an owner entry for a user on a VM, managed by a superuser on the VM's page) with three flags: `is_change`, `is_delete`, `is_vnc`. An owner without flags may see, start and stop the VM and open its console.
@ -15,9 +16,9 @@ WebVirtCloud combines three kinds of access rights:
|---|---|---|---|---|
| See the VM (list, detail) | ✅ | ✅ | — | ✅ |
| Start, shut down, power cycle, force off | ✅ | ✅ | — | ❌ |
| Open the console (noVNC, `.vv` file for virt-viewer, VDI URL) | ✅ | ✅ | — | ❌ |
| Open the console (noVNC or, when it is on, the serial console; `.vv` file for virt-viewer, VDI URL) | ✅ | ✅ | — | ❌ |
| Resize CPU/memory/disk, set root password, add SSH key, change title/description | ✅ | ✅ | `is_change` | ❌ |
| Change console settings (type, VNC password, keymap) | ✅ | ✅ | `is_change` and `is_vnc`; the listen address, and removing the password of a console that listens beyond localhost, are a superuser's | ❌ |
| Change console settings (type, VNC password, keymap) | ✅ | ✅ | `is_change` and `is_vnc`; the listen address, and removing the password of a console that listens beyond localhost, are a superuser's; nobody's on a template | ❌ |
| Snapshots | ✅ | ✅ | `is_change` and `instances.snapshot_instances` | ❌ |
| Clone | ✅ | ✅ | `is_change` and `instances.clone_instances` (templates: viewing the template is enough) | templates only, with `instances.clone_instances` |
| Delete the VM | ✅ | ✅ | `is_delete` | ❌ |
@ -33,5 +34,6 @@ Notes:
- Only superusers choose disk names and MAC addresses when cloning; for other users the server derives them.
- `is_staff` gives no access to VMs and does not reveal console settings or VNC passwords by itself.
- A VM an administrator paused stays paused for its owners: their power actions on it are refused.
- A template VM is changed (resize, root password, SSH keys, options, console settings, snapshots) only by superusers and by staff owners with `is_change`, and deleted only by superusers and staff owners with `is_delete`; other owners keep view, console and power (power on and power cycle of a template are refused with a warning). Cloning a template needs only view access and `instances.clone_instances`.
- A protected VM (a superuser's setting on its Settings tab) is neither deleted nor restored over, by anyone, until the protection is turned off.
- A template VM is changed (resize, root password, SSH keys, title and description, snapshots) only by superusers and by staff owners with `is_change`, and deleted only by superusers and staff owners with `is_delete`; other owners keep view, console and power (power on and power cycle of a template are refused with a warning). Cloning a template needs only view access and `instances.clone_instances`.
- On VM pages, users without ownership or `view_instances` get **404** (the VM's existence is not revealed), and users who can see a VM but lack the right for an action get **403**. Superuser-only pages answer **403** to everyone else; the console page answers **403** both for a missing VM and for a VM the user may not open.