vsphere/resource_vsphere_compute_cluster.go
func flattenClusterDasConfigInfo(d *schema.ResourceData, obj types.ClusterDasConfigInfo, version viapi.VSphereVersion) error {
	var dsIDs []string
	for _, v := range obj.HeartbeatDatastore {
		dsIDs = append(dsIDs, v.Value)
	}

	err := structure.SetBatch(d, map[string]interface{}{
		"ha_enabled":                    obj.Enabled,
		"ha_heartbeat_datastore_policy": obj.HBDatastoreCandidatePolicy,
		"ha_host_monitoring":            obj.HostMonitoring,
		"ha_vm_monitoring":              obj.VmMonitoring,
		"ha_heartbeat_datastore_ids":    dsIDs,
	})
	if err != nil {
		return err
	}

	if err := flattenClusterDasVMSettings(d, obj.DefaultVmSettings, version); err != nil {
		return err
	}
	if err := flattenResourceVSphereComputeClusterDasAdvancedOptions(d, obj.Option); err != nil {
		return err
	}

	if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
		if err := d.Set("ha_vm_component_protection", obj.VmComponentProtecting); err != nil {
			return err
		}
	}

	// If AdmissionControlEnabled is false, AdmissionControlPolicy is still
	// configured. Set ha_admission_control_policy to disabled before
	// flattenBaseClusterDasAdmissionControlPolicy, so AdmissionControlEnabled
	// can still be checked.
	if *obj.AdmissionControlEnabled == false {
		return d.Set("ha_admission_control_policy", clusterAdmissionControlTypeDisabled)
	}
	return flattenBaseClusterDasAdmissionControlPolicy(d, obj.AdmissionControlPolicy, version)
}
func flattenClusterDasConfigInfo(d *schema.ResourceData, obj types.ClusterDasConfigInfo, version viapi.VSphereVersion) error {
	var dsIDs []string
	for _, v := range obj.HeartbeatDatastore {
		dsIDs = append(dsIDs, v.Value)
	}

	err := structure.SetBatch(d, map[string]interface{}{
		"ha_enabled":                    obj.Enabled,
		"ha_heartbeat_datastore_policy": obj.HBDatastoreCandidatePolicy,
		"ha_host_monitoring":            obj.HostMonitoring,
		"ha_vm_monitoring":              obj.VmMonitoring,
		"ha_heartbeat_datastore_ids":    dsIDs,
	})
	if err != nil {
		return err
	}

	if err := flattenClusterDasVMSettings(d, obj.DefaultVmSettings, version); err != nil {
		return err
	}
	if err := flattenResourceVSphereComputeClusterDasAdvancedOptions(d, obj.Option); err != nil {
		return err
	}

	if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
		if err := d.Set("ha_vm_component_protection", obj.VmComponentProtecting); err != nil {
			return err
		}
	}

	// If AdmissionControlEnabled is false, AdmissionControlPolicy is still
	// configured. Set ha_admission_control_policy to disabled before
	// flattenBaseClusterDasAdmissionControlPolicy, so AdmissionControlEnabled
	// can still be checked.
	if *obj.AdmissionControlEnabled == false {
		return d.Set("ha_admission_control_policy", clusterAdmissionControlTypeDisabled)
	}
	return flattenBaseClusterDasAdmissionControlPolicy(d, obj.AdmissionControlPolicy, version)
}
func flattenClusterDasConfigInfo ( d * schema . ResourceData , obj types . ClusterDasConfigInfo , version viapi . VSphereVersion ) error { var dsIDs [ ] string for _ , v := range obj . HeartbeatDatastore { dsIDs = append ( dsIDs , v . Value ) } err := structure . SetBatch ( d , map [ string ] interface { } { " " : obj . Enabled , " " : obj . HBDatastoreCandidatePolicy , " " : obj . HostMonitoring , " " : obj . VmMonitoring , " " : dsIDs , } ) if err != nil { return err } if err := flattenClusterDasVMSettings ( d , obj . DefaultVmSettings , version ) ; err != nil { return err } if err := flattenResourceVSphereComputeClusterDasAdvancedOptions ( d , obj . Option ) ; err != nil { return err } if version . Newer ( viapi . VSphereVersion { Product : version . Product , Major : 6 } ) { if err := d . Set ( " " , obj . VmComponentProtecting ) ; err != nil { return err } } // If AdmissionControlEnabled is false, AdmissionControlPolicy is still // configured. Set ha_admission_control_policy to disabled before // flattenBaseClusterDasAdmissionControlPolicy, so AdmissionControlEnabled // can still be checked. if * obj . AdmissionControlEnabled == false { return d . Set ( " " , clusterAdmissionControlTypeDisabled ) } return flattenBaseClusterDasAdmissionControlPolicy ( d , obj . AdmissionControlPolicy , version ) }
// flattenClusterDasConfigInfo saves a ClusterDasConfigInfo into the supplied
// ResourceData.
flattenClusterDasConfigInfo saves a ClusterDasConfigInfo into the supplied ResourceData .