def cleanup(): if not check_root(): return install_info = InstallInfo.try_load() if install_info is None: logging.error("The cleanup has been performed") return stop_all_drakruns() backend = get_storage_backend(install_info) vm_ids = get_all_vm_conf() net_enable = int(conf["drakrun"].get("net_enable", "0")) out_interface = conf["drakrun"].get("out_interface", "") dns_server = conf["drakrun"].get("dns_server", "") for vm_id in vm_ids: vm = VirtualMachine(backend, vm_id) vm.destroy() delete_vm_network( vm_id=vm_id, net_enable=net_enable, out_interface=out_interface, dns_server=dns_server, ) if net_enable: stop_dnsmasq(vm_id=vm_id) backend.delete_vm_volume(vm_id) delete_vm_conf(vm_id) safe_delete(os.path.join(VOLUME_DIR, "snapshot.sav")) cleanup_postinstall_files() InstallInfo.delete()
def dnsmasq_stop_test(): stop_dnsmasq(10) assert subprocess.run(["pgrep", "-F", "/var/run/dnsmasq-vm10.pid"]).returncode == 1 # stopping already stopped dnsmasq stop_dnsmasq(10) # stopping a non started dnsmasq stop_dnsmasq(5)
def dnsmasq_stop_test(): stop_dnsmasq(1) assert subprocess.run(['pgrep', '-F', '/var/run/dnsmasq-vm1.pid']).returncode == 1 # stopping already stopped dnsmasq stop_dnsmasq(1) # stopping a non started dnsmasq stop_dnsmasq(5)
def test_dnsmasq_stop(): stop_dnsmasq(1) try: subprocess.check_output('pgrep dnsmasq', shell=True) except subprocess.CalledProcessError as e: assert e.returncode == 1