45 lines
2.3 KiB
Go
45 lines
2.3 KiB
Go
package compute_units
|
|
|
|
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"
|
|
"github.com/biter777/countries"
|
|
)
|
|
|
|
/*
|
|
* ComputeUnits is a struct that represents a compute units in your datacenters
|
|
*/
|
|
|
|
type ComputeUnits struct {
|
|
utils.AbstractObject
|
|
MonitorPath string `json:"monitor_path,omitempty" bson:"monitor_path,omitempty"`
|
|
Location resources.GeoPoint `json:"location,omitempty" bson:"location,omitempty"`
|
|
Country countries.CountryCode `json:"country,omitempty" bson:"country,omitempty"`
|
|
AccessProtocol string `json:"access_protocol,omitempty" bson:"access_protocol,omitempty"`
|
|
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"`
|
|
ResourceID string `json:"-" bson:"-"`
|
|
}
|
|
|
|
func (r *ComputeUnits) StoreDraftDefault() {
|
|
r.IsDraft = true
|
|
}
|
|
|
|
func (r *ComputeUnits) CanDelete() bool {
|
|
return r.IsDraft // only draft ComputeUnits can be deleted
|
|
}
|
|
|
|
func (d *ComputeUnits) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
|
return NewAccessor(request) // Create a new instance of the accessor
|
|
}
|