Skip to content

Commit

Permalink
Merge pull request #3 from qiuwei/dev
Browse files Browse the repository at this point in the history
Make running the clone service work
  • Loading branch information
ubuntolog authored Oct 14, 2016
2 parents 5718225 + da58384 commit a863b16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
19 changes: 9 additions & 10 deletions src/github.com/eudat-gef/gef-docker/server/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 7 additions & 5 deletions src/github.com/eudat-gef/gef-docker/server/gefservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down

0 comments on commit a863b16

Please sign in to comment.