Просмотр исходного кода

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.
Daniel Vincze 2 лет назад
Родитель
Сommit
f32c25194d
1 измененных файлов с 10 добавлено и 3 удалено
  1. 10 3
      coriolis/osmorphing/osmount/windows.py

+ 10 - 3
coriolis/osmorphing/osmount/windows.py

@@ -154,9 +154,16 @@ class WindowsMountTools(base.BaseOSMountTools):
         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()