54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package datacenter
|
|
|
|
import (
|
|
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
tool "cloud.o-forge.io/core/oc-lib/utils"
|
|
)
|
|
|
|
type Datacenter struct {
|
|
resources.AbstractResource
|
|
Owner string `bson:"owner" json:"owner" required:"true"`
|
|
BookingPrice int `bson:"booking_price" json:"booking_price" required:"true"`
|
|
|
|
CPU DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
|
|
RAM DatacenterMemoryModel `bson:"ram,omitempty" json:"ram,omitempty"`
|
|
GPU []DatacenterGpuModel `bson:"gpu,omitempty" json:"gpu,omitempty"`
|
|
}
|
|
|
|
type DatacenterCpuModel struct {
|
|
Cores uint `bson:"cores,omitempty" json:"cores,omitempty"` //TODO: validate
|
|
Architecture string `bson:"architecture,omitempty" json:"architecture,omitempty"` //TOOD: enum
|
|
Shared bool `bson:"shared,omitempty" json:"shared,omitempty"`
|
|
MinimumMemory uint `bson:"minimum_memory,omitempty" json:"minimum_memory,omitempty"`
|
|
Platform string `bson:"platform,omitempty" json:"platform,omitempty"`
|
|
}
|
|
|
|
type DatacenterMemoryModel struct {
|
|
Size uint `bson:"size,omitempty" json:"size,omitempty" description:"Units in MB"`
|
|
Ecc bool `bson:"ecc,omitempty" json:"ecc,omitempty"`
|
|
}
|
|
|
|
type DatacenterGpuModel struct {
|
|
CudaCores uint `bson:"cuda_cores,omitempty" json:"cuda_cores,omitempty"`
|
|
Model string `bson:"model,omitempty" json:"model,omitempty"`
|
|
Memory uint `bson:"memory,omitempty" json:"memory,omitempty" description:"Units in MB"`
|
|
TensorCores uint `bson:"tensor_cores,omitempty" json:"tensor_cores,omitempty"`
|
|
}
|
|
|
|
func (d *Datacenter) GetType() resources.ResourceType {
|
|
return resources.DATACENTER
|
|
}
|
|
|
|
func (d *Datacenter) GetAccessor(driver tool.Driver) utils.Accessor {
|
|
var data utils.Accessor
|
|
switch driver {
|
|
case tool.MONGO:
|
|
data = &DatacenterMongoAccessor{}
|
|
default:
|
|
data = &DatacenterMongoAccessor{}
|
|
}
|
|
data.SetLogger()
|
|
return data
|
|
}
|