Added methods to verify if workflow contains compute on other peers before setting up admiralty
This commit is contained in:
@@ -1,2 +1,53 @@
|
||||
package workflow_builder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
type AdmiraltySetter struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
func (s *AdmiraltySetter) InitializeAdmiralty(localPeerID string,remotePeerID string) error {
|
||||
|
||||
data := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER),"",localPeerID,nil,nil).LoadOne(remotePeerID)
|
||||
if data.Code != 200 {
|
||||
logger.Error().Msg("Error while trying to instantiate remote peer " + remotePeerID)
|
||||
return fmt.Errorf(data.Err)
|
||||
}
|
||||
remotePeer := data.ToPeer()
|
||||
|
||||
caller := tools.NewHTTPCaller(
|
||||
map[tools.DataType]map[tools.METHOD]string{
|
||||
tools.ADMIRALTY_SOURCE: map[tools.METHOD]string{
|
||||
tools.POST : "/:id",
|
||||
},
|
||||
tools.ADMIRALTY_KUBECONFIG: map[tools.METHOD]string{
|
||||
tools.POST: "/:id",
|
||||
},
|
||||
tools.ADMIRALTY_SECRET: map[tools.METHOD]string{
|
||||
tools.POST: "/:id",
|
||||
},
|
||||
tools.ADMIRALTY_TARGET: map[tools.METHOD]string{
|
||||
tools.POST: "/:id",
|
||||
},
|
||||
tools.ADMIRALTY_NODES: map[tools.METHOD]string{
|
||||
tools.GET: "/id",
|
||||
},
|
||||
},
|
||||
)
|
||||
fmt.Println("Creating source in ")
|
||||
resp, err := remotePeer.LaunchPeerExecution(remotePeer.UUID,"toto-5",tools.ADMIRALTY_SOURCE,tools.POST,nil,caller)
|
||||
if err != nil {
|
||||
fmt.Println("Error contacting remote peer")
|
||||
fmt.Println(err)
|
||||
panic(0)
|
||||
}
|
||||
|
||||
fmt.Println(resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user