1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00
Commit graph

162 commits

Author SHA1 Message Date
catborise
490b337453 fix(instances): the VM page reloads only when the VM state changes
The VM page polls the VM state every 5 s and reloads when it differs
from the state the page was rendered with. Since the polling moved to
pollWhileVisible, that state was kept in a top-level "var status",
which is not a page variable but the browser's window.status. Where the
browser does not keep a value there, the poll compared the answer with
"" and reloaded the page every 5 s, back to its first tab.

The variable is now vm_status. A Node test runs the page's script with
a window.status that keeps nothing.
2026-10-06 12:27:45 +03:00
catborise
5bc8b1915e fix(instances): every VM state has a label and the actions it allows
The instance lists, the VM page header and the power tab knew three
libvirt states: running, paused and shut off. A VM that was blocked,
shutting down, crashed, suspended by its guest or without a state got
an empty status cell and no actions, so a crashed VM could not even be
forced off from the list. The lists also offered actions users could
not use: Suspend and Resume (views for superusers) to everyone, and
power actions to users who see every VM through the read-only
view_instances permission.

instances/states.py holds the rules in one place: the label and color
of each state, the actions each state allows, and which of them a user
may use (superusers all; a VM's owners all but suspend and resume, and
nothing on a VM an administrator suspended, as the VM page already
showed; nobody else any). Blocked is a running VM; shutting down,
crashed and suspended by the guest get Force Off, after which the VM
can be started. A shut-off template offers Clone to whoever has the
clone permission, as the clone view allows.

The templates read them through two tags (vm_states): the lists and the
VM page header show the state, instance_actions.html has one slot per
button, each enabled or disabled from the allowed actions. The power
tab offers Force Off in the states that need it.

The new tests check the rules directly and render every state in the
lists and on the VM page for a superuser, an owner and a
view_instances user; they fail on the previous code.
2026-10-05 19:34:30 +03:00
catborise
731d14efd7 fix(instances): pages poll one request at a time, and not while hidden
The VM page polls the VM state every 5 s and, while its Stats tab is
open, the statistics every 10 s; the compute overview polls the host
graph every 5 s. All used setInterval:

- A new request went out on schedule while the previous one was still
  open. When a host goes silent, a stats request waits up to 30-45 s,
  so each open page held several sync workers at once.
- Each time the Stats tab was shown, the page made new charts and a
  new interval without stopping the old ones, and polling went on on
  the other tabs of the page.
- Hidden pages kept polling at full rate.

Measured in a browser against a test server (old code / new): Stats tab
shown 4 times, 31 s on it: 12 / 2 requests; 31 s on another tab of the
page: 12 / 0; page hidden for 31 s: 15 / 0, and the new code asks once
right after the page is shown again; with 25 s answers, at most 15 / 1
requests open at once.

static/js/poll.js repeats a request while the page is visible: the
next one 5 or 10 s after the previous answer, none while hidden, one at
once when shown again. The Stats tab makes its charts once and polls
only while shown. The answer handler runs after the poller's own
bookkeeping, so an error in it (a chart for a disk added meanwhile)
does not stop the polling. A Node test of poll.js runs with the test
suite when node is installed.
2026-10-05 16:55:50 +03:00
catborise
fb3f686532 fix(instances): the quota counts every VM and refuses what it cannot verify
check_user_quota added up the vCPUs, memory and disks of the user's
VMs, but skipped a VM whose host failed a TCP probe. A host that was
down therefore let users exceed their quota, and the probe always failed
for ssh computes named by an ssh_config alias or reached through
ProxyJump, so their VMs were never counted. A VM that could not be read
turned the page into the error page instead.

- Hosts are checked with Compute.status, the connection WebVirtCloud
  uses, once per host. A VM that cannot be read (host down, VM gone)
  makes the usage unknown: clone and resize up are refused with their
  own message (fail closed).
- A request that adds nothing is not checked, so a user over quota can
  still shrink a VM. Users without limits, and an exceeded instance
  count (from the database), need no host either.
- Memory resize of a running VM changes only the current memory, but
  the quota was charged with the submitted maximum. It is now charged
  with no change, and resize_mem gets the current maximum, so a VM that
  shuts down meanwhile cannot take an unchecked one.
