shared peer conn

This commit is contained in:
mr
2024-08-13 09:49:42 +02:00
parent 6fe862a9b5
commit e71bd3544f
10 changed files with 237 additions and 24 deletions

View File

@@ -8,6 +8,7 @@ import (
"strings"
"time"
"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/workflow/graph"
@@ -55,11 +56,18 @@ func (wfa *Workflow) CheckBooking(subPath string) (bool, error) {
continue
}
// CHECK BOOKING
url := dc.(*datacenter.DatacenterResource).SourceUrl
caller := tools.NewHTTPCaller("", "", "", "")
peerID := dc.(*datacenter.DatacenterResource).PeerID
if peerID == "" {
return false, errors.New("no peer id")
}
p, code, err := (&peer.Peer{}).GetAccessor(nil).LoadOne(peerID)
if code != 200 {
return false, err
}
caller := tools.NewHTTPCaller(map[string]map[tools.METHOD]string{})
subPath = strings.ReplaceAll(subPath, ":start_date", wfa.getFormat(wfa.Schedule.Start))
subPath = strings.ReplaceAll(subPath, ":end_date", wfa.getFormat(&e))
resp, err := caller.CallGet(url, subPath)
resp, err := caller.CallGet(p.(*peer.Peer).Url, subPath)
if err != nil {
return false, err
}