added links models to workflow
This commit is contained in:
@@ -1,26 +1,34 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
source string
|
||||
destination string
|
||||
dcLink bool
|
||||
// ID primitive.ObjectID `json:"ID" bson:"_id" required:"true" example:"5099803df3f4948bd2f98391"`
|
||||
Source string `json:"source" description:"id in the workflow of the source object"`
|
||||
Destination string `json:"destination" description:"id in the workflow of the destination object"`
|
||||
DCLink bool `json:"dcLink" description:"is this a link with a datacenter"`
|
||||
}
|
||||
|
||||
func NewLink(src interface{}, dst interface{}) (link Link) {
|
||||
// Check type with reflect and get ID
|
||||
typeSrc := reflect.TypeOf(src)
|
||||
typeDst := reflect.TypeOf(dst)
|
||||
// Use ResourceObject parameter to process certain components type differently
|
||||
// and Id's to identify each component as a node in an oriented graph
|
||||
|
||||
fmt.Println("src is %s\ndst is %s",typeSrc,typeDst)
|
||||
func NewLink(src ResourceObject, srcId string, dst ResourceObject, dstId string) (link Link) {
|
||||
|
||||
link.Source = srcId
|
||||
link.Destination = dstId
|
||||
|
||||
if (src.getRtype() == rtype.DATACENTER || dst.getRtype() == rtype.DATACENTER){
|
||||
link.DCLink = true
|
||||
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (l *Link) AddLinkToDataCenter(component interface{}) {
|
||||
// if the component has a DataCenter id attribute then add it (switch on type)
|
||||
}
|
||||
// So far only computing components expect the ID of the DC in their attributes
|
||||
// func (l *Link) AddLinkToDataCenter(component models.ComputingModel) {
|
||||
// }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user