From caa0171ee6cb8070ca38a1877abde1ebc1701e64 Mon Sep 17 00:00:00 2001 From: Tu Dinh Date: Fri, 17 Jan 2025 22:03:55 +0100 Subject: [PATCH] lib/host: Allow specifying default SR UUID Signed-off-by: Tu Dinh --- data.py-dist | 1 + lib/host.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/data.py-dist b/data.py-dist index 991d317b..1ab822ee 100644 --- a/data.py-dist +++ b/data.py-dist @@ -91,6 +91,7 @@ VM_IMAGES = { # Possible values: # - 'default': keep using the pool's default SR # - 'local': use the first local SR found instead +# - A UUID of the SR to be used DEFAULT_SR = 'default' # Whether to cache VMs on the test host, that is import them only if not already diff --git a/lib/host.py b/lib/host.py index f84dce49..441043c4 100644 --- a/lib/host.py +++ b/lib/host.py @@ -527,12 +527,11 @@ def local_vm_srs(self): return srs def main_sr_uuid(self): - """ Main SR is either the default SR, or the first local SR, depending on data.py's DEFAULT_SR. """ + """ Main SR is the default SR, the first local SR, or a specific SR depending on data.py's DEFAULT_SR. """ try: from data import DEFAULT_SR except ImportError: DEFAULT_SR = 'default' - assert DEFAULT_SR in ['default', 'local'] sr_uuid = None if DEFAULT_SR == 'local': @@ -545,9 +544,12 @@ def main_sr_uuid(self): ) assert local_sr_uuids, f"DEFAULT_SR=='local' so there must be a local SR on host {self}" sr_uuid = local_sr_uuids[0] - else: + 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}" + else: + sr_uuid = DEFAULT_SR + assert self.xe('sr-list', {'uuid': sr_uuid}), f"cannot find SR with UUID {sr_uuid} on host {self}" assert sr_uuid != "" return sr_uuid