Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Kill all unresponsive VMs
if params.get("kill_unresponsive_vms") == "yes":
logging.debug("Param 'kill_unresponsive_vms' specified, killing all "
"VMs that fail to respond to a remote login request")
for vm in env.get_all_vms():
if vm.is_alive():
try:
session = vm.login()
session.close()
except (remote.LoginError, virt_vm.VMError), e:
logging.warn(e)
vm.destroy(gracefully=False)
# Kill all aexpect tail threads
aexpect.kill_tail_threads()
# Terminate tcpdump if no VMs are alive
living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()]
if not living_vms and "tcpdump" in env:
env["tcpdump"].close()
del env["tcpdump"]
if params.get("setup_hugepages") == "yes":
h = test_setup.HugePageConfig(params)
h.cleanup()
if params.get("vm_type") == "libvirt":
libvirt_vm.libvirtd_restart()
if params.get("setup_thp") == "yes":
thp = test_setup.TransparentHugePageConfig(test, params)
thp.cleanup()
destroy = False
vm_params = params.object_params(vm.name)
for image in vm_params.objects('images'):
if params.object_params(image).get('remove_image') == 'yes':
destroy = True
if destroy and not vm.is_dead():
logging.debug(
'Image of VM %s was removed, destroying it.',
vm.name)
vm.destroy()
# Terminate the ip sniffer thread
env.stop_ip_sniffing()
# Kill all aexpect tail threads
aexpect.kill_tail_threads()
# collect sosreport of host/remote host during postprocess if enabled
if params.get("enable_host_sosreport", "no") == "yes":
sosreport_path = utils_misc.get_sosreport(sosreport_name="host")
logging.info("Sosreport for host: %s", sosreport_path)
if params.get("enable_remote_host_sosreport", "no") == "yes":
remote_params = {'server_ip': params['remote_ip'], 'server_pwd': params['remote_pwd']}
remote_params['server_user'] = params['remote_user']
session = test_setup.remote_session(remote_params)
sosreport_path = utils_misc.get_sosreport(session=session,
remote_ip=params['remote_ip'],
remote_pwd=params['remote_pwd'],
remote_user=params['remote_user'],
sosreport_name="host_remote")
logging.info("Sosreport for remote host: %s", sosreport_path)
living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()]
destroy = False
vm_params = params.object_params(vm.name)
for image in vm_params.objects('images'):
if params.object_params(image).get('remove_image') == 'yes':
destroy = True
if destroy and not vm.is_dead():
logging.debug(
'Image of VM %s was removed, destroying it.',
vm.name)
vm.destroy()
# Terminate the ip sniffer thread
env.stop_ip_sniffing()
# Kill all aexpect tail threads
aexpect.kill_tail_threads()
living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()]
# Close all monitor socket connections of living vm.
for vm in living_vms:
if hasattr(vm, "monitors"):
for m in vm.monitors:
try:
m.close()
except Exception:
pass
# Close the serial console session, as it'll help
# keeping the number of filedescriptors used by avocado-vt honest.
vm.cleanup_serial_console()
libvirtd_inst = utils_libvirtd.Libvirtd()
vm_type = params.get("vm_type")
glob.glob(os.path.join(test.debugdir, '*.webm'))):
os.unlink(f)
# Kill all unresponsive VMs
if params.get("kill_unresponsive_vms") == "yes":
for vm in env.get_all_vms():
if vm.is_alive():
try:
session = vm.login()
session.close()
except (remote.LoginError, virt_vm.VMError), e:
logging.warn(e)
vm.destroy(gracefully=False)
# Kill all aexpect tail threads
aexpect.kill_tail_threads()
# Terminate tcpdump if no VMs are alive
living_vms = [vm for vm in env.get_all_vms() if vm.is_alive()]
if not living_vms and "tcpdump" in env:
env["tcpdump"].close()
del env["tcpdump"]
if params.get("setup_hugepages") == "yes":
h = test_setup.HugePageConfig(params)
h.cleanup()
if params.get("vm_type") == "libvirt":
libvirt_vm.libvirtd_restart()
if params.get("setup_thp") == "yes":
thp = test_setup.TransparentHugePageConfig(test, params)
thp.cleanup()