|
@ -58,8 +58,12 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) { |
|
|
} |
|
|
} |
|
|
writeJson(w, r, map[string]interface{}{"locations": ret}) |
|
|
writeJson(w, r, map[string]interface{}{"locations": ret}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
w.WriteHeader(http.StatusNotFound) |
|
|
writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found. "}) |
|
|
writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found. "}) |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
w.WriteHeader(http.StatusNotAcceptable) |
|
|
|
|
|
writeJson(w, r, map[string]string{"error": "unknown volumeId format " + vid}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -74,11 +78,13 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) { |
|
|
} |
|
|
} |
|
|
rt, err := storage.NewReplicationTypeFromString(repType) |
|
|
rt, err := storage.NewReplicationTypeFromString(repType) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
w.WriteHeader(http.StatusNotAcceptable) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if topo.GetVolumeLayout(rt).GetActiveVolumeCount() <= 0 { |
|
|
if topo.GetVolumeLayout(rt).GetActiveVolumeCount() <= 0 { |
|
|
if topo.FreeSpace() <= 0 { |
|
|
if topo.FreeSpace() <= 0 { |
|
|
|
|
|
w.WriteHeader(http.StatusNotFound) |
|
|
writeJson(w, r, map[string]string{"error": "No free volumes left!"}) |
|
|
writeJson(w, r, map[string]string{"error": "No free volumes left!"}) |
|
|
return |
|
|
return |
|
|
} else { |
|
|
} else { |
|
@ -89,6 +95,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) { |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl": dn.PublicUrl, "count": count}) |
|
|
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl": dn.PublicUrl, "count": count}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
w.WriteHeader(http.StatusNotAcceptable) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -128,6 +135,7 @@ func volumeGrowHandler(w http.ResponseWriter, r *http.Request) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
w.WriteHeader(http.StatusNotAcceptable) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
writeJson(w, r, map[string]string{"error": err.Error()}) |
|
|
} else { |
|
|
} else { |
|
|
writeJson(w, r, map[string]interface{}{"count": count}) |
|
|
writeJson(w, r, map[string]interface{}{"count": count}) |
|
|