You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2013/12/30 12:21:35 UTC

git commit: updated refs/heads/4.3 to 5a2e4fd

Updated Branches:
  refs/heads/4.3 e4acedbcb -> 5a2e4fd0a


CLOUDSTACK-5560: Reattach of data disk fails for hyperv. When a data disk
is attached a hard disk drive is created on the scsi controller. On detach
the data disk is removed from the drive but the disk drive is left behind.
On reattach the agent was again trying to create a disk drive while it was
already present. Fixed the agent code to look up for disk drive while
attaching and if one is not found then only to create the drive for
attaching a data disk.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a2e4fd0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a2e4fd0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a2e4fd0

Branch: refs/heads/4.3
Commit: 5a2e4fd0a22bc18594e9bac2e15fb4bc8804fa82
Parents: e4acedb
Author: Devdeep Singh <de...@gmail.com>
Authored: Mon Dec 30 23:46:56 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Mon Dec 30 16:52:04 2013 +0530

----------------------------------------------------------------------
 .../ServerResource/HypervResource/WmiCallsV2.cs | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a2e4fd0/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
index 6830fe3..2e3aca5 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -591,7 +591,11 @@ namespace HypervResource
             }
             else
             {
-                ManagementPath newDrivePath = AttachDiskDriveToScsiController(vm, addressOnController);
+                ManagementPath newDrivePath = GetDiskDriveOnScsiController(vm, addressOnController);
+                if (newDrivePath == null)
+                {
+                    newDrivePath = AttachDiskDriveToScsiController(vm, addressOnController);
+                }
                 InsertDiskImage(vm, diskPath, HARDDISK_DISK, newDrivePath);
             }
         }
@@ -779,10 +783,21 @@ namespace HypervResource
             return newResourcePaths[0];
         }
 
-        private ManagementPath GetDiskDriveToScsiController(ComputerSystem vm, string addrOnController)
+        private ManagementPath GetDiskDriveOnScsiController(ComputerSystem vm, string addrOnController)
         {
             VirtualSystemSettingData vmSettings = GetVmSettings(vm);
-            var ctrller = GetScsiControllerSettings(vmSettings);
+            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
+            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
+            {
+                if (wmiObj.ResourceSubType == HARDDISK_DRIVE)
+                {
+                    ResourceAllocationSettingData parent = new ResourceAllocationSettingData(new ManagementObject(wmiObj.Parent));
+                    if (parent.ResourceSubType == SCSI_CONTROLLER && wmiObj.AddressOnParent == addrOnController)
+                    {
+                        return wmiObj.Path;
+                    }
+                }
+            }
             return null;
         }