Skip to content

Commit f82af42

Browse files
committed
lib/host: Allow specifying default SR UUID
Signed-off-by: Tu Dinh <[email protected]>
1 parent 64b7f48 commit f82af42

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

data.py-dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ VM_IMAGES = {
9191
# Possible values:
9292
# - 'default': keep using the pool's default SR
9393
# - 'local': use the first local SR found instead
94+
# - A UUID of the SR to be used
9495
DEFAULT_SR = 'default'
9596

9697
# Whether to cache VMs on the test host, that is import them only if not already

lib/host.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,11 @@ def local_vm_srs(self):
527527
return srs
528528

529529
def main_sr_uuid(self):
530-
""" Main SR is either the default SR, or the first local SR, depending on data.py's DEFAULT_SR. """
530+
""" Main SR is the default SR, the first local SR, or a specific SR depending on data.py's DEFAULT_SR. """
531531
try:
532532
from data import DEFAULT_SR
533533
except ImportError:
534534
DEFAULT_SR = 'default'
535-
assert DEFAULT_SR in ['default', 'local']
536535

537536
sr_uuid = None
538537
if DEFAULT_SR == 'local':
@@ -545,9 +544,12 @@ def main_sr_uuid(self):
545544
)
546545
assert local_sr_uuids, f"DEFAULT_SR=='local' so there must be a local SR on host {self}"
547546
sr_uuid = local_sr_uuids[0]
548-
else:
547+
elif DEFAULT_SR == 'default':
549548
sr_uuid = self.pool.param_get('default-SR')
550549
assert sr_uuid, f"DEFAULT_SR='default' so there must be a default SR on the pool of host {self}"
550+
else:
551+
sr_uuid = DEFAULT_SR
552+
assert self.xe('sr-list', {'uuid': sr_uuid}), f"cannot find SR with UUID {sr_uuid} on host {self}"
551553
assert sr_uuid != "<not in database>"
552554
return sr_uuid
553555

0 commit comments

Comments
 (0)