Skip to content

Commit

Permalink
Call shutdown_and_reboot_vms from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
emkll committed Feb 17, 2020
1 parent 3d965da commit ff1f1c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
4 changes: 1 addition & 3 deletions launcher/sdw_updater_gui/Updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def apply_updates(vms):
progress_percentage = int(((progress_current + 1) / len(vms)) * 100 - 5)
yield vm, progress_percentage, upgrade_results

_shutdown_and_start_vms()


def _check_updates_dom0():
"""
Expand Down Expand Up @@ -396,7 +394,7 @@ def overall_update_status(results):
return UpdateStatus.UPDATES_OK


def _shutdown_and_start_vms():
def shutdown_and_start_vms():
"""
Power cycles the vms to ensure. we should do them all in one shot to reduce complexity
and likelihood of failure. Rebooting the VMs will ensure the TemplateVM
Expand Down
3 changes: 3 additions & 0 deletions launcher/sdw_updater_gui/UpdaterApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ def run(self):
for vm, progress, result in upgrade_generator:
results[vm] = result
self.progress_signal.emit(progress)
# reboot vms
Updater.shutdown_and_start_vms()

# write flags to disk
run_results = Updater.overall_update_status(results)
Updater._write_updates_status_flag_to_disk(run_results)
Expand Down
22 changes: 4 additions & 18 deletions launcher/tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,12 @@ def test_check_all_updates(

@mock.patch("Updater._write_updates_status_flag_to_disk")
@mock.patch("Updater._write_last_updated_flags_to_disk")
@mock.patch("Updater._shutdown_and_start_vms")
@mock.patch("Updater._apply_updates_vm")
@mock.patch("Updater._apply_updates_dom0", return_value=UpdateStatus.UPDATES_OK)
@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
def test_apply_updates(
mocked_info,
mocked_error,
apply_dom0,
apply_vm,
shutdown,
write_updated,
write_status,
mocked_info, mocked_error, apply_dom0, apply_vm, write_updated, write_status,
):
upgrade_generator = updater.apply_updates(["dom0"])
results = {}
Expand All @@ -354,7 +347,6 @@ def test_apply_updates(

@mock.patch("Updater._write_updates_status_flag_to_disk")
@mock.patch("Updater._write_last_updated_flags_to_disk")
@mock.patch("Updater._shutdown_and_start_vms")
@mock.patch(
"Updater._apply_updates_vm",
side_effect=[UpdateStatus.UPDATES_OK, UpdateStatus.UPDATES_REQUIRED],
Expand All @@ -363,13 +355,7 @@ def test_apply_updates(
@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
def test_apply_updates_required(
mocked_info,
mocked_error,
apply_dom0,
apply_vm,
shutdown,
write_updated,
write_status,
mocked_info, mocked_error, apply_dom0, apply_vm, write_updated, write_status,
):
upgrade_generator = updater.apply_updates(["fedora", "sd-app"])
results = {}
Expand Down Expand Up @@ -527,7 +513,7 @@ def test_write_last_updated_flags_dom0_folder_creation_fail(
@mock.patch("subprocess.check_call")
@mock.patch("Updater._write_updates_status_flag_to_disk")
@mock.patch("Updater._write_last_updated_flags_to_disk")
@mock.patch("Updater._shutdown_and_start_vms")
@mock.patch("Updater.shutdown_and_start_vms")
@mock.patch("Updater._apply_updates_vm")
@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
Expand Down Expand Up @@ -736,7 +722,7 @@ def test_shutdown_and_start_vms(
call("sd-app"),
call("sd-gpg"),
]
updater._shutdown_and_start_vms()
updater.shutdown_and_start_vms()
mocked_shutdown.assert_has_calls(call_list)
mocked_start.assert_has_calls(call_list)
assert not mocked_error.called
Expand Down

0 comments on commit ff1f1c7

Please sign in to comment.