diff --git a/models/resources/compute.go b/models/resources/compute.go index 242cd8a..575c9e1 100644 --- a/models/resources/compute.go +++ b/models/resources/compute.go @@ -63,23 +63,14 @@ type ComputeResourcePartnership struct { MaxAllowedRAMSize float64 `json:"allowed_ram,omitempty" bson:"allowed_ram,omitempty"` } -type ComputeResourcePricingProfileOptions struct { - CPUCore int `json:"cpu_core" bson:"cpu_core" default:"1"` - GPUMemoryGB float64 `json:"gpu_memory_gb" bson:"gpu_memory_gb" default:"1"` - RAMSizeGB float64 `json:"ram_size_gb" bson:"ram_size_gb" default:"1"` -} - type ComputeResourcePricingProfile struct { pricing.ExploitPricingProfile[pricing.TimePricingStrategy] - Options ComputeResourcePricingProfileOptions `json:"options,omitempty" bson:"options,omitempty"` // Options is the options of the pricing profile // ExploitPricingProfile is the pricing profile of a compute it means that we exploit the resource for an amount of continuous time - OverrideCPUsPrices map[string]float64 `json:"cpus_prices,omitempty" bson:"cpus_prices,omitempty"` // CPUsPrices is the prices of the CPUs - OverrideGPUsPrices map[string]float64 `json:"gpus_prices,omitempty" bson:"gpus_prices,omitempty"` // GPUsPrices is the prices of the GPUs - OverrideRAMPrice float64 `json:"ram_price" bson:"ram_price" default:"-1"` // RAMPrice is the price of the RAM + CPUsPrices map[string]float64 `json:"cpus_prices,omitempty" bson:"cpus_prices,omitempty"` // CPUsPrices is the prices of the CPUs + GPUsPrices map[string]float64 `json:"gpus_prices,omitempty" bson:"gpus_prices,omitempty"` // GPUsPrices is the prices of the GPUs + RAMPrice float64 `json:"ram_price" bson:"ram_price" default:"-1"` // RAMPrice is the price of the RAM } -// PROBLEM - func (p *ComputeResourcePricingProfile) IsPurchased() bool { return p.Pricing.BuyingStrategy != pricing.PAY_PER_USE } @@ -97,10 +88,10 @@ func (p *ComputeResourcePricingProfile) GetPrice(amountOfData float64, explicitD pp := float64(0) model := params[1] if strings.Contains(params[0], "cpus") && len(params) > 1 { - if _, ok := p.OverrideCPUsPrices[model]; ok { - p.Pricing.Price = p.OverrideCPUsPrices[model] + if _, ok := p.CPUsPrices[model]; ok { + p.Pricing.Price = p.CPUsPrices[model] } - r, err := p.Pricing.GetPrice(amountOfData/float64(p.Options.CPUCore), explicitDuration, start, &end) + r, err := p.Pricing.GetPrice(amountOfData, explicitDuration, start, &end) if err != nil { return 0, err } @@ -108,20 +99,20 @@ func (p *ComputeResourcePricingProfile) GetPrice(amountOfData float64, explicitD } if strings.Contains(params[0], "gpus") && len(params) > 1 { - if _, ok := p.OverrideGPUsPrices[model]; ok { - p.Pricing.Price = p.OverrideGPUsPrices[model] + if _, ok := p.GPUsPrices[model]; ok { + p.Pricing.Price = p.GPUsPrices[model] } - r, err := p.Pricing.GetPrice(amountOfData/float64(p.Options.GPUMemoryGB), explicitDuration, start, &end) + r, err := p.Pricing.GetPrice(amountOfData, explicitDuration, start, &end) if err != nil { return 0, err } pp += r } if strings.Contains(params[0], "ram") { - if p.OverrideRAMPrice >= 0 { - p.Pricing.Price = p.OverrideRAMPrice + if p.RAMPrice >= 0 { + p.Pricing.Price = p.RAMPrice } - r, err := p.Pricing.GetPrice(float64(amountOfData)/p.Options.RAMSizeGB, explicitDuration, start, &end) + r, err := p.Pricing.GetPrice(float64(amountOfData), explicitDuration, start, &end) if err != nil { return 0, err }