(cmd *cobra.Command)
| 63 | } |
| 64 | |
| 65 | func listController(cmd *cobra.Command) { |
| 66 | server := common.GetServerInfo(cmd) |
| 67 | url := fmt.Sprintf("http://%s:%d/v1/controllers/", server.IP, server.Port) |
| 68 | |
| 69 | response, err := common.CURLPerform("GET", url, nil, "", []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd)), common.WithORGID(common.GetORGID(cmd))}...) |
| 70 | if err != nil { |
| 71 | fmt.Println(err) |
| 72 | return |
| 73 | } |
| 74 | if len(response.Get("DATA").MustArray()) == 0 { |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | isMasterRegionFunc := func(nodeType int) string { |
| 79 | if nodeType == 1 { |
| 80 | return "true" |
| 81 | } |
| 82 | return "false" |
| 83 | } |
| 84 | |
| 85 | t := table.New() |
| 86 | t.SetHeader([]string{"NAME", "IP", "REGION", "IS_MASTER_REGION", "MAX_AGENT_NUM", "EXP_AGENT_NUM", "CUR_AGENT_NUM"}) |
| 87 | tableItems := [][]string{} |
| 88 | for i := range response.Get("DATA").MustArray() { |
| 89 | row := response.Get("DATA").GetIndex(i) |
| 90 | tableItems = append(tableItems, []string{ |
| 91 | row.Get("NAME").MustString(), |
| 92 | row.Get("IP").MustString(), |
| 93 | row.Get("REGION_NAME").MustString(), |
| 94 | isMasterRegionFunc(row.Get("NODE_TYPE").MustInt()), |
| 95 | strconv.Itoa(row.Get("VTAP_MAX").MustInt()), |
| 96 | strconv.Itoa(row.Get("VTAP_COUNT").MustInt()), |
| 97 | strconv.Itoa(row.Get("CUR_VTAP_COUNT").MustInt()), |
| 98 | }) |
| 99 | } |
| 100 | t.AppendBulk(tableItems) |
| 101 | t.Render() |
| 102 | } |
| 103 | |
| 104 | func ingesterSubCommand() *cobra.Command { |
| 105 | ingester := &cobra.Command{ |
no test coverage detected