示例#1
0
// VolumeStatus is a HTTP Handler function to get Gluster Volume Status
func VolumeStatus(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	volName, ok := vars["volName"]
	if !ok {
		volName = ""
	}

	info, err := glustercli.VolumeStatus(volName)
	if err != nil {
		utils.HTTPErrorJSON(w, err.Error(), http.StatusInternalServerError)
	}
	utils.HTTPOutJSON(w, info)
}
示例#2
0
// VolumeGet is a HTTP Handler function to get Gluster Volume Information
func VolumeGet(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	volName, ok := vars["volName"]
	if !ok {
		volName = ""
	}
	status := r.URL.Query().Get("status")
	var info []glustercli.Volume
	var err error
	if status == "1" {
		info, err = glustercli.VolumeStatus(volName)
	} else {
		info, err = glustercli.VolumeInfo(volName)
	}
	if err != nil {
		utils.HTTPErrorJSON(w, err.Error(), http.StatusInternalServerError)
	}
	utils.HTTPOutJSON(w, info)
}