diff options
| author | Chris Lu <chris.lu@uber.com> | 2019-03-17 20:27:08 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@uber.com> | 2019-03-17 20:27:08 -0700 |
| commit | aca653c08bfaae205e3a62ae9e58ce327a5a583f (patch) | |
| tree | 83cc519f45f0186c10365c5a332e8a995fdb00ed /weed/shell | |
| parent | 22fbbf023b180e3c51261b0746a52be715e86648 (diff) | |
| download | seaweedfs-aca653c08bfaae205e3a62ae9e58ce327a5a583f.tar.xz seaweedfs-aca653c08bfaae205e3a62ae9e58ce327a5a583f.zip | |
weed shell: list volumes
Diffstat (limited to 'weed/shell')
| -rw-r--r-- | weed/shell/command_collection_list.go | 2 | ||||
| -rw-r--r-- | weed/shell/command_volume_list.go | 64 |
2 files changed, 65 insertions, 1 deletions
diff --git a/weed/shell/command_collection_list.go b/weed/shell/command_collection_list.go index f5ed6cfa6..34a406d67 100644 --- a/weed/shell/command_collection_list.go +++ b/weed/shell/command_collection_list.go @@ -30,7 +30,7 @@ func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer } for _, c := range resp.Collections { - fmt.Fprintf(writer, "collection:\"%s\"\treplication:\"%s\"\tTTL:\"%s\"\n", c.GetName(), c.GetReplication(), c.GetTtl()) + fmt.Fprintf(writer, "collection:\"%s\"\n", c.GetName()) } fmt.Fprintf(writer, "Total %d collections.\n", len(resp.Collections)) diff --git a/weed/shell/command_volume_list.go b/weed/shell/command_volume_list.go new file mode 100644 index 000000000..1d921e4b4 --- /dev/null +++ b/weed/shell/command_volume_list.go @@ -0,0 +1,64 @@ +package shell + +import ( + "context" + "fmt" + "github.com/chrislusf/seaweedfs/weed/pb/master_pb" + "io" +) + +func init() { + commands = append(commands, &commandVolumeList{}) +} + +type commandVolumeList struct { +} + +func (c *commandVolumeList) Name() string { + return "volume.list" +} + +func (c *commandVolumeList) Help() string { + return "# list all volumes" +} + +func (c *commandVolumeList) Do(args []string, commandEnv *commandEnv, writer io.Writer) error { + + resp, err := commandEnv.masterClient.VolumeList(context.Background()) + + if err != nil { + return err + } + + writeTopologyInfo(writer,resp.TopologyInfo) + + return nil +} + +func writeTopologyInfo(writer io.Writer, t *master_pb.TopologyInfo) { + fmt.Fprintf(writer, "Topology volume:%d/%d active:%d free:%d\n", t.VolumeCount, t.MaxVolumeCount, t.ActiveVolumeCount, t.FreeVolumeCount) + for _, dc := range t.DataCenterInfos { + writeDataCenterInfo(writer, dc) + } +} +func writeDataCenterInfo(writer io.Writer, t *master_pb.DataCenterInfo) { + fmt.Fprintf(writer, " DataCenter %s volume:%d/%d active:%d free:%d\n", t.Id, t.VolumeCount, t.MaxVolumeCount, t.ActiveVolumeCount, t.FreeVolumeCount) + for _, r := range t.RackInfos { + writeRackInfo(writer, r) + } +} +func writeRackInfo(writer io.Writer, t *master_pb.RackInfo) { + fmt.Fprintf(writer, " Rack %s volume:%d/%d active:%d free:%d\n", t.Id, t.VolumeCount, t.MaxVolumeCount, t.ActiveVolumeCount, t.FreeVolumeCount) + for _, dn := range t.DataNodeInfos { + writeDataNodeInfo(writer, dn) + } +} +func writeDataNodeInfo(writer io.Writer, t *master_pb.DataNodeInfo) { + fmt.Fprintf(writer, " DataNode %s volume:%d/%d active:%d free:%d\n", t.Id, t.VolumeCount, t.MaxVolumeCount, t.ActiveVolumeCount, t.FreeVolumeCount) + for _, vi := range t.VolumeInfos { + writeVolumeInformationMessage(writer, vi) + } +} +func writeVolumeInformationMessage(writer io.Writer, t *master_pb.VolumeInformationMessage) { + fmt.Fprintf(writer, " volume %+v \n", t) +} |
