48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package processing
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
)
|
|
|
|
type ProcessingResource struct {
|
|
utils.AbstractResource
|
|
CPUs []*datacenter.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"`
|
|
GPUs []*datacenter.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"`
|
|
RAM datacenter.RAM `bson:"ram,omitempty" json:"ram,omitempty"`
|
|
Storage uint `bson:"storage,omitempty" json:"storage,omitempty"`
|
|
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"`
|
|
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
|
|
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
|
|
|
|
// Price uint `bson:"price,omitempty" json:"price,omitempty"`
|
|
// License string `bson:"license,omitempty" json:"license,omitempty"`
|
|
}
|
|
|
|
func (dma *ProcessingResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
|
b, err := json.Marshal(j)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
json.Unmarshal(b, dma)
|
|
return dma
|
|
}
|
|
|
|
func (dma *ProcessingResource) Serialize() map[string]interface{} {
|
|
var m map[string]interface{}
|
|
b, err := json.Marshal(dma)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
json.Unmarshal(b, &m)
|
|
return m
|
|
}
|
|
|
|
func (d *ProcessingResource) GetAccessor() utils.Accessor {
|
|
data := &ProcessingMongoAccessor{}
|
|
data.SetLogger(utils.PROCESSING_RESOURCE)
|
|
return data
|
|
}
|