utils func for storage
This commit is contained in:
		@@ -7,6 +7,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/storage"
 | 
			
		||||
	"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/tools"
 | 
			
		||||
@@ -35,6 +36,22 @@ func (w *AbstractWorkflow) GetWorkflows() (list_computings []graph.GraphItem) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (w *AbstractWorkflow) GetStoragesByRelatedProcessing(processingID string, relatedToData bool, ignoreRelation bool) []*storage.StorageResource {
 | 
			
		||||
	storages := []*storage.StorageResource{}
 | 
			
		||||
	for _, link := range w.Graph.Links {
 | 
			
		||||
		nodeID := link.Destination.ID                 // we considers that the processing is the destination
 | 
			
		||||
		node := w.Graph.Items[link.Source.ID].Storage // we are looking for the storage as source
 | 
			
		||||
		if node == nil {                              // if the source is not a storage, we consider that the destination is the storage
 | 
			
		||||
			nodeID = link.Source.ID                           // and the processing is the source
 | 
			
		||||
			node = w.Graph.Items[link.Destination.ID].Storage // we are looking for the storage as destination
 | 
			
		||||
		}
 | 
			
		||||
		if processingID == nodeID && node != nil { // if the storage is linked to the processing
 | 
			
		||||
			storages = append(storages, node)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return storages
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (w *AbstractWorkflow) GetProcessings() (list_computings []graph.GraphItem) {
 | 
			
		||||
	for _, item := range w.Graph.Items {
 | 
			
		||||
		if item.Processing != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user