Skip to content

Commit c745cf7

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

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
@@ -356,35 +356,7 @@ def create_vms(request, host):
356356
vdis = []
357357
vbds = []
358358
for marker in markers.args:
359-
vm_name = marker["name"]
360-
vm_template = marker["template"]
361-
362-
logging.info(">> Install VM %r from template %r", vm_name, vm_template)
363-
364-
vm = host.vm_from_template(vm_name, vm_template)
365-
366-
# VM is now created, make sure we clean it up on any subsequent failure
367-
vms.append(vm)
368-
369-
if "vdis" in marker:
370-
for vdi_def in marker["vdis"]:
371-
sr = SR(host.main_sr_uuid(), host.pool)
372-
vdi = sr.create_vdi(vdi_def["name"], vdi_def["size"])
373-
vdis.append(vdi)
374-
# connect to VM
375-
vbd = vm.create_vbd(vdi_def["device"], vdi.uuid)
376-
vbds.append(vbd)
377-
vbd.param_set(param_name="userdevice", value=vdi_def["userdevice"])
378-
379-
if "vifs" in marker:
380-
for vif_def in marker["vifs"]:
381-
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
382-
383-
if "params" in marker:
384-
for param_def in marker["params"]:
385-
logging.info("Setting param %s", param_def)
386-
vm.param_set(**param_def)
387-
359+
_create_vm(marker, host, vms, vdis, vbds)
388360
yield vms
389361

390362
except Exception:
@@ -402,6 +374,36 @@ def create_vms(request, host):
402374
logging.info("<< Destroy VM %s", vm.uuid)
403375
vm.destroy(verify=True)
404376

377+
def _create_vm(marker, host, vms, vdis, vbds):
378+
vm_name = marker["name"]
379+
vm_template = marker["template"]
380+
381+
logging.info(">> Install VM %r from template %r", vm_name, vm_template)
382+
383+
vm = host.vm_from_template(vm_name, vm_template)
384+
385+
# VM is now created, make sure we clean it up on any subsequent failure
386+
vms.append(vm)
387+
388+
if "vdis" in marker:
389+
for vdi_def in marker["vdis"]:
390+
sr = SR(host.main_sr_uuid(), host.pool)
391+
vdi = sr.create_vdi(vdi_def["name"], vdi_def["size"])
392+
vdis.append(vdi)
393+
# connect to VM
394+
vbd = vm.create_vbd(vdi_def["device"], vdi.uuid)
395+
vbds.append(vbd)
396+
vbd.param_set(param_name="userdevice", value=vdi_def["userdevice"])
397+
398+
if "vifs" in marker:
399+
for vif_def in marker["vifs"]:
400+
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
401+
402+
if "params" in marker:
403+
for param_def in marker["params"]:
404+
logging.info("Setting param %s", param_def)
405+
vm.param_set(**param_def)
406+
405407
@pytest.fixture(scope="module")
406408
def running_vm(imported_vm):
407409
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)