vsphere/internal/virtualdevice/virtual_machine_disk_subresource.go
func ReadDiskAttrsForDataSource(l object.VirtualDeviceList, count int) ([]map[string]interface{}, error) {
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Fetching select attributes for disks across %d SCSI controllers", count)
	devices := SelectDisks(l, count)
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Disk devices located: %s", DeviceListString(devices))
	// Sort the device list, in case it's not sorted already.
	devSort := virtualDeviceListSorter{
		Sort:       devices,
		DeviceList: l,
	}
	sort.Sort(devSort)
	devices = devSort.Sort
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Disk devices order after sort: %s", DeviceListString(devices))
	var out []map[string]interface{}
	for i, device := range devices {
		disk := device.(*types.VirtualDisk)
		backing, ok := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
		if !ok {
			return nil, fmt.Errorf("disk number %d has an unsupported backing type (expected flat VMDK version 2, got %T)", i, disk.Backing)
		}
		m := make(map[string]interface{})
		var eager, thin bool
		if backing.EagerlyScrub != nil {
			eager = *backing.EagerlyScrub
		}
		if backing.ThinProvisioned != nil {
			thin = *backing.ThinProvisioned
		}
		m["size"] = diskCapacityInGiB(disk)
		m["eagerly_scrub"] = eager
		m["thin_provisioned"] = thin
		out = append(out, m)
	}
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Attributes returned: %+v", out)
	return out, nil
}
func ReadDiskAttrsForDataSource(l object.VirtualDeviceList, count int) ([]map[string]interface{}, error) {
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Fetching select attributes for disks across %d SCSI controllers", count)
	devices := SelectDisks(l, count)
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Disk devices located: %s", DeviceListString(devices))
	// Sort the device list, in case it's not sorted already.
	devSort := virtualDeviceListSorter{
		Sort:       devices,
		DeviceList: l,
	}
	sort.Sort(devSort)
	devices = devSort.Sort
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Disk devices order after sort: %s", DeviceListString(devices))
	var out []map[string]interface{}
	for i, device := range devices {
		disk := device.(*types.VirtualDisk)
		backing, ok := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
		if !ok {
			return nil, fmt.Errorf("disk number %d has an unsupported backing type (expected flat VMDK version 2, got %T)", i, disk.Backing)
		}
		m := make(map[string]interface{})
		var eager, thin bool
		if backing.EagerlyScrub != nil {
			eager = *backing.EagerlyScrub
		}
		if backing.ThinProvisioned != nil {
			thin = *backing.ThinProvisioned
		}
		m["size"] = diskCapacityInGiB(disk)
		m["eagerly_scrub"] = eager
		m["thin_provisioned"] = thin
		out = append(out, m)
	}
	log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Attributes returned: %+v", out)
	return out, nil
}
func ReadDiskAttrsForDataSource ( l object . VirtualDeviceList , count int ) ( [ ] map [ string ] interface { } , error ) { log . Printf ( " " , count ) devices := SelectDisks ( l , count ) log . Printf ( " " , DeviceListString ( devices ) ) // Sort the device list, in case it's not sorted already. devSort := virtualDeviceListSorter { Sort : devices , DeviceList : l , } sort . Sort ( devSort ) devices = devSort . Sort log . Printf ( " " , DeviceListString ( devices ) ) var out [ ] map [ string ] interface { } for i , device := range devices { disk := device . ( * types . VirtualDisk ) backing , ok := disk . Backing . ( * types . VirtualDiskFlatVer2BackingInfo ) if ! ok { return nil , fmt . Errorf ( " " , i , disk . Backing ) } m := make ( map [ string ] interface { } ) var eager , thin bool if backing . EagerlyScrub != nil { eager = * backing . EagerlyScrub } if backing . ThinProvisioned != nil { thin = * backing . ThinProvisioned } m [ " " ] = diskCapacityInGiB ( disk ) m [ " " ] = eager m [ " " ] = thin out = append ( out , m ) } log . Printf ( " " , out ) return out , nil }
// ReadDiskAttrsForDataSource returns select attributes from the list of disks
// on a virtual machine. This is used in the VM data source to discover
// specific options of all of the disks on the virtual machine sorted by the
// order that they would be added in if a clone were to be done.
ReadDiskAttrsForDataSource returns select attributes from the list of disks on a virtual machine . This is used in the VM data source to discover specific options of all of the disks on the virtual machine sorted by the order that they would be added in if a clone were to be done .