vsphere/host_data_store_system_helper.go
func availableScsiDisk(dss *object.HostDatastoreSystem, name string) (*types.HostScsiDisk, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	disks, err := dss.QueryAvailableDisksForVmfs(ctx)
	if err != nil {
		return nil, fmt.Errorf("cannot query available disks: %s", err)
	}

	var disk *types.HostScsiDisk
	for _, d := range disks {
		if d.CanonicalName == name {
			disk = &d
			break
		}
	}
	if disk == nil {
		return nil, fmt.Errorf("%s does not seem to be a disk available for VMFS", name)
	}
	return disk, nil
}
func availableScsiDisk(dss *object.HostDatastoreSystem, name string) (*types.HostScsiDisk, error) {
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	disks, err := dss.QueryAvailableDisksForVmfs(ctx)
	if err != nil {
		return nil, fmt.Errorf("cannot query available disks: %s", err)
	}

	var disk *types.HostScsiDisk
	for _, d := range disks {
		if d.CanonicalName == name {
			disk = &d
			break
		}
	}
	if disk == nil {
		return nil, fmt.Errorf("%s does not seem to be a disk available for VMFS", name)
	}
	return disk, nil
}
func availableScsiDisk ( dss * object . HostDatastoreSystem , name string ) ( * types . HostScsiDisk , error ) { ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultAPITimeout ) defer cancel ( ) disks , err := dss . QueryAvailableDisksForVmfs ( ctx ) if err != nil { return nil , fmt . Errorf ( " " , err ) } var disk * types . HostScsiDisk for _ , d := range disks { if d . CanonicalName == name { disk = & d break } } if disk == nil { return nil , fmt . Errorf ( " " , name ) } return disk , nil }
// availableScsiDisk checks to make sure that a disk is available for use in a
// VMFS datastore, and returns the ScsiDisk.
availableScsiDisk checks to make sure that a disk is available for use in a VMFS datastore and returns the ScsiDisk .