Skip to content

Commit c33708f

Browse files
authored
PWX-28363: Improving DeviceMapping to reduce api calls (#124)
1 parent 1f27357 commit c33708f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

vsphere/vsphere.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,13 @@ func (ops *vsphereOps) DeviceMappings() (map[string]string, error) {
474474
virtualDevice := device.GetVirtualDevice()
475475
backing, ok := virtualDevice.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
476476
if ok {
477-
devicePath, err := ops.DevicePath(backing.FileName)
477+
diskUUID, err := vmObj.Datacenter.GetVirtualDiskPage83Data(ctx, backing.FileName)
478+
if err != nil {
479+
vmName,_ := vmObj.ObjectName(ctx)
480+
return nil, fmt.Errorf("failed to get device path for disk: %s on vm: %s err: %s", backing.FileName, vmName, err)
481+
}
482+
483+
devicePath, err := path.Join(diskByIDPath, diskSCSIPrefix+diskUUID), nil
478484
if err == nil && len(devicePath) != 0 { // TODO can ignore errors?
479485
m[devicePath] = backing.FileName
480486
}

0 commit comments

Comments
 (0)