rebrand oc-datacenter in oc-compute
This commit is contained in:
parent
d249bcdf94
commit
1d6b9db5f9
@ -19,7 +19,7 @@ func init() {
|
|||||||
{Key: "example", Value: "text"}},
|
{Key: "example", Value: "text"}},
|
||||||
})
|
})
|
||||||
|
|
||||||
IndexesMap["datacenter"] = append(IndexesMap["datacenter"], mongo.IndexModel{Keys: bson.D{
|
IndexesMap["compute"] = append(IndexesMap["compute"], mongo.IndexModel{Keys: bson.D{
|
||||||
{Key: "description", Value: "text"},
|
{Key: "description", Value: "text"},
|
||||||
{Key: "example", Value: "text"},
|
{Key: "example", Value: "text"},
|
||||||
{Key: "owner", Value: "text"}},
|
{Key: "owner", Value: "text"}},
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
||||||
@ -42,7 +42,7 @@ const (
|
|||||||
DATA_RESOURCE = tools.DATA_RESOURCE
|
DATA_RESOURCE = tools.DATA_RESOURCE
|
||||||
PROCESSING_RESOURCE = tools.PROCESSING_RESOURCE
|
PROCESSING_RESOURCE = tools.PROCESSING_RESOURCE
|
||||||
STORAGE_RESOURCE = tools.STORAGE_RESOURCE
|
STORAGE_RESOURCE = tools.STORAGE_RESOURCE
|
||||||
DATACENTER_RESOURCE = tools.DATACENTER_RESOURCE
|
COMPUTE_RESOURCE = tools.COMPUTE_RESOURCE
|
||||||
WORKFLOW_RESOURCE = tools.WORKFLOW_RESOURCE
|
WORKFLOW_RESOURCE = tools.WORKFLOW_RESOURCE
|
||||||
WORKFLOW = tools.WORKFLOW
|
WORKFLOW = tools.WORKFLOW
|
||||||
WORKSPACE = tools.WORKSPACE
|
WORKSPACE = tools.WORKSPACE
|
||||||
@ -155,7 +155,7 @@ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string,
|
|||||||
Resource model is the model that will define the structure of the resources
|
Resource model is the model that will define the structure of the resources
|
||||||
*/
|
*/
|
||||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||||
for _, model := range []string{tools.DATA_RESOURCE.String(), tools.PROCESSING_RESOURCE.String(), tools.STORAGE_RESOURCE.String(), tools.DATACENTER_RESOURCE.String(), tools.WORKFLOW_RESOURCE.String()} {
|
for _, model := range []string{tools.DATA_RESOURCE.String(), tools.PROCESSING_RESOURCE.String(), tools.STORAGE_RESOURCE.String(), tools.COMPUTE_RESOURCE.String(), tools.WORKFLOW_RESOURCE.String()} {
|
||||||
data, code, _ := accessor.Search(nil, model)
|
data, code, _ := accessor.Search(nil, model)
|
||||||
if code == 404 || len(data) == 0 {
|
if code == 404 || len(data) == 0 {
|
||||||
refs := map[string]string{}
|
refs := map[string]string{}
|
||||||
@ -423,9 +423,9 @@ func (l *LibData) ToDataResource() *data.DataResource {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LibData) ToDatacenterResource() *datacenter.DatacenterResource {
|
func (l *LibData) ToComputeResource() *compute.ComputeResource {
|
||||||
if l.Data != nil && l.Data.GetAccessor(nil).GetType() == tools.DATACENTER_RESOURCE.String() {
|
if l.Data != nil && l.Data.GetAccessor(nil).GetType() == tools.COMPUTE_RESOURCE.String() {
|
||||||
return l.Data.(*datacenter.DatacenterResource)
|
return l.Data.(*compute.ComputeResource)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@ import (
|
|||||||
*/
|
*/
|
||||||
type Booking struct {
|
type Booking struct {
|
||||||
workflow_execution.WorkflowExecution // WorkflowExecution contains the workflow execution data
|
workflow_execution.WorkflowExecution // WorkflowExecution contains the workflow execution data
|
||||||
DatacenterResourceID string `json:"datacenter_resource_id,omitempty" bson:"datacenter_resource_id,omitempty" validate:"required"` // DatacenterResourceID is the ID of the datacenter resource specified in the booking
|
ComputeResourceID string `json:"compute_resource_id,omitempty" bson:"compute_resource_id,omitempty" validate:"required"` // ComputeResourceID is the ID of the compute resource specified in the booking
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckBooking checks if a booking is possible on a specific datacenter resource
|
// CheckBooking checks if a booking is possible on a specific compute resource
|
||||||
func (wfa *Booking) CheckBooking(id string, start time.Time, end *time.Time) (bool, error) {
|
func (wfa *Booking) CheckBooking(id string, start time.Time, end *time.Time) (bool, error) {
|
||||||
// check if
|
// check if
|
||||||
if end == nil {
|
if end == nil {
|
||||||
@ -30,8 +30,8 @@ func (wfa *Booking) CheckBooking(id string, start time.Time, end *time.Time) (bo
|
|||||||
e := *end
|
e := *end
|
||||||
accessor := wfa.GetAccessor(nil)
|
accessor := wfa.GetAccessor(nil)
|
||||||
res, code, err := accessor.Search(&dbs.Filters{
|
res, code, err := accessor.Search(&dbs.Filters{
|
||||||
And: map[string][]dbs.Filter{ // check if there is a booking on the same datacenter resource by filtering on the datacenter_resource_id, the state and the execution date
|
And: map[string][]dbs.Filter{ // check if there is a booking on the same compute resource by filtering on the compute_resource_id, the state and the execution date
|
||||||
"datacenter_resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
"compute_resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
||||||
"workflowexecution.state": {{Operator: dbs.EQUAL.String(), Value: workflow_execution.SCHEDULED.EnumIndex()}},
|
"workflowexecution.state": {{Operator: dbs.EQUAL.String(), Value: workflow_execution.SCHEDULED.EnumIndex()}},
|
||||||
"workflowexecution.execution_date": {
|
"workflowexecution.execution_date": {
|
||||||
{Operator: dbs.LTE.String(), Value: primitive.NewDateTimeFromTime(e)},
|
{Operator: dbs.LTE.String(), Value: primitive.NewDateTimeFromTime(e)},
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||||
d "cloud.o-forge.io/core/oc-lib/models/resources/data"
|
d "cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
p "cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
p "cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
s "cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
s "cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
||||||
@ -27,7 +27,7 @@ It's used to create the models dynamically
|
|||||||
var models = map[string]func() utils.DBObject{
|
var models = map[string]func() utils.DBObject{
|
||||||
tools.WORKFLOW_RESOURCE.String(): func() utils.DBObject { return &w.WorkflowResource{} },
|
tools.WORKFLOW_RESOURCE.String(): func() utils.DBObject { return &w.WorkflowResource{} },
|
||||||
tools.DATA_RESOURCE.String(): func() utils.DBObject { return &d.DataResource{} },
|
tools.DATA_RESOURCE.String(): func() utils.DBObject { return &d.DataResource{} },
|
||||||
tools.DATACENTER_RESOURCE.String(): func() utils.DBObject { return &datacenter.DatacenterResource{} },
|
tools.COMPUTE_RESOURCE.String(): func() utils.DBObject { return &compute.ComputeResource{} },
|
||||||
tools.STORAGE_RESOURCE.String(): func() utils.DBObject { return &s.StorageResource{} },
|
tools.STORAGE_RESOURCE.String(): func() utils.DBObject { return &s.StorageResource{} },
|
||||||
tools.PROCESSING_RESOURCE.String(): func() utils.DBObject { return &p.ProcessingResource{} },
|
tools.PROCESSING_RESOURCE.String(): func() utils.DBObject { return &p.ProcessingResource{} },
|
||||||
tools.WORKFLOW.String(): func() utils.DBObject { return &w2.Workflow{} },
|
tools.WORKFLOW.String(): func() utils.DBObject { return &w2.Workflow{} },
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type WebResource struct {
|
type WebResource struct {
|
||||||
Type string `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
|
||||||
Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"` // Protocol is the protocol of the URL
|
Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"` // Protocol is the protocol of the URL
|
||||||
Path string `bson:"path,omitempty" json:"path,omitempty"` // Path is the path of the URL
|
Path string `bson:"path,omitempty" json:"path,omitempty"` // Path is the path of the URL
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package datacenter
|
package compute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -9,17 +9,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DatacenterResource is a struct that represents a datacenter resource
|
* ComputeResource is a struct that represents a compute resource
|
||||||
* it defines the resource datacenter
|
* it defines the resource compute
|
||||||
*/
|
*/
|
||||||
type DatacenterResource struct {
|
type ComputeResource struct {
|
||||||
resource_model.AbstractResource
|
resource_model.AbstractResource
|
||||||
CPUs []*CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs
|
CPUs []*CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` // CPUs is the list of CPUs
|
||||||
RAM *RAM `bson:"ram,omitempty" json:"ram,omitempty"` // RAM is the RAM
|
RAM *RAM `bson:"ram,omitempty" json:"ram,omitempty"` // RAM is the RAM
|
||||||
GPUs []*GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs
|
GPUs []*GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` // GPUs is the list of GPUs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dma *DatacenterResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
func (dma *ComputeResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
||||||
b, err := json.Marshal(j)
|
b, err := json.Marshal(j)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@ -28,7 +28,7 @@ func (dma *DatacenterResource) Deserialize(j map[string]interface{}) utils.DBObj
|
|||||||
return dma
|
return dma
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dma *DatacenterResource) Serialize() map[string]interface{} {
|
func (dma *ComputeResource) Serialize() map[string]interface{} {
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
b, err := json.Marshal(dma)
|
b, err := json.Marshal(dma)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -38,9 +38,9 @@ func (dma *DatacenterResource) Serialize() map[string]interface{} {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DatacenterResource) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
func (d *ComputeResource) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||||
data := New()
|
data := New()
|
||||||
data.Init(tools.DATACENTER_RESOURCE, caller)
|
data.Init(tools.COMPUTE_RESOURCE, caller)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package datacenter
|
package compute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
@ -7,39 +7,39 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type datacenterMongoAccessor struct {
|
type computeMongoAccessor struct {
|
||||||
utils.AbstractAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
utils.AbstractAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new instance of the datacenterMongoAccessor
|
// New creates a new instance of the computeMongoAccessor
|
||||||
func New() *datacenterMongoAccessor {
|
func New() *computeMongoAccessor {
|
||||||
return &datacenterMongoAccessor{}
|
return &computeMongoAccessor{}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nothing special here, just the basic CRUD operations
|
* Nothing special here, just the basic CRUD operations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (dca *datacenterMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
func (dca *computeMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||||
return dca.GenericDeleteOne(id, dca)
|
return dca.GenericDeleteOne(id, dca)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dca *datacenterMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
func (dca *computeMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||||
set.(*DatacenterResource).ResourceModel = nil
|
set.(*ComputeResource).ResourceModel = nil
|
||||||
return dca.GenericUpdateOne(set, id, dca, &DatacenterResource{})
|
return dca.GenericUpdateOne(set, id, dca, &ComputeResource{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dca *datacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (dca *computeMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
data.(*DatacenterResource).ResourceModel = nil
|
data.(*ComputeResource).ResourceModel = nil
|
||||||
return dca.GenericStoreOne(data, dca)
|
return dca.GenericStoreOne(data, dca)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dca *datacenterMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (dca *computeMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
return dca.GenericStoreOne(data, dca)
|
return dca.computeMongoAccessor(data, dca)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dca *datacenterMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
func (dca *computeMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||||
var datacenter DatacenterResource
|
var compute ComputeResource
|
||||||
|
|
||||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, dca.GetType())
|
res_mongo, code, err := mongo.MONGOService.LoadOne(id, dca.GetType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,23 +47,23 @@ func (dca *datacenterMongoAccessor) LoadOne(id string) (utils.DBObject, int, err
|
|||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res_mongo.Decode(&datacenter)
|
res_mongo.Decode(&compute)
|
||||||
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
accessor := (&resource_model.ResourceModel{}).GetAccessor(nil)
|
||||||
resources, _, err := accessor.Search(nil, dca.GetType())
|
resources, _, err := accessor.Search(nil, dca.GetType())
|
||||||
if err == nil && len(resources) > 0 {
|
if err == nil && len(resources) > 0 {
|
||||||
datacenter.ResourceModel = resources[0].(*resource_model.ResourceModel)
|
compute.ResourceModel = resources[0].(*resource_model.ResourceModel)
|
||||||
}
|
}
|
||||||
return &datacenter, 200, nil
|
return &compute, 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa datacenterMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
|
func (wfa computeMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
|
||||||
objs := []utils.ShallowDBObject{}
|
objs := []utils.ShallowDBObject{}
|
||||||
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
|
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wfa.Logger.Error().Msg("Could not retrieve any from db. Error: " + err.Error())
|
wfa.Logger.Error().Msg("Could not retrieve any from db. Error: " + err.Error())
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
var results []DatacenterResource
|
var results []ComputeResource
|
||||||
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
||||||
return nil, 404, err
|
return nil, 404, err
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ func (wfa datacenterMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro
|
|||||||
return objs, 200, nil
|
return objs, 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *datacenterMongoAccessor) Search(filters *dbs.Filters, search string) ([]utils.ShallowDBObject, int, error) {
|
func (wfa *computeMongoAccessor) Search(filters *dbs.Filters, search string) ([]utils.ShallowDBObject, int, error) {
|
||||||
objs := []utils.ShallowDBObject{}
|
objs := []utils.ShallowDBObject{}
|
||||||
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
|
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
|
||||||
filters = &dbs.Filters{
|
filters = &dbs.Filters{
|
||||||
@ -96,7 +96,7 @@ func (wfa *datacenterMongoAccessor) Search(filters *dbs.Filters, search string)
|
|||||||
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
|
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
var results []DatacenterResource
|
var results []ComputeResource
|
||||||
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
|
||||||
return nil, 404, err
|
return nil, 404, err
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package datacenter
|
package compute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreOneDatacenter(t *testing.T) {
|
func TestStoreOneCompute(t *testing.T) {
|
||||||
dc := DatacenterResource{
|
dc := ComputeResource{
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testCompute"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
Owner: "toto",
|
Owner: "toto",
|
||||||
@ -27,10 +27,10 @@ func TestStoreOneDatacenter(t *testing.T) {
|
|||||||
assert.NotEmpty(t, id)
|
assert.NotEmpty(t, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOneDatacenter(t *testing.T) {
|
func TestLoadOneCompute(t *testing.T) {
|
||||||
dc := DatacenterResource{
|
dc := ComputeResource{
|
||||||
AbstractResource: resource_model.AbstractResource{
|
AbstractResource: resource_model.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testCompute"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
Owner: "toto",
|
Owner: "toto",
|
@ -7,7 +7,20 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
)
|
)
|
||||||
|
// enum of public private or licenced data
|
||||||
|
type DataLicense string
|
||||||
|
const (
|
||||||
|
PUBLIC = "public"
|
||||||
|
PRIVATE = "private"
|
||||||
|
LICENCED = "licenced"
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
* Struct of Usage Conditions
|
||||||
|
*/
|
||||||
|
type UsageConditions struct {
|
||||||
|
Usage string `json:"usage,omitempty" bson:"usage,omitempty" description:"usage of the data"` // Usage is the usage of the data
|
||||||
|
Actors []string `json:"actors,omitempty" bson:"actors,omitempty" description:"actors of the data"` // Actors is the actors of the data
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* DataResource is a struct that represents a data resource
|
* DataResource is a struct that represents a data resource
|
||||||
* it defines the resource data
|
* it defines the resource data
|
||||||
@ -15,6 +28,10 @@ import (
|
|||||||
type DataResource struct {
|
type DataResource struct {
|
||||||
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||||
resource_model.WebResource
|
resource_model.WebResource
|
||||||
|
Type string `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
||||||
|
UsageConditions UsageConditions `json:"usage_conditions,omitempty" bson:"usage_conditions,omitempty" description:"usage conditions of the data"` // UsageConditions is the usage conditions of the data
|
||||||
|
License DataLicense `json:"license,omitempty" bson:"license,omitempty" description:"license of the data"` // License is the license of the data
|
||||||
|
Interest DataLicense `json:"interest,omitempty" bson:"interest,omitempty" description:"interest of the data"` // Interest is the interest of the data
|
||||||
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` // Example is an example of the data
|
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` // Example is an example of the data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
"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/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
)
|
)
|
||||||
@ -29,9 +29,9 @@ type Expose struct {
|
|||||||
*/
|
*/
|
||||||
type ProcessingResource struct {
|
type ProcessingResource struct {
|
||||||
resource_model.AbstractResource
|
resource_model.AbstractResource
|
||||||
CPUs []*datacenter.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"` // CPUs is the list of CPUs
|
CPUs []*compute.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"` // CPUs is the list of CPUs
|
||||||
GPUs []*datacenter.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"` // GPUs is the list of GPUs
|
GPUs []*compute.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"` // GPUs is the list of GPUs
|
||||||
RAM *datacenter.RAM `bson:"ram,omitempty" json:"ram,omitempty"` // RAM is the RAM
|
RAM *compute.RAM `bson:"ram,omitempty" json:"ram,omitempty"` // RAM is the RAM
|
||||||
Storage uint `bson:"storage,omitempty" json:"storage,omitempty"` // Storage is the storage
|
Storage uint `bson:"storage,omitempty" json:"storage,omitempty"` // Storage is the storage
|
||||||
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"` // Parallel is a flag that indicates if the processing is parallel
|
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"` // Parallel is a flag that indicates if the processing is parallel
|
||||||
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"` // ScalingModel is the scaling model
|
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"` // ScalingModel is the scaling model
|
||||||
|
@ -3,7 +3,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
||||||
@ -18,13 +18,13 @@ type ResourceSet struct {
|
|||||||
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
|
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
|
||||||
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
|
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
|
||||||
Processings []string `bson:"processings,omitempty" json:"processings,omitempty"`
|
Processings []string `bson:"processings,omitempty" json:"processings,omitempty"`
|
||||||
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
|
Computes []string `bson:"computes,omitempty" json:"computes,omitempty"`
|
||||||
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
|
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
|
||||||
|
|
||||||
DataResources []*data.DataResource `bson:"-" json:"data_resources,omitempty"`
|
DataResources []*data.DataResource `bson:"-" json:"data_resources,omitempty"`
|
||||||
StorageResources []*storage.StorageResource `bson:"-" json:"storage_resources,omitempty"`
|
StorageResources []*storage.StorageResource `bson:"-" json:"storage_resources,omitempty"`
|
||||||
ProcessingResources []*processing.ProcessingResource `bson:"-" json:"processing_resources,omitempty"`
|
ProcessingResources []*processing.ProcessingResource `bson:"-" json:"processing_resources,omitempty"`
|
||||||
DatacenterResources []*datacenter.DatacenterResource `bson:"-" json:"datacenter_resources,omitempty"`
|
ComputeResources []*compute.ComputeResource `bson:"-" json:"compute_resources,omitempty"`
|
||||||
WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"`
|
WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ type ItemResource struct {
|
|||||||
Data *data.DataResource `bson:"data,omitempty" json:"data,omitempty"`
|
Data *data.DataResource `bson:"data,omitempty" json:"data,omitempty"`
|
||||||
Processing *processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
|
Processing *processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
|
||||||
Storage *storage.StorageResource `bson:"storage,omitempty" json:"storage,omitempty"`
|
Storage *storage.StorageResource `bson:"storage,omitempty" json:"storage,omitempty"`
|
||||||
Datacenter *datacenter.DatacenterResource `bson:"datacenter,omitempty" json:"datacenter,omitempty"`
|
Compute *compute.ComputeResource `bson:"compute,omitempty" json:"compute,omitempty"`
|
||||||
Workflow *w.WorkflowResource `bson:"workflow,omitempty" json:"workflow,omitempty"`
|
Workflow *w.WorkflowResource `bson:"workflow,omitempty" json:"workflow,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,12 +47,11 @@ func (i *ItemResource) GetAbstractRessource() *resource_model.AbstractResource {
|
|||||||
if(i.Storage != nil){
|
if(i.Storage != nil){
|
||||||
return &i.Storage.AbstractResource
|
return &i.Storage.AbstractResource
|
||||||
}
|
}
|
||||||
if(i.Datacenter != nil){
|
if(i.Compute != nil){
|
||||||
return &i.Datacenter.AbstractResource
|
return &i.Compute.AbstractResource
|
||||||
}
|
}
|
||||||
if(i.Workflow != nil){
|
if(i.Workflow != nil){
|
||||||
return &i.Workflow.AbstractResource
|
return &i.Workflow.AbstractResource
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@ -28,6 +28,18 @@ func (dma StorageType) ToArgo() string {
|
|||||||
return argoType[dma]
|
return argoType[dma]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enum of a data type
|
||||||
|
type StorageType string
|
||||||
|
const (
|
||||||
|
FILE = "file"
|
||||||
|
STREAM = "stream"
|
||||||
|
API = "api"
|
||||||
|
DATABASE = "database"
|
||||||
|
S3 = "s3"
|
||||||
|
MEMORY = "memory"
|
||||||
|
HARDWARE = "hardware"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* StorageResource is a struct that represents a storage resource
|
* StorageResource is a struct that represents a storage resource
|
||||||
* it defines the resource storage
|
* it defines the resource storage
|
||||||
@ -35,6 +47,7 @@ func (dma StorageType) ToArgo() string {
|
|||||||
type StorageResource struct {
|
type StorageResource struct {
|
||||||
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
resource_model.AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||||
resource_model.WebResource
|
resource_model.WebResource
|
||||||
|
Type DataType `bson:"type,omitempty" json:"type,omitempty"` // Type is the type of the storage
|
||||||
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` // Acronym is the acronym of the storage
|
||||||
SizeType StorageType `bson:"size_type" json:"size_type" default:"0"` // SizeType is the type of the storage size
|
SizeType StorageType `bson:"size_type" json:"size_type" default:"0"` // SizeType is the type of the storage size
|
||||||
Size uint `bson:"size,omitempty" json:"size,omitempty"` // Size is the size of the storage
|
Size uint `bson:"size,omitempty" json:"size,omitempty"` // Size is the size of the storage
|
||||||
|
@ -17,8 +17,8 @@ func (g *Graph) GetResource(id string) (string, utils.DBObject) {
|
|||||||
if item, ok := g.Items[id]; ok {
|
if item, ok := g.Items[id]; ok {
|
||||||
if item.Data != nil {
|
if item.Data != nil {
|
||||||
return tools.DATA_RESOURCE.String(), item.Data
|
return tools.DATA_RESOURCE.String(), item.Data
|
||||||
} else if item.Datacenter != nil {
|
} else if item.Compute != nil {
|
||||||
return tools.DATACENTER_RESOURCE.String(), item.Datacenter
|
return tools.COMPUTE_RESOURCE.String(), item.Compute
|
||||||
} else if item.Workflow != nil {
|
} else if item.Workflow != nil {
|
||||||
return tools.WORKFLOW_RESOURCE.String(), item.Workflow
|
return tools.WORKFLOW_RESOURCE.String(), item.Workflow
|
||||||
} else if item.Processing != nil {
|
} else if item.Processing != nil {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
@ -61,16 +61,16 @@ func (w *AbstractWorkflow) GetProcessings() (list_computings []graph.GraphItem)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// tool function to check if a link is a link between a datacenter and a resource
|
// tool function to check if a link is a link between a compute and a resource
|
||||||
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) (bool, string) {
|
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) (bool, string) {
|
||||||
if w.Graph == nil || w.Graph.Items == nil {
|
if w.Graph == nil || w.Graph.Items == nil {
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
if d, ok := w.Graph.Items[link.Source.ID]; ok && d.Datacenter != nil {
|
if d, ok := w.Graph.Items[link.Source.ID]; ok && d.Compute != nil {
|
||||||
return true, d.Datacenter.UUID
|
return true, d.Compute.UUID
|
||||||
}
|
}
|
||||||
if d, ok := w.Graph.Items[link.Destination.ID]; ok && d.Datacenter != nil {
|
if d, ok := w.Graph.Items[link.Destination.ID]; ok && d.Compute != nil {
|
||||||
return true, d.Datacenter.UUID
|
return true, d.Compute.UUID
|
||||||
}
|
}
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
@ -92,15 +92,15 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
|
|||||||
if wfa.Graph == nil { // no graph no booking
|
if wfa.Graph == nil { // no graph no booking
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
accessor := (&datacenter.DatacenterResource{}).GetAccessor(nil)
|
accessor := (&compute.ComputeResource{}).GetAccessor(nil)
|
||||||
for _, link := range wfa.Graph.Links {
|
for _, link := range wfa.Graph.Links {
|
||||||
if ok, dc_id := wfa.isDCLink(link); ok { // check if the link is a link between a datacenter and a resource
|
if ok, dc_id := wfa.isDCLink(link); ok { // check if the link is a link between a compute and a resource
|
||||||
dc, code, _ := accessor.LoadOne(dc_id)
|
dc, code, _ := accessor.LoadOne(dc_id)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// CHECK BOOKING ON PEER, datacenter could be a remote one
|
// CHECK BOOKING ON PEER, compute could be a remote one
|
||||||
peerID := dc.(*datacenter.DatacenterResource).PeerID
|
peerID := dc.(*compute.ComputeResource).PeerID
|
||||||
if peerID == "" {
|
if peerID == "" {
|
||||||
return false, errors.New("no peer id")
|
return false, errors.New("no peer id")
|
||||||
} // no peer id no booking, we need to know where to book
|
} // no peer id no booking, we need to know where to book
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/workspace"
|
"cloud.o-forge.io/core/oc-lib/models/workspace"
|
||||||
@ -125,15 +125,15 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
|
|||||||
g = realData.Graph
|
g = realData.Graph
|
||||||
}
|
}
|
||||||
if g != nil && g.Links != nil && len(g.Links) > 0 { // if the graph is set and has links then book the workflow (even on ourselves)
|
if g != nil && g.Links != nil && len(g.Links) > 0 { // if the graph is set and has links then book the workflow (even on ourselves)
|
||||||
accessor := (&datacenter.DatacenterResource{}).GetAccessor(nil)
|
accessor := (&compute.ComputeResource{}).GetAccessor(nil)
|
||||||
for _, link := range g.Links {
|
for _, link := range g.Links {
|
||||||
if ok, dc_id := realData.isDCLink(link); ok { // check if the link is a link between a datacenter and a resource booking is only on datacenter
|
if ok, dc_id := realData.isDCLink(link); ok { // check if the link is a link between a compute and a resource booking is only on compute
|
||||||
dc, code, _ := accessor.LoadOne(dc_id)
|
dc, code, _ := accessor.LoadOne(dc_id)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// CHECK BOOKING
|
// CHECK BOOKING
|
||||||
peerID := dc.(*datacenter.DatacenterResource).PeerID
|
peerID := dc.(*compute.ComputeResource).PeerID
|
||||||
if peerID == "" { // no peer id no booking
|
if peerID == "" { // no peer id no booking
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
|
|||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(peerID, "", tools.BOOKING, tools.POST,
|
_, err := (&peer.Peer{}).LaunchPeerExecution(peerID, "", tools.BOOKING, tools.POST,
|
||||||
(&workflow_execution.WorkflowExecutions{ // it's the standard model for booking see OC-PEER
|
(&workflow_execution.WorkflowExecutions{ // it's the standard model for booking see OC-PEER
|
||||||
WorkflowID: id, // set the workflow id "WHO"
|
WorkflowID: id, // set the workflow id "WHO"
|
||||||
ResourceID: dc_id, // set the datacenter id "WHERE"
|
ResourceID: dc_id, // set the compute id "WHERE"
|
||||||
Executions: execs, // set the executions to book "WHAT"
|
Executions: execs, // set the executions to book "WHAT"
|
||||||
}).Serialize(), wfa.Caller)
|
}).Serialize(), wfa.Caller)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -297,7 +297,7 @@ func (wfa *workflowMongoAccessor) execute(workflow *Workflow, delete bool, activ
|
|||||||
Processings: workflow.Processings,
|
Processings: workflow.Processings,
|
||||||
Storages: workflow.Storages,
|
Storages: workflow.Storages,
|
||||||
Workflows: workflow.Workflows,
|
Workflows: workflow.Workflows,
|
||||||
Datacenters: workflow.Datacenters,
|
Computes: workflow.Computes,
|
||||||
},
|
},
|
||||||
}, resource[0].GetID())
|
}, resource[0].GetID())
|
||||||
} else { // if the workspace does not exist, create it
|
} else { // if the workspace does not exist, create it
|
||||||
@ -309,7 +309,7 @@ func (wfa *workflowMongoAccessor) execute(workflow *Workflow, delete bool, activ
|
|||||||
Processings: workflow.Processings,
|
Processings: workflow.Processings,
|
||||||
Storages: workflow.Storages,
|
Storages: workflow.Storages,
|
||||||
Workflows: workflow.Workflows,
|
Workflows: workflow.Workflows,
|
||||||
Datacenters: workflow.Datacenters,
|
Computes: workflow.Computes,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
// Workspace is a struct that represents a workspace
|
// Workspace is a struct that represents a workspace
|
||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||||
resources.ResourceSet // ResourceSet contains the resources of the workspace (data, datacenter, processing, storage, workflow)
|
resources.ResourceSet // ResourceSet contains the resources of the workspace (data, compute, processing, storage, workflow)
|
||||||
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"` // IsContextual is a flag that indicates if the workspace is contextual
|
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"` // IsContextual is a flag that indicates if the workspace is contextual
|
||||||
Active bool `json:"active" bson:"active" default:"false"` // Active is a flag that indicates if the workspace is active
|
Active bool `json:"active" bson:"active" default:"false"` // Active is a flag that indicates if the workspace is active
|
||||||
Shared string `json:"shared,omitempty" bson:"shared,omitempty"` // Shared is the ID of the shared workspace
|
Shared string `json:"shared,omitempty" bson:"shared,omitempty"` // Shared is the ID of the shared workspace
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
||||||
@ -40,7 +40,7 @@ func (wfa *workspaceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, er
|
|||||||
func (wfa *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
func (wfa *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||||
d := set.(*Workspace) // Get the workspace from the set
|
d := set.(*Workspace) // Get the workspace from the set
|
||||||
d.DataResources = nil // Reset the resources
|
d.DataResources = nil // Reset the resources
|
||||||
d.DatacenterResources = nil
|
d.ComputeResources = nil
|
||||||
d.StorageResources = nil
|
d.StorageResources = nil
|
||||||
d.ProcessingResources = nil
|
d.ProcessingResources = nil
|
||||||
d.WorkflowResources = nil
|
d.WorkflowResources = nil
|
||||||
@ -76,7 +76,7 @@ func (wfa *workspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject
|
|||||||
// reset the resources
|
// reset the resources
|
||||||
d := data.(*Workspace)
|
d := data.(*Workspace)
|
||||||
d.DataResources = nil
|
d.DataResources = nil
|
||||||
d.DatacenterResources = nil
|
d.ComputeResources = nil
|
||||||
d.StorageResources = nil
|
d.StorageResources = nil
|
||||||
d.ProcessingResources = nil
|
d.ProcessingResources = nil
|
||||||
d.WorkflowResources = nil
|
d.WorkflowResources = nil
|
||||||
@ -102,13 +102,13 @@ func (wfa *workspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fill the workspace with the datacenters
|
// Fill the workspace with the computes
|
||||||
if workflow.Datacenters != nil && len(workflow.Datacenters) > 0 {
|
if workflow.Computes != nil && len(workflow.Computes) > 0 {
|
||||||
dataAccessor := (&datacenter.DatacenterResource{}).GetAccessor(nil)
|
dataAccessor := (&compute.ComputeResource{}).GetAccessor(nil)
|
||||||
for _, id := range workflow.Datacenters {
|
for _, id := range workflow.Computes {
|
||||||
d, _, e := dataAccessor.LoadOne(id)
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
workflow.DatacenterResources = append(workflow.DatacenterResources, d.(*datacenter.DatacenterResource))
|
workflow.ComputeResources = append(workflow.ComputeResources, d.(*compute.ComputeResource))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ const (
|
|||||||
DATA_RESOURCE
|
DATA_RESOURCE
|
||||||
PROCESSING_RESOURCE
|
PROCESSING_RESOURCE
|
||||||
STORAGE_RESOURCE
|
STORAGE_RESOURCE
|
||||||
DATACENTER_RESOURCE
|
COMPUTE_RESOURCE
|
||||||
WORKFLOW_RESOURCE
|
WORKFLOW_RESOURCE
|
||||||
WORKFLOW
|
WORKFLOW
|
||||||
WORKFLOW_EXECUTION
|
WORKFLOW_EXECUTION
|
||||||
@ -56,7 +56,7 @@ var Str = [...]string{
|
|||||||
"data_resource",
|
"data_resource",
|
||||||
"processing_resource",
|
"processing_resource",
|
||||||
"storage_resource",
|
"storage_resource",
|
||||||
"datacenter_resource",
|
"compute_resource",
|
||||||
"workflow_resource",
|
"workflow_resource",
|
||||||
"workflow",
|
"workflow",
|
||||||
"workflow_execution",
|
"workflow_execution",
|
||||||
|
Loading…
Reference in New Issue
Block a user