- The VM page no longer computes the quota on every load (it read every
  VM of the user on every host for a "quota reached" banner). The limit
  is reported when a change is refused.

The test that expected a down host to pass the quota now expects it to
be refused. Checked against the test hosts: with a VM behind an
ssh_config alias the previous code counted 29 vCPUs, the new one 31;
with a VM on an unreachable host the previous code allowed +1 vCPU,
the new one refuses it after 5.1 s and allows -1 at once. The new
tests fail on the previous code, except the ones guarding unchanged
behaviour.
2026-10-05 12:26:57 +03:00
catborise
e5fda79f5a feat(console): VNC is the only console type
SPICE was removed earlier; its leftovers and the console type choice go
too:
- the console settings form, update_console and the backend no longer
  offer or change the type; an invalid console form now shows its
  errors instead of being ignored;
- the create form, the API serializer and create_instance no longer take
  a graphics type, new VMs get VNC; get_graphics_types and the graphics
  entries of the domain capabilities are gone;
- migration appsettings.0013 deletes QEMU_CONSOLE_DEFAULT_TYPE;
- a VM defined elsewhere with another graphics type gets "Console type
  ... is not supported".

The locale catalogs still reference the deleted SPICE templates in
source comments; regenerating them is left to the translation work.
2026-10-04 01:08:11 +03:00
catborise
4546653b5a fix: serve JSON endpoints as application/json and build DOM safely
Several views returned json.dumps() output through HttpResponse, i.e. as
text/html, and guess_mac_address reflects the URL's vname into it
(reflected XSS). Templates filled the log table and volume dropdowns by
concatenating server data into HTML strings, and log messages contain
user-entered snapshot/disk/clone names (stored XSS that runs when a
superuser opens the Logs tab).

- Use JsonResponse in guess_mac_address, random_mac_address,
  guess_clone_name, sshkeys, storages.get_volumes,
  datasource.os_metadata_json and logs.vm_logs; sshkeys?plain=true is
  served as text/plain.
- stats_tab.html builds log rows with .text(); instance.html and
  create_instance_w2.html build <option> elements with .val().text().
