package live import ( "cloud.o-forge.io/core/oc-lib/models/common/enum" "cloud.o-forge.io/core/oc-lib/models/common/models" "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" ) /* * LiveDatacenter is a struct that represents a compute units in your datacenters */ type ComputeNode struct { Name string `json:"name,omitempty" bson:"name,omitempty"` Quantity int64 `json:"quantity" bson:"quantity" default:"1"` RAM *models.RAM `bson:"ram,omitempty" json:"ram,omitempty"` // RAM is the RAM CPUs map[string]int64 `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs key is model GPUs map[string]int64 `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs key is model } type LiveDatacenter struct { AbstractLive StorageType enum.StorageType `bson:"storage_type" json:"storage_type" default:"-1"` // Type is the type of the storage Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage Architecture string `json:"architecture,omitempty" bson:"architecture,omitempty"` // Architecture is the architecture Infrastructure enum.InfrastructureType `json:"infrastructure" bson:"infrastructure" default:"-1"` // Infrastructure is the infrastructure Source string `json:"source,omitempty" bson:"source,omitempty"` // Source is the source of the resource SecurityLevel string `json:"security_level,omitempty" bson:"security_level,omitempty"` PowerSources []string `json:"power_sources,omitempty" bson:"power_sources,omitempty"` AnnualCO2Emissions float64 `json:"annual_co2_emissions,omitempty" bson:"co2_emissions,omitempty"` CPUs map[string]*models.CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs key is model GPUs map[string]*models.GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs key is model Nodes []*ComputeNode `json:"nodes,omitempty" bson:"nodes,omitempty"` } func (r *LiveDatacenter) IsCompatible(service map[string]interface{}) bool { return service["infrastructure"] == r.Infrastructure && service["architecture"] == r.Architecture } func (d *LiveDatacenter) GetAccessor(request *tools.APIRequest) utils.Accessor { return NewAccessor[*LiveDatacenter](tools.LIVE_DATACENTER, request) // Create a new instance of the accessor }