From 717b083ab93632e5b41d45cbd0a89ba8f18040ea Mon Sep 17 00:00:00 2001 From: Daniel Vincze Date: Tue, 13 Feb 2024 17:03:25 +0200 Subject: [PATCH] Attempt dismounting Windows disks one by one This patch will make sure that every disk is dismounted one by one from the Windows OSMorphing worker, in order to account for workers that have temporary disks attached by default (currently common on Azure platform). This will also prevent the migration task failure in case a disk cannot be set to offline. --- coriolis/osmorphing/osmount/windows.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/coriolis/osmorphing/osmount/windows.py b/coriolis/osmorphing/osmount/windows.py index b577c4c5f..911f229c0 100644 --- a/coriolis/osmorphing/osmount/windows.py +++ b/coriolis/osmorphing/osmount/windows.py @@ -154,9 +154,16 @@ def _get_fs_roots(self, fail_if_empty=False): return drives def _bring_nonboot_disks_offline(self): - self._conn.exec_ps_command( - "Get-Disk | Where-Object { $_.IsBoot -eq $False } | " - "Set-Disk -IsOffline $True") + nonboot_disk_nums = self._conn.exec_ps_command( + "(Get-Disk | Where-Object { $_.IsBoot -eq $False }).Number") + for disk_num in nonboot_disk_nums.splitlines(): + try: + self._conn.exec_ps_command( + "Set-Disk -IsOffline $True %s" % disk_num) + except exception.CoriolisException: + LOG.warning( + "Failed setting disk %s offline. Error was: %s", + disk_num, utils.get_exception_details()) def _rebring_disks_online(self): self._bring_nonboot_disks_offline()