From da583840685fe7565dffd432541ac27d3f9dd135 Mon Sep 17 00:00:00 2001 From: Wei Qiu Date: Thu, 13 Oct 2016 15:43:36 +0200 Subject: [PATCH] Make running the clone service work --- .../eudat-gef/gef-docker/server/apiserver.go | 19 +++++++++---------- .../eudat-gef/gef-docker/server/gefservice.go | 12 +++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/github.com/eudat-gef/gef-docker/server/apiserver.go b/src/github.com/eudat-gef/gef-docker/server/apiserver.go index c592dd9..d775b84 100644 --- a/src/github.com/eudat-gef/gef-docker/server/apiserver.go +++ b/src/github.com/eudat-gef/gef-docker/server/apiserver.go @@ -289,24 +289,23 @@ func (s *Server) executeServiceHandler(w http.ResponseWriter, r *http.Request) { Response{w}.Location(loc).Created(jmap("Location", loc, "jobID", containerID)) } +// makeBinds construct volume:path binds func makeBinds(r *http.Request, image dckr.Image) ([]string, error) { svc := extractServiceInfo(image) var binds []string for _, in := range svc.Input { - hostPartPath := r.FormValue(in.ID) - if hostPartPath == "" { - return nil, fmt.Errorf("no bind path for input port: %s", in.Name) + volumeID := r.FormValue(in.VolumeID) + if volumeID == "" { + return nil, fmt.Errorf("no bind volume for input port: %s", in.Name) } - hostPath := filepath.Join(HarcodedIrodsMountPoint, hostPartPath) - binds = append(binds, fmt.Sprintf("%s:%s:ro", hostPath, in.Path)) + binds = append(binds, fmt.Sprintf("%s:%s:ro", volumeID, in.Path)) } for _, out := range svc.Output { - hostPartPath := r.FormValue(out.ID) - if hostPartPath == "" { - return nil, fmt.Errorf("no bind path for output port: %s", out.Name) + volumeID := r.FormValue(out.VolumeID) + if volumeID == "" { + return nil, fmt.Errorf("no bind volume for output port: %s", out.Name) } - hostPath := filepath.Join(HarcodedB2DropMountPoint, hostPartPath) - binds = append(binds, fmt.Sprintf("%s:%s", hostPath, out.Path)) + binds = append(binds, fmt.Sprintf("%s:%s", volumeID, out.Path)) } return binds, nil } diff --git a/src/github.com/eudat-gef/gef-docker/server/gefservice.go b/src/github.com/eudat-gef/gef-docker/server/gefservice.go index 5505380..3eb1df8 100644 --- a/src/github.com/eudat-gef/gef-docker/server/gefservice.go +++ b/src/github.com/eudat-gef/gef-docker/server/gefservice.go @@ -24,10 +24,12 @@ type Service struct { } // IOPort is an i/o specification for a service +// The service can only read data from volumes and write to a single volume +// Path specifies where the volumes are mounted type IOPort struct { - ID string - Name string - Path string + VolumeID string + Name string + Path string } // Job is an instance of a running service @@ -79,7 +81,7 @@ func extractServiceInfo(image dckr.Image) Service { in := make([]IOPort, 0, len(srv.Input)) for _, p := range srv.Input { if p.Path != "" { - p.ID = fmt.Sprintf("input%d", len(in)) + p.VolumeID = fmt.Sprintf("input%d", len(in)) in = append(in, p) } } @@ -89,7 +91,7 @@ func extractServiceInfo(image dckr.Image) Service { out := make([]IOPort, 0, len(srv.Output)) for _, p := range srv.Output { if p.Path != "" { - p.ID = fmt.Sprintf("output%d", len(out)) + p.VolumeID = fmt.Sprintf("output%d", len(out)) out = append(out, p) } }