MCPcopy
hub / github.com/google/seesaw / showNode

Function showNode

cli/show.go:180–225  ·  view source on GitHub ↗
(cli *SeesawCLI, args []string)

Source from the content-addressed store, hash-verified

178}
179
180func showNode(cli *SeesawCLI, args []string) error {
181 if len(args) > 1 {
182 fmt.Println("show node <node>")
183 return nil
184 }
185
186 cs, err := cli.seesaw.ClusterStatus()
187 if err != nil {
188 return fmt.Errorf("Failed to get cluster status: %v", err)
189 }
190 sort.Sort(seesaw.NodesByIPv4{cs.Nodes})
191 if len(args) == 1 {
192 nodeName := args[0]
193 var node *seesaw.Node
194 for _, n := range cs.Nodes {
195 // TODO(baptr): Write a shared matcher implementation for show*.
196 if n.Hostname == nodeName {
197 node = n
198 break
199 }
200 }
201 if node == nil {
202 return fmt.Errorf("node %q not found", nodeName)
203 }
204 printHdr("Node")
205 printVal("Hostname:", node.Hostname)
206 printVal("Site:", cs.Site)
207 printVal("IPv4 Address:", node.IPv4Printable())
208 printVal("IPv6 Address:", node.IPv6Printable())
209 printVal("HA Enabled:", node.State != spb.HaState_DISABLED)
210 printVal("Anycast Enabled:", node.AnycastEnabled)
211 printVal("BGP Enabled:", node.BGPEnabled)
212 printVal("Vservers Enabled:", node.VserversEnabled)
213 return nil
214 }
215 printHdr("Nodes")
216 for i, node := range cs.Nodes {
217 enabled := "enabled"
218 if node.State == spb.HaState_DISABLED {
219 enabled = "disabled"
220 }
221 // TODO(baptr): Figure out how to identify/mark local node.
222 fmt.Printf("[%d] %s %s\n", i+1, node.Hostname, enabled)
223 }
224 return nil
225}
226
227func showBackend(cli *SeesawCLI, args []string) error {
228 if len(args) > 1 {

Callers

nothing calls this directly

Calls 5

printHdrFunction · 0.85
printValFunction · 0.85
IPv4PrintableMethod · 0.80
IPv6PrintableMethod · 0.80
ClusterStatusMethod · 0.65

Tested by

no test coverage detected