def test_vm_launch_flags(flag_file, flag, vm_id): assert not os.path.exists(flag_file) hooks.dump_vm_launch_flags_to_file(vm_id, flag) assert hooks.load_vm_launch_flags_from_file(vm_id) == flag assert os.path.exists(flag_file) hooks.remove_vm_launch_flags_file(vm_id) assert not os.path.exists(flag_file)
def test_pause_flags(self): vm_id = '042f6258-3446-4437-8034-0c93e3bcda1b' with namedTemporaryDir() as tmpDir: flags_path = os.path.join(tmpDir, '%s') with MonkeyPatchScope([(hooks, '_LAUNCH_FLAGS_PATH', flags_path)]): flags_file = hooks._LAUNCH_FLAGS_PATH % vm_id for flag in [libvirt.VIR_DOMAIN_NONE, libvirt.VIR_DOMAIN_START_PAUSED]: self.assertFalse(os.path.exists(flags_file)) hooks.dump_vm_launch_flags_to_file(vm_id, flag) read_flag = hooks.load_vm_launch_flags_from_file(vm_id) self.assertEqual(flag, read_flag) self.assertTrue(os.path.exists(flags_file)) hooks.remove_vm_launch_flags_file(vm_id) self.assertFalse(os.path.exists(flags_file))
def test_pause_flags(self): vm_id = '042f6258-3446-4437-8034-0c93e3bcda1b' with namedTemporaryDir() as tmpDir: flags_path = os.path.join(tmpDir, '%s') with MonkeyPatchScope([(hooks, '_LAUNCH_FLAGS_PATH', flags_path)]): flags_file = hooks._LAUNCH_FLAGS_PATH % vm_id for flag in [ libvirt.VIR_DOMAIN_NONE, libvirt.VIR_DOMAIN_START_PAUSED ]: self.assertFalse(os.path.exists(flags_file)) hooks.dump_vm_launch_flags_to_file(vm_id, flag) read_flag = hooks.load_vm_launch_flags_from_file(vm_id) self.assertEqual(flag, read_flag) self.assertTrue(os.path.exists(flags_file)) hooks.remove_vm_launch_flags_file(vm_id) self.assertFalse(os.path.exists(flags_file))
def load_vm_launch_flags_from_file(vm_id): return hooks.load_vm_launch_flags_from_file(vm_id)