Skip to content

Commit d32c844

Browse files
committed
WIP split _create_vm out of create_vms fixture
Will help implementing vm import as alternative to creation
1 parent 2d96732 commit d32c844

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

conftest.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -387,35 +387,7 @@ def create_vms(request, host):
387387
vdis = []
388388
vbds = []
389389
for marker in markers.args:
390-
vm_name = marker["name"]
391-
vm_template = marker["template"]
392-
393-
logging.info(">> Install VM %r from template %r", vm_name, vm_template)
394-
395-
vm = host.vm_from_template(vm_name, vm_template)
396-
397-
# VM is now created, make sure we clean it up on any subsequent failure
398-
vms.append(vm)
399-
400-
if "vdis" in marker:
401-
for vdi_def in marker["vdis"]:
402-
sr = SR(host.main_sr_uuid(), host.pool)
403-
vdi = sr.create_vdi(vdi_def["name"], vdi_def["size"])
404-
vdis.append(vdi)
405-
# connect to VM
406-
vbd = vm.create_vbd(vdi_def["device"], vdi.uuid)
407-
vbds.append(vbd)
408-
vbd.param_set(param_name="userdevice", value=vdi_def["userdevice"])
409-
410-
if "vifs" in marker:
411-
for vif_def in marker["vifs"]:
412-
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
413-
414-
if "params" in marker:
415-
for param_def in marker["params"]:
416-
logging.info("Setting param %s", param_def)
417-
vm.param_set(**param_def)
418-
390+
_create_vm(marker, host, vms, vdis, vbds)
419391
yield vms
420392

421393
except Exception:
@@ -433,6 +405,36 @@ def create_vms(request, host):
433405
logging.info("<< Destroy VM %s", vm.uuid)
434406
vm.destroy(verify=True)
435407

408+
def _create_vm(marker, host, vms, vdis, vbds):
409+
vm_name = marker["name"]
410+
vm_template = marker["template"]
411+
412+
logging.info(">> Install VM %r from template %r", vm_name, vm_template)
413+
414+
vm = host.vm_from_template(vm_name, vm_template)
415+
416+
# VM is now created, make sure we clean it up on any subsequent failure
417+
vms.append(vm)
418+
419+
if "vdis" in marker:
420+
for vdi_def in marker["vdis"]:
421+
sr = SR(host.main_sr_uuid(), host.pool)
422+
vdi = sr.create_vdi(vdi_def["name"], vdi_def["size"])
423+
vdis.append(vdi)
424+
# connect to VM
425+
vbd = vm.create_vbd(vdi_def["device"], vdi.uuid)
426+
vbds.append(vbd)
427+
vbd.param_set(param_name="userdevice", value=vdi_def["userdevice"])
428+
429+
if "vifs" in marker:
430+
for vif_def in marker["vifs"]:
431+
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
432+
433+
if "params" in marker:
434+
for param_def in marker["params"]:
435+
logging.info("Setting param %s", param_def)
436+
vm.param_set(**param_def)
437+
436438
@pytest.fixture(scope="module")
437439
def running_vm(imported_vm):
438440
vm = imported_vm

tests/install/test_install.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ def test_install_nested_821_uefi(self, iso_remaster, create_vms):
8383
).returncode == 1,
8484
"Wait for installer to terminate")
8585

86-
# powercycle, catch any change of IP
87-
logging.info("Rebooting Host VM after successful installation")
86+
logging.info("Shutting down Host VM after successful installation")
8887
try:
89-
# use "poweroff" because "reboot" would cause ARP and
90-
# SSH to be checked before host is down, and require
91-
# ssh retries
9288
host_vm.ssh(["poweroff"])
9389
except commands.SSHCommandFailed as e:
9490
# ignore connection closed by reboot
@@ -182,3 +178,9 @@ def test_install_nested_821_uefi(self, iso_remaster, create_vms):
182178
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
183179
host_vm.shutdown(force=True)
184180
raise
181+
182+
# record this state
183+
# FIXME move to fixture
184+
# FIXME where to store?
185+
host_vm.host.ssh(["rm -f test_firstboot_nested_821_uefi-vm1.xva"])
186+
host_vm.export("test_firstboot_nested_821_uefi-vm1.xva", "zstd")

0 commit comments

Comments
 (0)