Skip to content

Commit

Permalink
lib/host: Allow specifying default SR UUID
Browse files Browse the repository at this point in the history
Signed-off-by: Tu Dinh <[email protected]>
  • Loading branch information
Tu Dinh committed Jan 21, 2025
1 parent 64b7f48 commit f82af42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions data.py-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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 != "<not in database>"
return sr_uuid

Expand Down

0 comments on commit f82af42

Please sign in to comment.