vsphere/host_data_store_system_helper.go
func diskSpecForExtend(dss *object.HostDatastoreSystem, ds *object.Datastore, name string) (*types.VmfsDatastoreExtendSpec, error) {
	disk, err := availableScsiDisk(dss, name)
	if err != nil {
		return nil, err
	}

	props, err := datastore.Properties(ds)
	if err != nil {
		return nil, fmt.Errorf("error getting properties for datastore ID %q: %s", ds.Reference().Value, err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	options, err := queryVmfsDatastoreExtendOptions(ctx, dss, ds, disk.DevicePath, true)
	if err != nil {
		return nil, fmt.Errorf("could not get disk extension options for %q: %s", name, err)
	}
	var option *types.VmfsDatastoreOption
	for _, o := range options {
		if _, ok := o.Info.(*types.VmfsDatastoreAllExtentOption); ok {
			option = &o
			break
		}
	}
	if option == nil {
		return nil, fmt.Errorf("device %q cannot be used as a new whole-disk device for datastore %q", name, props.Summary.Name)
	}
	return option.Spec.(*types.VmfsDatastoreExtendSpec), nil
}
func diskSpecForExtend(dss *object.HostDatastoreSystem, ds *object.Datastore, name string) (*types.VmfsDatastoreExtendSpec, error) {
	disk, err := availableScsiDisk(dss, name)
	if err != nil {
		return nil, err
	}

	props, err := datastore.Properties(ds)
	if err != nil {
		return nil, fmt.Errorf("error getting properties for datastore ID %q: %s", ds.Reference().Value, err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	options, err := queryVmfsDatastoreExtendOptions(ctx, dss, ds, disk.DevicePath, true)
	if err != nil {
		return nil, fmt.Errorf("could not get disk extension options for %q: %s", name, err)
	}
	var option *types.VmfsDatastoreOption
	for _, o := range options {
		if _, ok := o.Info.(*types.VmfsDatastoreAllExtentOption); ok {
			option = &o
			break
		}
	}
	if option == nil {
		return nil, fmt.Errorf("device %q cannot be used as a new whole-disk device for datastore %q", name, props.Summary.Name)
	}
	return option.Spec.(*types.VmfsDatastoreExtendSpec), nil
}
// diskSpecForExtend checks to make sure that a disk is available to be
// used to extend a VMFS datastore, specifically in its entirety, and returns a
// respective VmfsDatastoreExtendSpec if it is. An error is returned if it's
// not.