2026-10-02 18:29:11 +03:00
catborise
b47ec2e8f9 bootstrap icon conversion fixes 2023-08-11 09:40:38 +03:00
Emre Serdengeçti
1cbdf76df6
logger updates (#31)
* Log for failed login attempts

* Logger configuration for logging to file

* interface fixes

* login log fix, added logged in too

* bootstrap icons setup

* font-awesome icons replaced with bootstrap icons

* replaced i-tags with django_bootstrap_icons

* removed icons library from project

* bug fix

---------

Co-authored-by: catborise <catborise@gmail.com>
2023-08-09 09:20:18 +03:00
catborise
33d49a68a7 experimental: external snapshot fixes 2023-04-13 12:25:42 +03:00
catborise
e3fb820b50 update bootstrap&bootswatch 5.0.2 -> 5.2.2. Seperate bootswatch overrides for future update easiness 2023-01-23 08:25:44 +03:00
catborise
6d3550bb24 console_listen_address not in the context, it's instance.console_listen_address. fixed by @wadefelix 2022-08-23 08:40:36 +03:00
catborise
cfce71ec2b
Rest framework (#24)
* Add rest framework for API: First Commit

* modify some shell scripts to make variable references safer; modify some python scripts to reduce the code complexity and cyclomatic complexity of functions.

* Add REST API for some webvirtcloud functions. Instance list/delete/create, compute list/delete/create, storages-network list/retrieve. Add swagger and redoc for API interface

* update requirements

Co-authored-by: herengui <herengui@uniontech.com>
2022-08-22 15:12:33 +03:00
Info-IIG
052610dd21 Added permission can snapshot instances 2022-06-16 14:55:08 +02:00
catborise
86723a8271 add missing pipe mark after snapshot icon 2021-12-10 14:39:56 +03:00
catborise
073b7b6717
Bootstrap5 (#17)
* Bootstrap5 migration
2021-07-07 14:12:38 +03:00
catborise
5aa22ac042 Django 3.2.4 LTS upgrade 2021-06-15 13:28:47 +03:00
catborise
d30e6470e2 Add guest info like:hostname,os,version,kernel. indendation fixes 2020-12-17 14:29:07 +03:00
Real-Gecko
01043ba8a8 Templates cleanup 2020-10-15 20:18:45 +06:00
catborise
74a4a1a3ef vnc console options added 2020-07-17 11:04:21 +03:00
Real-Gecko
47009d47ca Instances overhaul 2020-07-13 15:33:09 +06:00
Real-Gecko
1430c73c13 https://github.com/retspen/webvirtcloud/issues/323#issuecomment-649986187 2020-06-26 12:48:53 +06:00
Real-Gecko
eda233ada7 Fix appsettings 2020-06-17 15:23:44 +06:00
Real-Gecko
7eee811e65 Namespaced instances urls 2020-06-16 18:57:50 +06:00
catborise
e97d592e51 fix some messages, add translation for some keywords, update tr locale file 2020-06-12 14:46:17 +03:00
catborise
fd3212de90 fix layout for instance qos configuration 2020-06-10 16:25:29 +03:00
catborise
b7fc8a5fea Language change activation. Fix typos and add new translations 2020-06-10 15:16:58 +03:00
catborise
7bb6bd310b update locale files and TR translations. 2020-06-10 11:15:14 +03:00
catborise
07be61a557 fix detach cdrom problem and cd-rom list's layout problem 2020-06-05 09:29:26 +03:00
catborise
7538ddab4f Add all settings to appsettings page & Convert settings choices 2020-06-04 12:32:00 +03:00
catborise
bf15de507a add aria-label definition to forms 2020-06-04 12:05:55 +03:00
catborise
8bafaa8720 add scope to th tags for screen readers 2020-06-04 12:04:46 +03:00
catborise
7c93ee1e2f bootstrap 4.5 fixations & Update strings style to f-string 2020-06-04 11:38:41 +03:00
catborise
871083967f bootstrap 4.5 fixations & fix various localizations 2020-06-04 11:35:57 +03:00
catborise
0e5840498e bootstrap 4.5 & Bootswatch Themes 2020-06-04 11:33:25 +03:00
catborise
b48b112a40 Update Ace XML Editor 1.4.10 - Move seperate dir 2020-06-04 08:51:27 +03:00
catborise
d384c914a4 stop getting status info before instance delete to prevent domain not found error 2020-06-04 08:51:14 +03:00
catborise
966da065b4 get host info from compute not instance 2020-06-04 08:50:33 +03:00
Real-Gecko
6d82c2820b Fix instance bottom bar overlapping main content 2020-05-25 17:32:36 +06:00
catborise
52c856c504 add show/hide bottom bar option in instance details 2020-04-17 15:37:34 +03:00
catborise
4d40de1b55 Python3 & Django 2.2 Migration - Fix & Updates 2020-03-16 16:59:45 +03:00
catborise
57665c2ab9 add cdrom to instance errors fixed. make cdrom readonly, disable cache. 2020-01-22 14:48:48 +03:00
catborise
9198615076 guest agent status indicator changed 2020-01-21 15:39:16 +03:00
catborise
70032fc2e1 re organize instance overview. add snapshot indicator if there is... add bottom bar for navigation. 2020-01-20 15:47:14 +03:00
catborise
0c8a0523a8 show snapshot list while instance is running. User wanto to see list of running snapshot and delete it. 2020-01-17 16:14:28 +03:00
catborise
6cebd2f70e add seperation between nics, show nic model 2020-01-13 16:18:19 +03:00
catborise
c62e6ba3bc Add changing option of network model. Show model on instance network list 2020-01-10 17:55:42 +03:00
catborise
8b9fe4e887 rearrange instance network to show ipv4 and ipv6 address. Add capability to show all ip address not one of them. Add ipv4 address to instance summary 2020-01-10 15:28:09 +03:00
catborise
f2ba2b58b0 Add editing disk capability to instance. Add instance disk options like io, discard, detect zeroes. rewrite detach disk 2020-01-08 11:28:46 +03:00
catborise
38054d9882 for instances add guest agent indicator: installed, connected. 2019-12-25 14:36:43 +03:00
catborise
9d58e56d16 add/remove guest agent channel function added 2019-12-24 17:19:11 +03:00