MCPcopy Index your code
hub / github.com/deepflowio/deepflow / listController

Function listController

cli/ctl/server.go:65–102  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

63}
64
65func 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
104func ingesterSubCommand() *cobra.Command {
105 ingester := &cobra.Command{

Callers 1

controllerSubCommandFunction · 0.85

Calls 6

NewMethod · 0.80
SetHeaderMethod · 0.80
AppendBulkMethod · 0.80
RenderMethod · 0.80
GetMethod · 0.65
GetORGIDMethod · 0.45

Tested by

no test coverage detected