1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(instances): a new VM's existing volume or template is taken from the chosen pool

The create job looked volumes up by name in every active pool and took
the first match, so a volume of the same name in another pool could be
attached or copied in place of the chosen one. The form now sends each
existing volume as pool/volume and the template's pool, and the job
looks each up in its own pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-08 14:33:10 +03:00
parent d2383be914
commit 8f09812b7d
7 changed files with 41 additions and 22 deletions

View file

@ -101,16 +101,13 @@ class wvmCreate(wvmConnect):
vol = self.get_volume_by_path(path)
return util.vol_driver_type(util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type"))
def get_volume_path(self, volume, pool=None):
storages = [pool] if pool else self.get_storages(only_actives=True)
for storage in storages:
stg = self.get_storage(storage)
if stg.info()[0] != 0:
stg.refresh(0)
for img in stg.listVolumes():
if img == volume:
vol = stg.storageVolLookupByName(img)
return vol.path()
def get_volume_path(self, volume, pool):
"""The path of that volume of the pool; None if an active pool has no such volume."""
stg = self.get_storage(pool)
if stg.info()[0] != 0:
stg.refresh(0)
if volume in stg.listVolumes():
return stg.storageVolLookupByName(volume).path()
def get_storage_by_vol_path(self, vol_path):
vol = self.get_volume_by_path(vol_path)