diff --git a/glustercli/cmd/volume.go b/glustercli/cmd/volume.go index 7e9b36321..156189fc2 100644 --- a/glustercli/cmd/volume.go +++ b/glustercli/cmd/volume.go @@ -233,36 +233,52 @@ var volumeDeleteCmd = &cobra.Command{ } var volumeGetCmd = &cobra.Command{ - Use: "get", + Use: "get ", Short: helpVolumeGetCmd, Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { + table := tablewriter.NewWriter(os.Stdout) + table.SetHeader([]string{"Volume Name", "Name", "Modified", "Value", "Default Value", "Option Level"}) + table.SetAlignment(tablewriter.ALIGN_LEFT) + volname := args[0] optname := args[1] - opts, err := client.VolumeGet(volname, optname) - if err != nil { - log.WithError(err).Error("error getting volume options") - failure("Error getting volume options", err, 1) + var volList []string + if volname == "all" { + volInfoList, err := client.Volumes("") + if len(volInfoList) <= 0 { + failure("No volumes found", err, 1) + } + for _, volInfo := range volInfoList { + volList = append(volList, volInfo.Name) + } + } else { + volList = append(volList, volname) } + for _, volume := range volList { - table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"Name", "Modified", "Value", "Default Value", "Option Level"}) - table.SetAlignment(tablewriter.ALIGN_LEFT) - - for _, opt := range opts { - //if modified flag is set, discard unmodified options - if flagGetMdf && !opt.Modified { - continue - } - if flagGetBsc && opt.OptionLevel == "Basic" { - table.Append([]string{opt.OptName, formatBoolYesNo(opt.Modified), opt.Value, opt.DefaultValue, opt.OptionLevel}) + opts, err := client.VolumeGet(volume, optname) + if err != nil { + log.WithError(err).Error("error getting volume options") + failure("Error getting volume options", err, 1) } - if flagGetAdv && opt.OptionLevel == "Advanced" { - table.Append([]string{opt.OptName, formatBoolYesNo(opt.Modified), opt.Value, opt.DefaultValue, opt.OptionLevel}) + for _, opt := range opts { + //if modified flag is set, discard unmodified options + if flagGetMdf && !opt.Modified { + continue + } + if flagGetBsc && opt.OptionLevel == "Basic" { + table.Append([]string{volume, opt.OptName, formatBoolYesNo(opt.Modified), opt.Value, opt.DefaultValue, opt.OptionLevel}) + } + if flagGetAdv && opt.OptionLevel == "Advanced" { + table.Append([]string{volume, opt.OptName, formatBoolYesNo(opt.Modified), opt.Value, opt.DefaultValue, opt.OptionLevel}) + + } } + table.Append([]string{"-", "-", "-", "-", "-", "-"}) } table.Render() diff --git a/pkg/restclient/volume.go b/pkg/restclient/volume.go index 515accc9d..be5429a2e 100644 --- a/pkg/restclient/volume.go +++ b/pkg/restclient/volume.go @@ -124,7 +124,7 @@ func (c *Client) ClusterOptionSet(req api.ClusterOptionReq) error { } // VolumeGet gets volume options for a Gluster Volume -func (c *Client) VolumeGet(volname string, optname string) (api.VolumeOptionsGetResp, error) { +func (c *Client) VolumeGet(volname, optname string) (api.VolumeOptionsGetResp, error) { if optname == "all" { var opts api.VolumeOptionsGetResp url := fmt.Sprintf("/v1/volumes/%s/options", volname)