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

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	options, err := dss.QueryVmfsDatastoreCreateOptions(ctx, disk.DevicePath)
	if err != nil {
		return nil, fmt.Errorf("could not get disk creation 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 is not available as a new whole-disk device for datastore", name)
	}
	return option.Spec.(*types.VmfsDatastoreCreateSpec), nil
}
func diskSpecForCreate(dss *object.HostDatastoreSystem, name string) (*types.VmfsDatastoreCreateSpec, error) {
	disk, err := availableScsiDisk(dss, name)
	if err != nil {
		return nil, err
	}

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	options, err := dss.QueryVmfsDatastoreCreateOptions(ctx, disk.DevicePath)
	if err != nil {
		return nil, fmt.Errorf("could not get disk creation 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 is not available as a new whole-disk device for datastore", name)
	}
	return option.Spec.(*types.VmfsDatastoreCreateSpec), nil
}
// diskSpecForCreate checks to make sure that a disk is available to be used to
// create a VMFS datastore, specifically in its entirety, and returns a
// respective VmfsDatastoreCreateSpec.