mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 04:06:47 +00:00
feat(instances): the Migrate tab marks hosts it cannot use and files in the way
The Migrate tab offered every other host alike, and its plan showed neither a file of the same name in a destination pool nor the disks of the VM's next start, which the job then refused. Now: - When the tab opens, the hosts are checked first: one that cannot be reached, or the VM's own host under another record (the same libvirt host UUID), is shown with why and cannot be chosen, and the disks of the first one left are checked. The job refuses the VM's own host under another name too. - A pool of the destination that has a file of a disk's name is shown but cannot be chosen for it; a disk no pool can take refuses the form. - The next start's file disks the migration does not carry are listed; one not on storage both hosts share refuses the form, as the job does.
This commit is contained in:
parent
54a1943e26
commit
a408cfdb2b
9 changed files with 163 additions and 24 deletions
|
|
@ -425,11 +425,40 @@
|
|||
submit.disabled = false; // the migration checks them again
|
||||
});
|
||||
}
|
||||
// the destinations that cannot be chosen (unreachable, or this host under
|
||||
// another record) are marked first; then the disks of the first one left
|
||||
function loadMigrateTargets() {
|
||||
var submit = migratePlan.closest("form").querySelector('button[name="migrate"]');
|
||||
submit.disabled = true;
|
||||
migrateCompute.disabled = true; // no disks are checked for a host before the hosts are
|
||||
migratePlan.textContent = "{{ _("Checking the hosts…")|escapejs }}";
|
||||
fetch(migratePlan.dataset.targetsUrl).then(function (response) {
|
||||
if (!response.ok) throw new Error(response.statusText);
|
||||
return response.json();
|
||||
}).then(function (refused) {
|
||||
migrateCompute.disabled = false;
|
||||
Array.prototype.forEach.call(migrateCompute.options, function (option) {
|
||||
if (refused[option.value]) {
|
||||
option.disabled = true;
|
||||
option.textContent = refused[option.value]; // it names the host
|
||||
}
|
||||
});
|
||||
var first = Array.prototype.find.call(migrateCompute.options, function (option) { return !option.disabled; });
|
||||
if (!first) {
|
||||
migratePlan.textContent = "{{ _("No host can take the VM now.")|escapejs }}";
|
||||
return;
|
||||
}
|
||||
if (migrateCompute.selectedOptions[0].disabled) migrateCompute.value = first.value;
|
||||
loadMigratePlan();
|
||||
}).catch(function () {
|
||||
migratePlan.textContent = "{{ _("The hosts could not be checked.")|escapejs }}";
|
||||
});
|
||||
}
|
||||
if (migratePlan && migrateCompute) {
|
||||
document.querySelector('[data-bs-target="#migrate"]').addEventListener("shown.bs.tab", function () {
|
||||
if (!migratePlan.dataset.loaded) {
|
||||
migratePlan.dataset.loaded = "true";
|
||||
loadMigratePlan();
|
||||
loadMigrateTargets();
|
||||
}
|
||||
});
|
||||
migrateCompute.addEventListener("change", loadMigratePlan);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue