vsphere/distributed_virtual_switch_structure.go
func schemaDvsHostInfrastructureTrafficResource() map[string]*schema.Schema {
	s := make(map[string]*schema.Schema)
	shareLevelFmt := "The allocation level for the %s traffic class. Can be one of high, low, normal, or custom."
	shareCountFmt := "The amount of shares to allocate to the %s traffic class for a custom share level."
	maxMbitFmt := "The maximum allowed usage for the %s traffic class, in Mbits/sec."
	resMbitFmt := "The amount of guaranteed bandwidth for the %s traffic class, in Mbits/sec."

	for _, class := range infrastructureTrafficClassValues {
		shareLevelKey := fmt.Sprintf("%s_share_level", strings.ToLower(class))
		shareCountKey := fmt.Sprintf("%s_share_count", strings.ToLower(class))
		maxMbitKey := fmt.Sprintf("%s_maximum_mbit", strings.ToLower(class))
		resMbitKey := fmt.Sprintf("%s_reservation_mbit", strings.ToLower(class))

		s[shareLevelKey] = &schema.Schema{
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(shareLevelFmt, class),
			ValidateFunc: validation.StringInSlice(sharesLevelAllowedValues, false),
		}
		s[shareCountKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(shareCountFmt, class),
			ValidateFunc: validation.IntAtLeast(0),
		}
		s[maxMbitKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(maxMbitFmt, class),
			ValidateFunc: validation.IntAtLeast(-1),
		}
		s[resMbitKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(resMbitFmt, class),
			ValidateFunc: validation.IntAtLeast(-1),
		}
	}

	return s
}
func schemaDvsHostInfrastructureTrafficResource() map[string]*schema.Schema {
	s := make(map[string]*schema.Schema)
	shareLevelFmt := "The allocation level for the %s traffic class. Can be one of high, low, normal, or custom."
	shareCountFmt := "The amount of shares to allocate to the %s traffic class for a custom share level."
	maxMbitFmt := "The maximum allowed usage for the %s traffic class, in Mbits/sec."
	resMbitFmt := "The amount of guaranteed bandwidth for the %s traffic class, in Mbits/sec."

	for _, class := range infrastructureTrafficClassValues {
		shareLevelKey := fmt.Sprintf("%s_share_level", strings.ToLower(class))
		shareCountKey := fmt.Sprintf("%s_share_count", strings.ToLower(class))
		maxMbitKey := fmt.Sprintf("%s_maximum_mbit", strings.ToLower(class))
		resMbitKey := fmt.Sprintf("%s_reservation_mbit", strings.ToLower(class))

		s[shareLevelKey] = &schema.Schema{
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(shareLevelFmt, class),
			ValidateFunc: validation.StringInSlice(sharesLevelAllowedValues, false),
		}
		s[shareCountKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(shareCountFmt, class),
			ValidateFunc: validation.IntAtLeast(0),
		}
		s[maxMbitKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(maxMbitFmt, class),
			ValidateFunc: validation.IntAtLeast(-1),
		}
		s[resMbitKey] = &schema.Schema{
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  fmt.Sprintf(resMbitFmt, class),
			ValidateFunc: validation.IntAtLeast(-1),
		}
	}

	return s
}
// schemaDvsHostInfrastructureTrafficResource returns the respective schema
// keys for the various kinds of network I/O control traffic classes. The
// schema items are generated dynamically off of the list of available traffic
// classes for the currently supported vSphere API. Not all traffic classes may
// be supported across all DVS and network I/O control versions.