2025-06-24 11:29:04 +02:00
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
|
2026-04-28 11:48:23 +02:00
|
|
|
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
|
|
|
|
|
}
|
2025-06-24 11:29:04 +02:00
|
|
|
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
|
|
|
|
|
|
2026-04-28 11:48:23 +02:00
|
|
|
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"`
|
2025-06-24 11:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-28 11:48:23 +02:00
|
|
|
func (r *LiveDatacenter) IsCompatible(service map[string]interface{}) bool {
|
|
|
|
|
return service["infrastructure"] == r.Infrastructure && service["architecture"] == r.Architecture
|
2025-06-24 11:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-28 11:48:23 +02:00
|
|
|
func (d *LiveDatacenter) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
|
|
|
|
return NewAccessor[*LiveDatacenter](tools.LIVE_DATACENTER, request) // Create a new instance of the accessor
|
2025-06-24 11:29:04 +02:00
|
|
|
}
|