1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 19:56:48 +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:
catborise 2026-10-31 01:34:44 +03:00
parent 54a1943e26
commit a408cfdb2b
9 changed files with 163 additions and 24 deletions

View file

@ -499,3 +499,24 @@ class NvramCopyTestCase(unittest.TestCase):
self.assertIs(raised.exception, error)
self.dest_pool.storageVolLookupByName.assert_called_once_with("vm_VARS.fd")
self.dest_pool.storageVolLookupByName.return_value.delete.assert_called_once_with(0)
class MigrationPlanTestCase(unittest.TestCase):
"""The Migrate tab's plan: the pools each disk can be copied into, and the
next start's disks the migration does not carry."""
def test_pools_with_a_file_of_the_name_and_the_next_start_disks(self):
dest = wvmInstances.__new__(wvmInstances)
pools = {"default": (mock.MagicMock(), "/i"), "fast": (mock.MagicMock(), "/srv/fast"),
"slow": (mock.MagicMock(), "/srv/slow")}
dest.file_pools = lambda: pools
vda = {"target": "vda", "path": "/i/vm.qcow2", "shared": False, "refusal": None}
vdb = {"target": "vdb", "path": "/i/new.qcow2", "shared": False, "refusal": None}
dest.disk_plan = lambda conn, xml: [dict(row) for row in {"live": [vda], "next": [vda, vdb]}[xml]]
# the pool on the disk's directory has a file of its name
dest._find_volume = lambda pool, name: object() if pool is pools["default"][0] else None
disks, pending = dest.migration_plan(None, "live", "next")
self.assertEqual((disks[0]["free_pools"], disks[0]["default"]), (["fast", "slow"], "fast"))
self.assertEqual(pending, [vdb])
for pool, directory in pools.values():
pool.refresh.assert_called_once_with(0) # a file made since is seen