github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/transform.go (about)

     1  package engine
     2  
     3  import (
     4  	resourcetypes "github.com/projecteru2/core/resource/types"
     5  )
     6  
     7  // TODO 可以考虑进一步简化,每个 engine 自行处理
     8  
     9  // VirtualizationResource define resources
    10  type VirtualizationResource struct {
    11  	CPU           map[string]int64            `json:"cpu_map" mapstructure:"cpu_map"` // for cpu binding
    12  	Quota         float64                     `json:"cpu" mapstructure:"cpu"`         // for cpu quota
    13  	Memory        int64                       `json:"memory" mapstructure:"memory"`   // for memory binding
    14  	Storage       int64                       `json:"storage" mapstructure:"storage"`
    15  	NUMANode      string                      `json:"numa_node" mapstructure:"numa_node"` // numa node
    16  	Volumes       []string                    `json:"volumes" mapstructure:"volumes"`
    17  	VolumePlan    map[string]map[string]int64 `json:"volume_plan" mapstructure:"volume_plan"`       // literal VolumePlan
    18  	VolumeChanged bool                        `json:"volume_changed" mapstructure:"volume_changed"` // indicate whether new volumes contained in realloc request
    19  	IOPSOptions   map[string]string           `json:"iops_options" mapstructure:"IOPS_options"`     // format: {device_name: "read-IOPS:write-IOPS:read-bps:write-bps"}
    20  	Remap         bool                        `json:"remap" mapstructure:"remap"`
    21  }
    22  
    23  // MakeVirtualizationResource .
    24  func MakeVirtualizationResource[T any](engineParams resourcetypes.Resources, dst T, f func(resourcetypes.Resources, T) error) error {
    25  	return f(engineParams, dst)
    26  }