From ef8be34622d525fcce9b32039846f0a1ef4783be Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 10 Jan 2021 19:10:36 +0100 Subject: [PATCH 01/13] Cascade shutdown https://github.com/QubesOS/qubes-issues/issues/6109 --- qubesmanager/qube_manager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index eaa8e43..4b5dad6 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -22,6 +22,7 @@ # # import subprocess +import time from datetime import datetime, timedelta from functools import partial from os import path @@ -1249,6 +1250,25 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): try: + connected_vms = [x for x in vm.connected_vms if x.is_running()] + if len(connected_vms) > 0: + reply = QMessageBox.question( + self, self.tr("Qube Shutdown Confirmation"), + self.tr("There are some qubes connected to '{0}'!" + "
Do you want to shutdown: " + "'{1}'?").format( + vm.name ,", ".join([x.name for x in connected_vms])), + QMessageBox.Yes | QMessageBox.Cancel) + + if reply == QMessageBox.Yes: + with common_threads.busy_cursor(): + for connected_vm in connected_vms: + self.shutdown_vm(connected_vm) + while connected_vm.is_running(): + time.sleep(0.5) + else: + return + vm.shutdown() except exc.QubesException as ex: QMessageBox.warning( From 4bb156e061139b541ea2ca78f8ca4a966c2abf6a Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 10 Jan 2021 20:43:26 +0100 Subject: [PATCH 02/13] Fix pylint warnings --- qubesmanager/qube_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 4b5dad6..f1f7641 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1256,8 +1256,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self, self.tr("Qube Shutdown Confirmation"), self.tr("There are some qubes connected to '{0}'!" "
Do you want to shutdown: " - "'{1}'?").format( - vm.name ,", ".join([x.name for x in connected_vms])), + "'{1}'?").format(vm.name, + ", ".join([x.name for x in connected_vms])), QMessageBox.Yes | QMessageBox.Cancel) if reply == QMessageBox.Yes: From 4d68b64a3a5fc42559c05aede2037699c8a89c39 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 10 Jan 2021 20:54:03 +0100 Subject: [PATCH 03/13] Avoid infite loop while waiting vm to shutdown --- qubesmanager/qube_manager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index f1f7641..4901fa2 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1261,13 +1261,14 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): QMessageBox.Yes | QMessageBox.Cancel) if reply == QMessageBox.Yes: + for connected_vm in connected_vms: + if not self.shutdown_vm(connected_vm): + return False with common_threads.busy_cursor(): - for connected_vm in connected_vms: - self.shutdown_vm(connected_vm) - while connected_vm.is_running(): - time.sleep(0.5) + while connected_vm.is_running(): + time.sleep(0.5) else: - return + return False vm.shutdown() except exc.QubesException as ex: @@ -1275,7 +1276,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self, self.tr("Error shutting down Qube!"), self.tr("ERROR: {0}").format(ex)) - return + return False self.shutdown_monitor[vm.qid] = VmShutdownMonitor(vm, shutdown_time, check_time, @@ -1284,6 +1285,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): QTimer.singleShot(check_time, self.shutdown_monitor[ vm.qid].check_if_vm_has_shutdown) + return True + # noinspection PyArgumentList @pyqtSlot(name='on_action_restartvm_triggered') def action_restartvm_triggered(self): From 9a36089ee65f68805a71efb6d9ea9047e1ad8ad5 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 10 Jan 2021 21:17:49 +0100 Subject: [PATCH 04/13] Fix wrong identation (thanks pylint) --- qubesmanager/qube_manager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 4901fa2..a45043f 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1264,9 +1264,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): for connected_vm in connected_vms: if not self.shutdown_vm(connected_vm): return False - with common_threads.busy_cursor(): - while connected_vm.is_running(): - time.sleep(0.5) + with common_threads.busy_cursor(): + while connected_vm.is_running(): + time.sleep(0.5) else: return False From 696a668bbe6892032d3569247cd723f4f3146cdb Mon Sep 17 00:00:00 2001 From: donoban Date: Mon, 25 Jan 2021 22:40:10 +0100 Subject: [PATCH 05/13] First initiate shutdown for all vm's, then wait --- qubesmanager/qube_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index a45043f..cc43853 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1264,7 +1264,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): for connected_vm in connected_vms: if not self.shutdown_vm(connected_vm): return False - with common_threads.busy_cursor(): + + with common_threads.busy_cursor(): + for connected_vm in connected_vms: while connected_vm.is_running(): time.sleep(0.5) else: From c943e2dd840a8c25f6e5a1bd9a3e51d2366aae5a Mon Sep 17 00:00:00 2001 From: donoban Date: Tue, 26 Jan 2021 23:47:14 +0100 Subject: [PATCH 06/13] Don't wait! --- qubesmanager/qube_manager.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index cc43853..66b57b0 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -22,7 +22,6 @@ # # import subprocess -import time from datetime import datetime, timedelta from functools import partial from os import path @@ -1250,7 +1249,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): try: + cascade = False connected_vms = [x for x in vm.connected_vms if x.is_running()] + if len(connected_vms) > 0: reply = QMessageBox.question( self, self.tr("Qube Shutdown Confirmation"), @@ -1260,19 +1261,15 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): ", ".join([x.name for x in connected_vms])), QMessageBox.Yes | QMessageBox.Cancel) - if reply == QMessageBox.Yes: - for connected_vm in connected_vms: - if not self.shutdown_vm(connected_vm): - return False - - with common_threads.busy_cursor(): - for connected_vm in connected_vms: - while connected_vm.is_running(): - time.sleep(0.5) - else: + if reply != QMessageBox.Yes: return False - vm.shutdown() + cascade = True + for connected_vm in connected_vms: + if not self.shutdown_vm(connected_vm): + return False + + vm.shutdown(force=cascade) except exc.QubesException as ex: QMessageBox.warning( self, From 28120f3a8ffc14ea7d5d26c1892f09ce55f8217e Mon Sep 17 00:00:00 2001 From: donoban Date: Wed, 27 Jan 2021 09:30:21 +0100 Subject: [PATCH 07/13] Rewrite without cascade var --- qubesmanager/qube_manager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 66b57b0..4b54748 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1249,7 +1249,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): try: - cascade = False connected_vms = [x for x in vm.connected_vms if x.is_running()] if len(connected_vms) > 0: @@ -1264,12 +1263,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): if reply != QMessageBox.Yes: return False - cascade = True for connected_vm in connected_vms: if not self.shutdown_vm(connected_vm): return False - vm.shutdown(force=cascade) + vm.shutdown(force=True) + else: + vm.shutdown() except exc.QubesException as ex: QMessageBox.warning( self, From 7a0bc9b863aa82a1393bff30886bdc675f02fd14 Mon Sep 17 00:00:00 2001 From: donoban Date: Tue, 16 Feb 2021 21:28:32 +0100 Subject: [PATCH 08/13] Join all connected VM's in same warning --- qubesmanager/qube_manager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 4b54748..71f905d 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1246,10 +1246,17 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): if reply == QMessageBox.Yes: self.shutdown_vm(vm) + def get_connected_vms(self, vm, connected_vms): + for connected_vm in vm.connected_vms: + if connected_vm.is_running(): + connected_vms.append(connected_vm) + self.get_connected_vms(connected_vm, connected_vms) + def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): try: - connected_vms = [x for x in vm.connected_vms if x.is_running()] + connected_vms = [] + self.get_connected_vms(vm, connected_vms) if len(connected_vms) > 0: reply = QMessageBox.question( @@ -1264,8 +1271,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): return False for connected_vm in connected_vms: - if not self.shutdown_vm(connected_vm): - return False + connected_vm.shutdown(force=True) vm.shutdown(force=True) else: From 60dbeabfb44e5c9535462393a48e898d9b657b12 Mon Sep 17 00:00:00 2001 From: donoban Date: Tue, 16 Feb 2021 22:08:51 +0100 Subject: [PATCH 09/13] use force=True when restarting a netvm with connected vms --- qubesmanager/qube_manager.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 71f905d..ffc016e 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1252,11 +1252,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): connected_vms.append(connected_vm) self.get_connected_vms(connected_vm, connected_vms) - def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, + def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, force=False, check_time=vm_restart_check_timeout, and_restart=False): try: connected_vms = [] - self.get_connected_vms(vm, connected_vms) + + if not and_restart: + self.get_connected_vms(vm, connected_vms) if len(connected_vms) > 0: reply = QMessageBox.question( @@ -1270,12 +1272,12 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): if reply != QMessageBox.Yes: return False + force=True + shutdown_time = shutdown_time * len(connected_vms) for connected_vm in connected_vms: - connected_vm.shutdown(force=True) + connected_vm.shutdown(force=force) - vm.shutdown(force=True) - else: - vm.shutdown() + vm.shutdown(force=force) except exc.QubesException as ex: QMessageBox.warning( self, @@ -1308,7 +1310,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): # in case the user shut down the VM in the meantime try: if manager_utils.is_running(vm, False): - self.shutdown_vm(vm, and_restart=True) + self.shutdown_vm(vm, force=True, and_restart=True) else: self.start_vm(vm) except exc.QubesException as ex: From 6276373fff38655166e49cc0c5c75977beaf2b7e Mon Sep 17 00:00:00 2001 From: donoban Date: Wed, 17 Feb 2021 10:55:20 +0100 Subject: [PATCH 10/13] Show all non halted vm's as running --- qubesmanager/qube_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index ffc016e..fc9e7be 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -668,7 +668,7 @@ class QubesProxyModel(QSortFilterProxyModel): vm = self.sourceModel().data(index, Qt.UserRole) if self.window.show_running.isChecked() and \ - vm.state['power'] == 'Running': + vm.state['power'] != 'Halted': return super().filterAcceptsRow(sourceRow, sourceParent) if self.window.show_halted.isChecked() and \ vm.state['power'] == 'Halted': From 47b0bef3e211d5a6c485a07a15553db277fb6e38 Mon Sep 17 00:00:00 2001 From: donoban Date: Wed, 17 Feb 2021 10:56:29 +0100 Subject: [PATCH 11/13] Fix pylint warning --- qubesmanager/qube_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index fc9e7be..f8f7d5c 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1272,7 +1272,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): if reply != QMessageBox.Yes: return False - force=True + force = True shutdown_time = shutdown_time * len(connected_vms) for connected_vm in connected_vms: connected_vm.shutdown(force=force) From aa0ec0e45d3f642689402c567da84ed2c3c8f11d Mon Sep 17 00:00:00 2001 From: donoban Date: Wed, 24 Feb 2021 16:18:31 +0100 Subject: [PATCH 12/13] Use internal vm.shutdown_timeout --- qubesmanager/qube_manager.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index f8f7d5c..0509262 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -493,17 +493,15 @@ class QubesTableModel(QAbstractTableModel): return def_flags | Qt.ItemIsUserCheckable return def_flags -vm_shutdown_timeout = 20000 # in msec vm_restart_check_timeout = 1000 # in msec class VmShutdownMonitor(QObject): - def __init__(self, vm, shutdown_time=vm_shutdown_timeout, - check_time=vm_restart_check_timeout, + def __init__(self, vm, check_time=vm_restart_check_timeout, and_restart=False, caller=None): QObject.__init__(self) self.vm = vm - self.shutdown_time = shutdown_time + self.shutdown_timeout = vm.shutdown_timeout self.check_time = check_time self.and_restart = and_restart self.shutdown_started = datetime.now() @@ -519,7 +517,7 @@ class VmShutdownMonitor(QObject): def timeout_reached(self): actual = datetime.now() - self.shutdown_started - allowed = timedelta(milliseconds=self.shutdown_time) + allowed = timedelta(milliseconds=self.shutdown_timeout * 1000) return actual > allowed @@ -541,12 +539,12 @@ class VmShutdownMonitor(QObject): msgbox.setText(self.tr( "The Qube '{0}' hasn't shutdown within the last " "{1} seconds, do you want to kill it?
").format( - vm.name, self.shutdown_time / 1000)) + vm.name, self.shutdown_timeout)) kill_button = msgbox.addButton( self.tr("Kill it!"), QMessageBox.YesRole) wait_button = msgbox.addButton( self.tr("Wait another {0} seconds...").format( - self.shutdown_time / 1000), + self.shutdown_timeout), QMessageBox.NoRole) ignore_button = msgbox.addButton(self.tr("Don't ask again"), QMessageBox.RejectRole) @@ -1252,8 +1250,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): connected_vms.append(connected_vm) self.get_connected_vms(connected_vm, connected_vms) - def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, force=False, - check_time=vm_restart_check_timeout, and_restart=False): + def shutdown_vm(self, vm, force=False, check_time=vm_restart_check_timeout, + and_restart=False): try: connected_vms = [] @@ -1273,7 +1271,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): return False force = True - shutdown_time = shutdown_time * len(connected_vms) for connected_vm in connected_vms: connected_vm.shutdown(force=force) @@ -1285,8 +1282,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self.tr("ERROR: {0}").format(ex)) return False - self.shutdown_monitor[vm.qid] = VmShutdownMonitor(vm, shutdown_time, - check_time, + self.shutdown_monitor[vm.qid] = VmShutdownMonitor(vm, check_time, and_restart, self) # noinspection PyCallByClass,PyTypeChecker QTimer.singleShot(check_time, self.shutdown_monitor[ From f5c025216ab8759a06737d4a15e06978ab49a317 Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 27 Feb 2021 13:19:09 +0100 Subject: [PATCH 13/13] Tests suite fixes --- qubesmanager/qube_manager.py | 2 +- qubesmanager/tests/test_qube_manager.py | 64 +++++++++++-------------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 0509262..8ada6a1 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -517,7 +517,7 @@ class VmShutdownMonitor(QObject): def timeout_reached(self): actual = datetime.now() - self.shutdown_started - allowed = timedelta(milliseconds=self.shutdown_timeout * 1000) + allowed = timedelta(seconds=self.shutdown_timeout) return actual > allowed diff --git a/qubesmanager/tests/test_qube_manager.py b/qubesmanager/tests/test_qube_manager.py index fbf8406..324cc5c 100644 --- a/qubesmanager/tests/test_qube_manager.py +++ b/qubesmanager/tests/test_qube_manager.py @@ -156,9 +156,10 @@ class QubeManagerTest(unittest.TestCase): for row in range(self.dialog.table.model().rowCount()): vm = self._get_table_vm(row) - incl_backups_item = self._get_table_item(row, "Include in backups") + incl_backups_item = self._get_table_item(row, "Backup", + Qt.CheckStateRole) incl_backups_value = getattr(vm, 'include_in_backups', False) - incl_backups_value = "Yes" if incl_backups_value else "" + incl_backups_value = Qt.Checked if incl_backups_value else Qt.Unchecked self.assertEqual( incl_backups_value, incl_backups_item, @@ -440,11 +441,10 @@ class QubeManagerTest(unittest.TestCase): with unittest.mock.patch.object(selected_vm, 'shutdown')\ as mock_shutdown: self.dialog.action_shutdownvm.trigger() - mock_shutdown.assert_called_once_with() + mock_shutdown.assert_called_once_with(force=False) mock_monitor.assert_called_once_with( - selected_vm, - unittest.mock.ANY, unittest.mock.ANY, - unittest.mock.ANY, unittest.mock.ANY) + selected_vm, unittest.mock.ANY, unittest.mock.ANY, + unittest.mock.ANY) mock_timer.assert_called_once_with(unittest.mock.ANY, unittest.mock.ANY) @@ -529,10 +529,9 @@ class QubeManagerTest(unittest.TestCase): with unittest.mock.patch.object(selected_vm, 'shutdown')\ as mock_shutdown: action.trigger() - mock_shutdown.assert_called_once_with() + mock_shutdown.assert_called_once_with(force=True) mock_monitor.assert_called_once_with( - selected_vm, unittest.mock.ANY, - unittest.mock.ANY, True, unittest.mock.ANY) + selected_vm, 1000, True, unittest.mock.ANY) @unittest.mock.patch('qubesmanager.qube_manager.StartVMThread') @unittest.mock.patch("PyQt5.QtWidgets.QMessageBox.question", @@ -1133,36 +1132,28 @@ class QubeManagerTest(unittest.TestCase): else: self.assertEqual(call_count, 0) - def test_500_logs(self): + @unittest.mock.patch('qubesmanager.log_dialog.LogDialog') + def test_500_logs(self, mock_logDialog): self._select_admin_vm() - self.assertTrue(self.dialog.logs_menu.isEnabled()) - - dom0_logs = set() - for c in self.dialog.logs_menu.actions(): - dom0_logs.add(c.text()) - self.assertIsNotNone( - c.data(), "Empty log file found: {}".format(c.text())) - self.assertIn("hypervisor", c.text(), - "Log for dom0 does not contain 'hypervisor'") + self.assertTrue(self.dialog.action_show_logs.isEnabled()) + self.dialog.action_show_logs.trigger() + dom0_logs = mock_logDialog.call_args.args[1] + self.assertIn('/var/log/xen/console/hypervisor.log', dom0_logs, + "Log for dom0 does not contain 'hypervisor'") selected_vm = self._select_non_admin_vm(running=True).name - self.assertTrue(self.dialog.logs_menu.isEnabled()) - - vm_logs = set() - for c in self.dialog.logs_menu.actions(): - vm_logs.add(c.text()) - self.assertIsNotNone( - c.data(), - "Empty log file found: {}".format(c.text())) - self.assertIn( - selected_vm, - c.text(), - "Log for {} does not contain its name".format(selected_vm)) + self.assertTrue(self.dialog.action_show_logs.isEnabled()) + self.dialog.action_show_logs.trigger() + vm_logs = mock_logDialog.call_args.args[1] + self.assertIn( + selected_vm, + ",".join(vm_logs), + "Log for {} does not contain its name".format(selected_vm)) self.assertNotEqual(dom0_logs, vm_logs, - "Same logs found for dom0 and non-adminVM") + "Same logs found for dom0 and non-adminVM") def _find_vm_row(self, vm_name): for row in range(self.dialog.table.model().rowCount()): @@ -1434,8 +1425,9 @@ class VMShutdownMonitorTest(unittest.TestCase): mock_vm = unittest.mock.Mock() mock_vm.is_running.return_value = True mock_vm.start_time = datetime.datetime.now().timestamp() - 3000 + mock_vm.shutdown_timeout = 60 - monitor = qube_manager.VmShutdownMonitor(mock_vm, shutdown_time=1) + monitor = qube_manager.VmShutdownMonitor(mock_vm) time.sleep(3) monitor.check_if_vm_has_shutdown() @@ -1451,8 +1443,9 @@ class VMShutdownMonitorTest(unittest.TestCase): mock_vm = unittest.mock.Mock() mock_vm.is_running.return_value = True mock_vm.start_time = datetime.datetime.now().timestamp() - 3000 + mock_vm.shutdown_timeout = 1 - monitor = qube_manager.VmShutdownMonitor(mock_vm, shutdown_time=1) + monitor = qube_manager.VmShutdownMonitor(mock_vm) time.sleep(3) monitor.restart_vm_if_needed = unittest.mock.Mock() @@ -1468,8 +1461,9 @@ class VMShutdownMonitorTest(unittest.TestCase): mock_vm = unittest.mock.Mock() mock_vm.is_running.return_value = True mock_vm.start_time = datetime.datetime.now().timestamp() - 3000 + mock_vm.shutdown_timeout = 30 - monitor = qube_manager.VmShutdownMonitor(mock_vm, shutdown_time=3000) + monitor = qube_manager.VmShutdownMonitor(mock_vm) time.sleep(1) monitor.check_if_vm_has_shutdown()