vsphere/resource_vsphere_datastore_cluster.go
func flattenStorageDrsIoLoadBalanceConfig(
	d *schema.ResourceData,
	obj *types.StorageDrsIoLoadBalanceConfig,
	version viapi.VSphereVersion,
) error {
	attrs := map[string]interface{}{
		"sdrs_io_latency_threshold":        obj.IoLatencyThreshold,
		"sdrs_io_load_imbalance_threshold": obj.IoLoadImbalanceThreshold,
	}
	if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
		attrs["sdrs_io_reservable_threshold_mode"] = obj.ReservableThresholdMode
		if obj.ReservableThresholdMode == string(types.StorageDrsPodConfigInfoBehaviorManual) {
			attrs["sdrs_io_reservable_iops_threshold"] = obj.ReservableIopsThreshold
		} else {
			attrs["sdrs_io_reservable_percent_threshold"] = obj.ReservablePercentThreshold
		}
	}

	for k, v := range attrs {
		if err := d.Set(k, v); err != nil {
			return fmt.Errorf("error setting attribute %q: %s", k, err)
		}
	}

	return nil
}
func flattenStorageDrsIoLoadBalanceConfig(
	d *schema.ResourceData,
	obj *types.StorageDrsIoLoadBalanceConfig,
	version viapi.VSphereVersion,
) error {
	attrs := map[string]interface{}{
		"sdrs_io_latency_threshold":        obj.IoLatencyThreshold,
		"sdrs_io_load_imbalance_threshold": obj.IoLoadImbalanceThreshold,
	}
	if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
		attrs["sdrs_io_reservable_threshold_mode"] = obj.ReservableThresholdMode
		if obj.ReservableThresholdMode == string(types.StorageDrsPodConfigInfoBehaviorManual) {
			attrs["sdrs_io_reservable_iops_threshold"] = obj.ReservableIopsThreshold
		} else {
			attrs["sdrs_io_reservable_percent_threshold"] = obj.ReservablePercentThreshold
		}
	}

	for k, v := range attrs {
		if err := d.Set(k, v); err != nil {
			return fmt.Errorf("error setting attribute %q: %s", k, err)
		}
	}

	return nil
}
func flattenStorageDrsIoLoadBalanceConfig ( d * schema . ResourceData , obj * types . StorageDrsIoLoadBalanceConfig , version viapi . VSphereVersion , ) error { attrs := map [ string ] interface { } { " " : obj . IoLatencyThreshold , " " : obj . IoLoadImbalanceThreshold , } if version . Newer ( viapi . VSphereVersion { Product : version . Product , Major : 6 } ) { attrs [ " " ] = obj . ReservableThresholdMode if obj . ReservableThresholdMode == string ( types . StorageDrsPodConfigInfoBehaviorManual ) { attrs [ " " ] = obj . ReservableIopsThreshold } else { attrs [ " " ] = obj . ReservablePercentThreshold } } for k , v := range attrs { if err := d . Set ( k , v ) ; err != nil { return fmt . Errorf ( " " , k , err ) } } return nil }
// flattenStorageDrsIoLoadBalanceConfig saves a StorageDrsIoLoadBalanceConfig
// into the supplied ResourceData.
flattenStorageDrsIoLoadBalanceConfig saves a StorageDrsIoLoadBalanceConfig into the supplied ResourceData .