implement remote call for remote action
This commit is contained in:
@@ -6,13 +6,14 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
type ProcessingResource struct {
|
||||
resource_model.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"`
|
||||
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"`
|
||||
@@ -38,8 +39,8 @@ func (dma *ProcessingResource) Serialize() map[string]interface{} {
|
||||
return m
|
||||
}
|
||||
|
||||
func (d *ProcessingResource) GetAccessor() utils.Accessor {
|
||||
func (d *ProcessingResource) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.SetLogger(utils.PROCESSING_RESOURCE)
|
||||
data.Init(utils.PROCESSING_RESOURCE, caller)
|
||||
return data
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ func (pma *processingMongoAccessor) LoadOne(id string) (utils.DBObject, int, err
|
||||
}
|
||||
|
||||
res_mongo.Decode(&processing)
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor()
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||
resources, _, err := accessor.Search(nil, pma.GetType())
|
||||
if err == nil && len(resources) > 0 {
|
||||
processing.ResourceModel = resources[0].(*resource_model.ResourceModel)
|
||||
@@ -63,7 +63,7 @@ func (wfa processingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro
|
||||
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
||||
return nil, 404, err
|
||||
}
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor()
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||
resources, _, err := accessor.Search(nil, wfa.GetType())
|
||||
for _, r := range results {
|
||||
if err == nil && len(resources) > 0 {
|
||||
@@ -96,7 +96,7 @@ func (wfa *processingMongoAccessor) Search(filters *dbs.Filters, search string)
|
||||
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
||||
return nil, 404, err
|
||||
}
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor()
|
||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||
resources, _, err := accessor.Search(nil, wfa.GetType())
|
||||
for _, r := range results {
|
||||
if err == nil && len(resources) > 0 {
|
||||
|
Reference in New Issue
Block a user