Live Structure
This commit is contained in:
50
models/live/live_datacenter.go
Normal file
50
models/live/live_datacenter.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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/resources"
|
||||
"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 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 []*resources.ComputeNode `json:"nodes,omitempty" bson:"nodes,omitempty"`
|
||||
}
|
||||
|
||||
func (d *LiveDatacenter) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
return NewAccessor[*LiveDatacenter](request) // Create a new instance of the accessor
|
||||
}
|
||||
func (d *LiveDatacenter) GetResourceAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
return resources.NewAccessor[*resources.ComputeResource](tools.COMPUTE_RESOURCE, request, func() utils.DBObject { return &resources.ComputeResource{} })
|
||||
}
|
||||
|
||||
func (d *LiveDatacenter) GetResource() resources.ResourceInterface {
|
||||
return &resources.ComputeResource{}
|
||||
}
|
||||
func (d *LiveDatacenter) GetResourceInstance() resources.ResourceInstanceITF {
|
||||
return &resources.ComputeResourceInstance{}
|
||||
}
|
||||
|
||||
func (d *LiveDatacenter) SetResourceInstance(res resources.ResourceInterface, i resources.ResourceInstanceITF) resources.ResourceInterface {
|
||||
r := res.(*resources.ComputeResource)
|
||||
r.Instances = append(r.Instances, i.(*resources.ComputeResourceInstance))
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user