Compare commits
No commits in common. "main" and "argo_workflow" have entirely different histories.
main
...
argo_workf
@ -13,8 +13,8 @@ RUN bee generate routers
|
||||
# Generating the swagger
|
||||
RUN timeout 20 bee run -gendoc=true -downdoc=true -runmode=dev || :
|
||||
|
||||
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
|
||||
RUN sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html
|
||||
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html && \
|
||||
sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html
|
||||
|
||||
RUN ls -l routers
|
||||
|
||||
|
31
README.md
31
README.md
@ -31,30 +31,6 @@ const ui = SwaggerUIBundle({
|
||||
|
||||
This issue is fixed in the Dockerfile build with two `sed` to change the value of the swagger file URL.
|
||||
|
||||
## Deployment with Docker compose
|
||||
## Running the app locally
|
||||
In order to run the application we need to correct some errors that beego generates.
|
||||
|
||||
**Router generation**
|
||||
|
||||
Beego generates the routers from the comment of the controllers methods. However, there seems to be some errors when we let beego generate th routers from `bee run`.
|
||||
|
||||
We need to use `bee generate routers` to have a working router file.
|
||||
|
||||
**Swagger generation**
|
||||
|
||||
Using `bee run -downdoc=true -gendoc=true` beego download a swagger template and generate the JSON file (swagger.json) in `swagger/`. However the swagger template in `swagger/index.html` does not change the exemple's url for our current JSON file. When running locally we have to edit the call to construct the object holding the swagger information, with the parameter url set with the relative path to our JSON swagger file :
|
||||
|
||||
```
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "swagger.json",
|
||||
...
|
||||
...
|
||||
});
|
||||
```
|
||||
|
||||
This issue is fixed in the Dockerfile build with two `sed` to change the value of the swagger file URL.
|
||||
|
||||
## Deployment with Docker compose
|
||||
|
||||
Deploy with docker:
|
||||
@ -73,18 +49,15 @@ or out of docker `./scripts/populate_models.sh ./scripts/demo.json`
|
||||
|
||||
### Multinode
|
||||
|
||||
Deploy :
|
||||
### Multinode
|
||||
|
||||
Deploy :
|
||||
|
||||
`docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build`
|
||||
|
||||
## Populating the MongoDB database
|
||||
|
||||
On the machine running the mongoDB container, from the root of the project run this line :
|
||||
From the root of the projet run :
|
||||
|
||||
`./scripts/populate_models.sh ./scripts/demo.json`
|
||||
`./scripts/multinode.sh ./scripts/demo.json`
|
||||
|
||||
This script should be updated to be ran from anywhere.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
|
@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/vk496/cron"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
@startuml mxgraph
|
||||
package MxGraph {
|
||||
|
||||
class MxGraphModel {
|
||||
- XMLName xml.Name
|
||||
+ Root : RootStruct
|
||||
+ createLinks()
|
||||
}
|
||||
|
||||
class RootStruct {
|
||||
- XMLName xml.Name
|
||||
- MxCell[] MxCell
|
||||
- MxObject[] MxObject
|
||||
- MxLink[] MxLink
|
||||
}
|
||||
|
||||
class MxCell {
|
||||
- XMLName xml.Name
|
||||
+ ID string
|
||||
+ RID *string
|
||||
+ Rtype string
|
||||
+ Parent *string
|
||||
+ Edge *string
|
||||
+ Source *string
|
||||
+ Target *string
|
||||
+ processLinks()
|
||||
}
|
||||
|
||||
class MxLink {
|
||||
+ ID string
|
||||
+ Source string
|
||||
+ Target string
|
||||
}
|
||||
|
||||
class MxObject {
|
||||
- XMLName xml.Name
|
||||
+ ID string
|
||||
+ Settings []xml.Attr
|
||||
+ MxCell MxCell
|
||||
}
|
||||
|
||||
class mxissue {
|
||||
- msg string
|
||||
+ Error() string
|
||||
}
|
||||
|
||||
MxGraphModel *-- RootStruct : Root
|
||||
RootStruct *-- MxCell : MxCell
|
||||
RootStruct *-- MxObject : MxObject
|
||||
RootStruct *-- MxLink : MxLink
|
||||
MxObject *-- MxCell : MxCell
|
||||
}
|
||||
|
||||
@enduml
|
@ -1,2 +0,0 @@
|
||||
@startuml
|
||||
@enduml
|
@ -1,5 +0,0 @@
|
||||
For an easier parsing and constrution of dependencies we decided that :
|
||||
|
||||
- Computing elements must be linked between one another, to represent the chaining of events
|
||||
- A storage component can be shared by several computing component, the direction of the arrow will determine if it's for writting or reading
|
||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module cloud.o-forge.io/core/deprecated-oc-catalog
|
||||
module cloud.o-forge.io/core/oc-catalog
|
||||
|
||||
go 1.15
|
||||
|
||||
|
6
main.go
6
main.go
@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/conf"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/routers"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/conf"
|
||||
"cloud.o-forge.io/core/oc-catalog/routers"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
|
||||
"github.com/beego/beego/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
structtomap "github.com/Klathmon/StructToMap"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -1,8 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package models
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
@ -49,5 +49,7 @@ func NewLink(src ResourceObject, srcId string, dst ResourceObject, dstId string)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// So far only computing components expect the ID of the DC in their attributes
|
||||
// func (l *Link) AddLinkToDataCenter(component models.ComputingModel) {
|
||||
// }
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rtype
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/vk496/cron"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -99,7 +99,7 @@ func CheckSchedule(cronString string, duration uint, cronFirstDate, cronLastDate
|
||||
return errors.New("Bad cron message: " + err.Error())
|
||||
}
|
||||
|
||||
dcModel := GetDatacenterFromAcronym(services.DC_NAME)
|
||||
dcModel := GetDatacenterFromAcronym(services.DC_NAME)
|
||||
if dcModel == nil {
|
||||
return errors.New("The DC " + services.DC_NAME + " doesn't have any DC model with that acronym")
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package models
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
swagger "cloud.o-forge.io/core/deprecated-oc-catalog/selfapi"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
swagger "cloud.o-forge.io/core/oc-catalog/selfapi"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/vk496/cron"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -52,11 +52,11 @@ const SchedulesDB = "schedules"
|
||||
|
||||
type Workflow struct {
|
||||
// The key of the map is the ID of the object itself
|
||||
Data map[string]DataObject `json:"data"`
|
||||
Computing map[string]ComputingObject `json:"computing"`
|
||||
Storage map[string]StorageObject `json:"storage"`
|
||||
Datacenter map[string]DatacenterObject `json:"datacenter"` //TODO: Decide if there should be multiple objects of a datacenter
|
||||
Links map[string]Link `json:"link"`
|
||||
Data map[string]DataObject `json:"data"`
|
||||
Computing map[string]ComputingObject `json:"computing"`
|
||||
Storage map[string]StorageObject `json:"storage"`
|
||||
Datacenter map[string]DatacenterObject `json:"datacenter"` //TODO: Decide if there should be multiple objects of a datacenter
|
||||
Links map[string]Link `json:"link"`
|
||||
|
||||
Schedules WorkflowSchedule `json:"schedules"`
|
||||
|
||||
@ -78,7 +78,7 @@ type ResourceObject interface {
|
||||
|
||||
// This type allows to process computing and storage component
|
||||
// which can get input from the user
|
||||
type EditableResourceObject interface {
|
||||
type EditableResourceObject interface{
|
||||
ResourceObject
|
||||
addUserInput(map[string]interface{})
|
||||
}
|
||||
@ -119,13 +119,13 @@ func (w *Workflow) GetResource(rObjID *string) (retObj ResourceObject) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if datVal, ok := w.Data[*rObjID]; ok {
|
||||
retObj = &datVal
|
||||
if storVal, ok := w.Data[*rObjID]; ok {
|
||||
retObj = &storVal
|
||||
return
|
||||
}
|
||||
|
||||
if compVal, ok := w.Computing[*rObjID]; ok {
|
||||
retObj = &compVal
|
||||
if storVal, ok := w.Computing[*rObjID]; ok {
|
||||
retObj = &storVal
|
||||
return
|
||||
}
|
||||
|
||||
@ -134,8 +134,8 @@ func (w *Workflow) GetResource(rObjID *string) (retObj ResourceObject) {
|
||||
return
|
||||
}
|
||||
|
||||
if dcVal, ok := w.Datacenter[*rObjID]; ok {
|
||||
retObj = &dcVal
|
||||
if storVal, ok := w.Datacenter[*rObjID]; ok {
|
||||
retObj = &storVal
|
||||
return
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ func (w *Workflow) AddObj(robj ResourceObject) *primitive.ObjectID {
|
||||
return &outputID
|
||||
}
|
||||
|
||||
func (w *Workflow) AddLinkToWorkflow(link Link, id string) {
|
||||
func (w *Workflow) AddLinkToWorkflow (link Link, id string){
|
||||
if w.Links == nil {
|
||||
w.Links = make(map[string]Link)
|
||||
}
|
||||
@ -547,6 +547,7 @@ func ParseMxGraph(username, workflowName, xmlData string) (err error, mxissues [
|
||||
}
|
||||
|
||||
xmlModel.createLinks()
|
||||
|
||||
|
||||
targetWorkspaceWorkflow, err, mxissues := userWorkspace.ConsumeMxGraphModel(xmlModel)
|
||||
if err != nil {
|
||||
@ -604,38 +605,37 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
|
||||
return xmlmodel.Root.MxCell[i].RID != nil
|
||||
})
|
||||
|
||||
// Create the object and add it to the appropriate list
|
||||
// Create the object and add it to the appropriate list
|
||||
// for all the components with setting, which are identified
|
||||
// by a MxObject tag in the xml
|
||||
if ok := xmlmodel.Root.MxObject != nil; ok {
|
||||
for _, object := range *xmlmodel.Root.MxObject {
|
||||
|
||||
resObj, err, mxissues := returned_wf.mxCellToComponent(object.MxCell, ws)
|
||||
if err != nil {
|
||||
issues = append(issues, mxissues...)
|
||||
}
|
||||
|
||||
// add the component to the worflow's attribute that stores
|
||||
// all components in a map[string]Component where the key
|
||||
// is the component's ID in the mxGraph and the value the Component object
|
||||
returned_wf.UpdateObj(resObj, object.ID)
|
||||
|
||||
// Construct the object corresponding to the componant's type and use its addUserInput method
|
||||
if resObj.getRtype() == rtype.COMPUTING {
|
||||
comp_obj := returned_wf.GetResource(&object.ID).(*ComputingObject)
|
||||
comp_obj.AddUserInput(object.Settings)
|
||||
returned_wf.UpdateObj(comp_obj, object.ID)
|
||||
}
|
||||
// if(resObj.getRtype() == rtype.DATA){
|
||||
// }
|
||||
}
|
||||
}
|
||||
for _, object := range *xmlmodel.Root.MxObject{
|
||||
|
||||
resObj, err, mxissues := returned_wf.mxCellToComponent(object.MxCell,ws)
|
||||
if err != nil {
|
||||
issues = append(issues, mxissues...)
|
||||
}
|
||||
|
||||
// add the component to the worflow's attribute that stores
|
||||
// all components in a map[string]Component where the key
|
||||
// is the component's ID in the mxGraph and the value the Component object
|
||||
returned_wf.UpdateObj(resObj,object.ID)
|
||||
|
||||
// Construct the object corresponding to the componant's type and use its addUserInput method
|
||||
if(resObj.getRtype() == rtype.COMPUTING){
|
||||
comp_obj := returned_wf.GetResource(&object.ID).(*ComputingObject)
|
||||
comp_obj.AddUserInput(object.Settings)
|
||||
returned_wf.UpdateObj(comp_obj,object.ID)
|
||||
}
|
||||
// if(resObj.getRtype() == rtype.DATA){
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
for _, cell := range xmlmodel.Root.MxCell {
|
||||
|
||||
switch {
|
||||
case cell.RID != nil:
|
||||
resObj, err, mxissues := returned_wf.mxCellToComponent(cell, ws)
|
||||
resObj, err, mxissues := returned_wf.mxCellToComponent(cell,ws)
|
||||
if err != nil {
|
||||
issues = append(issues, mxissues...)
|
||||
}
|
||||
@ -674,12 +674,12 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
|
||||
//
|
||||
// The Source will be in the INPUTs of the Target.
|
||||
// But we also must make sure that the Target will be in the OUTPUTs of the Source
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
issues = returned_wf.createLinks(xmlmodel.Root.MxLink, issues)
|
||||
issues = returned_wf.checkLinks(issues)
|
||||
issues = returned_wf.CreateLinks(xmlmodel.Root.MxLink, issues)
|
||||
issues = returned_wf.CheckLinks(issues)
|
||||
|
||||
// dcslist := make(map[string]bool)
|
||||
// dataslist := make(map[string]bool)
|
||||
@ -833,14 +833,14 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
|
||||
return
|
||||
}
|
||||
|
||||
func (w *Workflow) createLinks(links []MxLink, issues []error) []error {
|
||||
func (w *Workflow) CreateLinks(links []MxLink, issues []error) []error {
|
||||
|
||||
for _, link := range links {
|
||||
if (len(link.Source) > 0 && len(link.Target) > 0){
|
||||
sourceObj := w.GetResource(&link.Source)
|
||||
targetObj := w.GetResource(&link.Target)
|
||||
link_object := NewLink(sourceObj, link.Source, targetObj, link.Target)
|
||||
w.AddLinkToWorkflow(link_object, link.ID)
|
||||
link_object := NewLink(sourceObj,link.Source, targetObj, link.Target)
|
||||
w.AddLinkToWorkflow(link_object,link.ID)
|
||||
} else {
|
||||
issues = append(issues, w.processLinkErrors(link))
|
||||
}
|
||||
@ -849,55 +849,56 @@ func (w *Workflow) createLinks(links []MxLink, issues []error) []error {
|
||||
}
|
||||
|
||||
func (w *Workflow) processLinkErrors(link MxLink) (issue error) {
|
||||
if len(link.Source) == 0 && len(link.Target) == 0 {
|
||||
issue = errors.New("Arrow " + link.ID + " is alone")
|
||||
} else if len(link.Source) == 0 {
|
||||
if len(link.Source) == 0 && len(link.Target) == 0 {
|
||||
issue = errors.New("Arrow "+link.ID+" is alone")
|
||||
} else if len(link.Source) == 0{
|
||||
targetObj := w.GetResource(&link.Target)
|
||||
issue = errors.New("Arrow (" + link.ID + ") to " + *targetObj.getName() + " without parent")
|
||||
issue = errors.New("Arrow ("+link.ID+") to "+*targetObj.getName()+" without parent")
|
||||
} else {
|
||||
sourceObj := w.GetResource(&link.Source)
|
||||
issue = errors.New("Arrow " + link.ID + " from " + *sourceObj.getName() + " without target")
|
||||
issue = errors.New("Arrow "+link.ID+" from "+*sourceObj.getName()+" without target")
|
||||
}
|
||||
|
||||
return issue
|
||||
}
|
||||
|
||||
func (w *Workflow) checkLinks(issues []error) []error {
|
||||
func (w *Workflow) CheckLinks(issues []error) []error {
|
||||
|
||||
// Check that storage components have a valid link
|
||||
for id, storage := range w.Storage {
|
||||
if(!w.isComponentSrc(id) && !w.isComponentDst(id)){
|
||||
if(!w.IsComponentSrc(id) && !w.IsComponentDst(id)){
|
||||
issues = append(issues, errors.New("Storage "+*storage.getName()+" without compatible inputs and outputs"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check that data components are linked to a computing component
|
||||
for id, data := range w.Data {
|
||||
if(!w.isLinkedToComputing(id)){
|
||||
if(!w.HasLinkageToComputing(id)){
|
||||
issues = append(issues, errors.New("Data "+*data.getName()+" not attached to any Computing"))
|
||||
}
|
||||
}
|
||||
|
||||
// Check that DC is linked to a computing component
|
||||
for id, dc:= range w.Datacenter {
|
||||
if(!w.isLinkedToComputing(id)){
|
||||
if(!w.HasLinkageToComputing(id)){
|
||||
issues = append(issues, errors.New("Datacenter "+*dc.getName()+" not attached to any Computing"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Check that all data computing components are linked to a DC
|
||||
for id,comp:= range w.Computing {
|
||||
if(!w.isLinkedToDC(id)){
|
||||
if(!w.HasLinkageToDC(id)){
|
||||
issues = append(issues, errors.New("Computing "+*comp.getName()+" not attached to any datacenter"))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return issues
|
||||
}
|
||||
|
||||
func (w *Workflow) isComponentSrc(id string) bool {
|
||||
|
||||
func (w *Workflow) IsComponentSrc(id string) bool {
|
||||
|
||||
for _, link := range w.Links{
|
||||
if(link.Source == id && link.Source != ""){
|
||||
@ -908,7 +909,7 @@ func (w *Workflow) isComponentSrc(id string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Workflow) isComponentDst(id string) bool {
|
||||
func (w *Workflow) IsComponentDst(id string) bool {
|
||||
|
||||
for _, link := range w.Links{
|
||||
if(link.Destination == id && link.Source != ""){
|
||||
@ -919,22 +920,22 @@ func (w *Workflow) isComponentDst(id string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Workflow) isLinkedToComputing(id string) bool {
|
||||
func (w *Workflow) HasLinkageToComputing(id string) bool {
|
||||
|
||||
for idComputing, _ := range w.Computing {
|
||||
if( (w.isComponentSrc(id) && w.isComponentDst(idComputing)) || (w.isComponentSrc(idComputing) && w.isComponentDst(id))){
|
||||
if( (w.IsComponentSrc(id) && w.IsComponentDst(idComputing)) || (w.IsComponentSrc(idComputing) && w.IsComponentDst(id))){
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Workflow) isLinkedToDC(id string) bool {
|
||||
func (w *Workflow) HasLinkageToDC(id string) bool {
|
||||
|
||||
for _, link := range w.Links {
|
||||
if link.Source == id && link.DCLink {
|
||||
for _, link := range w.Links{
|
||||
if(link.Source == id && link.DCLink){
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -1123,15 +1124,15 @@ func CheckAndBookWorkflowSchedule(username, workflowName string, book bool) (myR
|
||||
SchedulesDB: ¤tWorkflow.Schedules}},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
logs.Critical("Internal error when updating in DB: " + err.Error())
|
||||
}
|
||||
|
||||
return myRet, nil
|
||||
}
|
||||
|
||||
// Not sure if this method handles error propagation well
|
||||
func (wf Workflow) mxCellToComponent(cell MxCell, ws Workspace) (resObj ResourceObject, err error, issues []error) {
|
||||
// Not sure if this method handles error propagation well
|
||||
func (wf Workflow) mxCellToComponent(cell MxCell, ws Workspace) (resObj ResourceObject,err error, issues []error){
|
||||
rType := ws.getRtype(*cell.RID)
|
||||
|
||||
if rType == rtype.INVALID {
|
||||
@ -1150,7 +1151,22 @@ func (wf Workflow) mxCellToComponent(cell MxCell, ws Workspace) (resObj Resource
|
||||
|
||||
resObj = wf.CreateResourceObject(rType)
|
||||
resObj.setReference(rIDObj)
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// func (ws Workspace) extractMxCell(xmlModel MxGraphModel){
|
||||
// // Iterate through all objects of the MxGraph
|
||||
// graphObjects := xmlModel.Root.MxObject
|
||||
// for _, object := range(*graphObjects){
|
||||
// current_obj_id, _ := strconv.Atoi(object.ID)
|
||||
// inside_cell_id := strconv.Itoa(current_obj_id + 1)
|
||||
|
||||
// cell := ws.GetResource(&inside_cell_id)
|
||||
// // component := w.GetResource(cell.RID)
|
||||
// fmt.Print(cell)
|
||||
// }
|
||||
// // Extract the mxCell object
|
||||
// // Invoke the addParameter method from the component
|
||||
// // Edit the ID to get the object's one
|
||||
// }
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 345 KiB |
@ -4,8 +4,8 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/controllers"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
|
||||
"cloud.o-forge.io/core/oc-catalog/controllers"
|
||||
"cloud.o-forge.io/core/oc-catalog/models"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/controllers"
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/services"
|
||||
"cloud.o-forge.io/core/oc-catalog/controllers"
|
||||
"cloud.o-forge.io/core/oc-catalog/services"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
|
||||
|
@ -236,27 +236,6 @@
|
||||
},
|
||||
"inputs": [],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"name": "Mosquito server",
|
||||
"short_description": "open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.",
|
||||
"logo": "./local_imgs/mosquitto-logo.png",
|
||||
"description": "A very long description of what this storage is",
|
||||
"type": "computing",
|
||||
"owner": "IRT",
|
||||
"price": 300,
|
||||
"license": "GPLv2",
|
||||
"execution_requirements": {
|
||||
"cpus": 1,
|
||||
"ram": 1024,
|
||||
"storage": 300,
|
||||
"gpus": 1,
|
||||
"disk_io": "30 MB/s",
|
||||
"parallel": true,
|
||||
"scaling_model": 2
|
||||
},
|
||||
"inputs": [],
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -294,6 +273,22 @@
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"URL" : ""
|
||||
},
|
||||
{
|
||||
"name": "Mosquito server",
|
||||
"short_description": "open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.",
|
||||
"logo": "./local_imgs/mosquitto-logo.png",
|
||||
"description": "A very long description of what this storage is",
|
||||
"type": "storage",
|
||||
"DCacronym": "DC_myDC",
|
||||
"size": 40000,
|
||||
"encryption": false,
|
||||
"redundancy": "RAID5S",
|
||||
"throughput": "r:300,w:350",
|
||||
"bookingPrice": 90,
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"URL" : ""
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
@ -3,9 +3,7 @@ package services
|
||||
import (
|
||||
"os"
|
||||
|
||||
conf "cloud.o-forge.io/core/deprecated-oc-catalog/conf"
|
||||
|
||||
SelfAPI "cloud.o-forge.io/core/deprecated-oc-catalog/selfapi"
|
||||
SelfAPI "cloud.o-forge.io/core/oc-catalog/selfapi"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
@ -16,7 +14,6 @@ func GetSelfAPI(host string) *SelfAPI.APIClient {
|
||||
return SelfAPI.NewAPIClient(&SelfAPI.Configuration{BasePath: "http://" + host + "/v1"})
|
||||
}
|
||||
|
||||
// Need to understand why there are so many different DC name
|
||||
func Discoveryinit() {
|
||||
|
||||
dcNameOS := os.Getenv("DOCKER_DCNAME")
|
||||
@ -35,7 +32,4 @@ func Discoveryinit() {
|
||||
DC_NAME = "DC_DEFAULT"
|
||||
logs.Warning("Default DC name is used")
|
||||
|
||||
// Quickfix for scheduling
|
||||
DC_NAME = conf.GetConfig().DCNAME
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/conf"
|
||||
"cloud.o-forge.io/core/oc-catalog/conf"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/deprecated-oc-catalog/conf"
|
||||
"cloud.o-forge.io/core/oc-catalog/conf"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
Loading…
Reference in New Issue
Block a user