Explorar el Código

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 hace 2 años
padre
commit
f32c25194d
Se han modificado 1 ficheros con 10 adiciones y 3 borrados
  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
         return drives
 
 
     def _bring_nonboot_disks_offline(self):
     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):
     def _rebring_disks_online(self):
         self._bring_nonboot_disks_offline()
         self._bring_nonboot_disks_offline()