rebrand oc-datacenter in oc-compute

This commit is contained in:
mr
2024-11-07 11:05:24 +01:00
parent d249bcdf94
commit 1d6b9db5f9
18 changed files with 121 additions and 93 deletions

View File

@@ -6,7 +6,7 @@ import (
"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/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/workflow/graph"
"cloud.o-forge.io/core/oc-lib/models/utils"
@@ -61,16 +61,16 @@ func (w *AbstractWorkflow) GetProcessings() (list_computings []graph.GraphItem)
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) {
if w.Graph == nil || w.Graph.Items == nil {
return false, ""
}
if d, ok := w.Graph.Items[link.Source.ID]; ok && d.Datacenter != nil {
return true, d.Datacenter.UUID
if d, ok := w.Graph.Items[link.Source.ID]; ok && d.Compute != nil {
return true, d.Compute.UUID
}
if d, ok := w.Graph.Items[link.Destination.ID]; ok && d.Datacenter != nil {
return true, d.Datacenter.UUID
if d, ok := w.Graph.Items[link.Destination.ID]; ok && d.Compute != nil {
return true, d.Compute.UUID
}
return false, ""
}
@@ -92,15 +92,15 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
if wfa.Graph == nil { // no graph no booking
return false, nil
}
accessor := (&datacenter.DatacenterResource{}).GetAccessor(nil)
accessor := (&compute.ComputeResource{}).GetAccessor(nil)
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)
if code != 200 {
continue
}
// CHECK BOOKING ON PEER, datacenter could be a remote one
peerID := dc.(*datacenter.DatacenterResource).PeerID
// CHECK BOOKING ON PEER, compute could be a remote one
peerID := dc.(*compute.ComputeResource).PeerID
if peerID == "" {
return false, errors.New("no peer id")
} // no peer id no booking, we need to know where to book

View File

@@ -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/peer"
"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/workflow_execution"
"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
}
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 {
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)
if code != 200 {
continue
}
// CHECK BOOKING
peerID := dc.(*datacenter.DatacenterResource).PeerID
peerID := dc.(*compute.ComputeResource).PeerID
if peerID == "" { // no peer id no booking
continue
}
@@ -141,7 +141,7 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
_, err := (&peer.Peer{}).LaunchPeerExecution(peerID, "", tools.BOOKING, tools.POST,
(&workflow_execution.WorkflowExecutions{ // it's the standard model for booking see OC-PEER
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"
}).Serialize(), wfa.Caller)
if err != nil {
@@ -297,7 +297,7 @@ func (wfa *workflowMongoAccessor) execute(workflow *Workflow, delete bool, activ
Processings: workflow.Processings,
Storages: workflow.Storages,
Workflows: workflow.Workflows,
Datacenters: workflow.Datacenters,
Computes: workflow.Computes,
},
}, resource[0].GetID())
} 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,
Storages: workflow.Storages,
Workflows: workflow.Workflows,
Datacenters: workflow.Datacenters,
Computes: workflow.Computes,
},
})
}