mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
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.
This commit is contained in:
parent
5882123f19
commit
785931b6f0
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user