From e44e6b83e41cd69faf03d893965b62cd2aa0b23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Tue, 18 Nov 2025 13:49:52 +0100 Subject: [PATCH] Choose a local SR that was already in the pool before the tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test may create a local SR that should be used only for the test. Using it for something else, like caching the VMs, it prevents the SR being destroyed in the tear down. Signed-off-by: Gaƫtan Lehmann --- lib/host.py | 8 ++++++-- lib/pool.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/host.py b/lib/host.py index 3a15e564f..a5b5a21bd 100644 --- a/lib/host.py +++ b/lib/host.py @@ -665,8 +665,12 @@ def main_sr_uuid(self): self.xe('sr-list', {'host': hostname, 'content-type': 'user', 'minimal': 'true'}), ',' ) - assert local_sr_uuids, f"DEFAULT_SR=='local' so there must be a local SR on host {self}" - sr_uuid = local_sr_uuids[0] + # We don't want a SR added by the test, so choose one that already existed + pre_existing_local_sr_uuids = sorted(set(self.pool.pre_existing_sr_uuids) & set(local_sr_uuids)) + assert pre_existing_local_sr_uuids, ( + f"DEFAULT_SR=='local' so there must be a pre-existing local SR on host {self}" + ) + sr_uuid = pre_existing_local_sr_uuids[0] elif DEFAULT_SR == 'default': sr_uuid = self.pool.param_get('default-SR') assert sr_uuid, f"DEFAULT_SR='default' so there must be a default SR on the pool of host {self}" diff --git a/lib/pool.py b/lib/pool.py index 63da0956a..da0febeb2 100644 --- a/lib/pool.py +++ b/lib/pool.py @@ -35,6 +35,7 @@ def __init__(self, master_hostname_or_ip: HostAddress) -> None: self.hosts.append(host) self.uuid = self.master.xe('pool-list', minimal=True) self.saved_uefi_certs: Optional[Dict[str, Any]] = None + self.pre_existing_sr_uuids = safe_split(self.master.xe('sr-list', {'minimal': 'true'}), ',') def param_get(self, param_name, key=None, accept_unknown_key=False): return _param_get(self.master, Pool.xe_prefix, self.uuid, param_name, key, accept_unknown_key)