mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
A Balance button on the Computes page opens computes/balance/: the memory and vCPUs each host gives its running VMs, before and after, and the proposed migrations. The proposal (computes/balance.py) takes, step by step, the one move that most lowers the sum of the squared memory loads, then of the squared vCPU loads, and stops when none does; each VM moves once, and the VMs moved to a host fit in the memory its running and paused VMs leave without counting those moved away, so the moves may run in any order. Only running VMs count and move; one that cannot move (no destination shares its disks) still counts on its host and is listed with the reason. Unticking a VM keeps it where it is and makes the proposal again. Migrate runs the moves shown in one host.balance job. It shares the bulk migration's loop (computes.jobs.Migrations): migrate jobs, the chosen number at once, one bulk job at a time. Its migrations take only a running VM (moveto running_only): one stopped since stays where it is. A job another one started now shows only on its own page: a host's page no longer lists a bulk migration's or a balance's migrations, and the Computes page shows the bulk jobs.
94 lines
3.6 KiB
Python
94 lines
3.6 KiB
Python
from virtsecrets.views import secrets
|
|
|
|
from admin.decorators import superuser_only
|
|
from django.urls import URLPattern, URLResolver, include, path
|
|
from interfaces.views import interface, interfaces
|
|
from networks.views import network, networks
|
|
from nodedevs.views import nodedevs
|
|
from nwfilters.views import nwfilter, nwfilters
|
|
from storages.views import download_volume, get_volumes, storage, storages
|
|
|
|
from . import forms, views
|
|
|
|
|
|
def superuser_only_patterns(patterns):
|
|
"""
|
|
Wrap every view below these patterns with superuser_only. Everything under
|
|
/computes/ is host administration, so the check is applied
|
|
to the whole namespace instead of per view, and a view added here later
|
|
cannot be exposed by forgetting a decorator.
|
|
"""
|
|
for pattern in patterns:
|
|
if isinstance(pattern, URLResolver):
|
|
superuser_only_patterns(pattern.url_patterns)
|
|
elif isinstance(pattern, URLPattern):
|
|
pattern.callback = superuser_only(pattern.callback)
|
|
return patterns
|
|
|
|
|
|
urlpatterns = [
|
|
path("", views.computes, name="computes"),
|
|
path("balance/", views.balance, name="balance"),
|
|
path(
|
|
"add_tcp_host/",
|
|
views.compute_create,
|
|
{"FormClass": forms.TcpComputeForm},
|
|
name="add_tcp_host",
|
|
),
|
|
path(
|
|
"add_ssh_host/",
|
|
views.compute_create,
|
|
{"FormClass": forms.SshComputeForm},
|
|
name="add_ssh_host",
|
|
),
|
|
path(
|
|
"add_tls_host/",
|
|
views.compute_create,
|
|
{"FormClass": forms.TlsComputeForm},
|
|
name="add_tls_host",
|
|
),
|
|
path(
|
|
"add_socket_host/",
|
|
views.compute_create,
|
|
{"FormClass": forms.SocketComputeForm},
|
|
name="add_socket_host",
|
|
),
|
|
path(
|
|
"<int:compute_id>/",
|
|
include(
|
|
[
|
|
path("", views.overview, name="overview"),
|
|
path("update/", views.compute_update, name="compute_update"),
|
|
path("delete/", views.compute_delete, name="compute_delete"),
|
|
path("statistics", views.compute_graph, name="compute_graph"),
|
|
path("capacity/", views.capacity, name="compute_capacity"),
|
|
path("instances/", views.instances, name="instances"),
|
|
path("bulk-migrate/", views.bulk_migrate, name="bulk_migrate"),
|
|
path("nodedevs/", nodedevs, name="nodedevs"),
|
|
path("storages/", storages, name="storages"),
|
|
path("storage/<str:pool>/volumes/", get_volumes, name="volumes"),
|
|
path("storage/<str:pool>/", storage, name="storage"),
|
|
path("storage/<str:pool>/download/<str:vol>", download_volume, name="download_volume"),
|
|
path("networks/", networks, name="networks"),
|
|
path("network/<str:pool>/", network, name="network"),
|
|
path("interfaces/", interfaces, name="interfaces"),
|
|
path("interface/<str:iface>/", interface, name="interface"),
|
|
path("nwfilters/", nwfilters, name="nwfilters"),
|
|
path("nwfilter/<str:nwfltr>/", nwfilter, name="nwfilter"),
|
|
path("virtsecrets/", secrets, name="virtsecrets"),
|
|
path(
|
|
"archs/<str:arch>/machines",
|
|
views.get_compute_machine_types,
|
|
name="machines",
|
|
),
|
|
path(
|
|
"archs/<str:arch>/machines/<str:machine>/disks/<str:disk>/buses",
|
|
views.get_compute_disk_buses,
|
|
name="buses",
|
|
),
|
|
]
|
|
),
|
|
),
|
|
]
|
|
|
|
superuser_only_patterns(urlpatterns)
|