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

Function printVserver

cli/show.go:460–516  ·  view source on GitHub ↗
(vserver *seesaw.Vserver)

Source from the content-addressed store, hash-verified

458}
459
460func printVserver(vserver *seesaw.Vserver) {
461 vserverStatus := "enabled"
462 if !vserver.Enabled {
463 vserverStatus = "disabled"
464 }
465
466 configStatus := "enabled"
467 if !vserver.ConfigEnabled {
468 configStatus = "disabled"
469 }
470
471 status := fmt.Sprintf("%s (override state %s; config state %s)",
472 vserverStatus, vserver.OverrideState, configStatus)
473
474 printHdr("Vserver")
475 printVal("Name:", vserver.Name)
476 printVal("Hostname:", vserver.Host.Hostname)
477 printVal("Status:", status)
478 printFmt("IPv4 Address:", vserver.Host.IPv4Printable())
479 printFmt("IPv6 Address:", vserver.Host.IPv6Printable())
480 fmt.Println()
481 fmt.Printf(" Services:\n")
482
483 var serviceKeys seesaw.ServiceKeys
484 for _, svc := range vserver.Services {
485 serviceKeys = append(serviceKeys, &svc.ServiceKey)
486 }
487 sort.Sort(serviceKeys)
488 for _, sk := range serviceKeys {
489 svc := vserver.Services[*sk]
490
491 config := []string{svc.Mode.String(), fmt.Sprintf("%s scheduler", svc.Scheduler)}
492 if svc.OnePacket {
493 config = append(config, "one-packet mode")
494 }
495 if svc.Persistence > 0 {
496 config = append(config, fmt.Sprintf("%ds persistence", svc.Persistence))
497 }
498 l := label(fmt.Sprintf("%s %s/%d", svc.AF, svc.Proto, svc.Port), 4, 18)
499 fmt.Printf("\n%s (%s)\n", l, strings.Join(config, ", "))
500
501 fmt.Printf("%s %s\n", label("State:", 8, 20),
502 statusSummary(svc.Enabled, svc.Healthy, svc.Active))
503
504 watermarkStatus := fmt.Sprintf("Low %.2f, High %.2f, Currently %.2f",
505 svc.LowWatermark, svc.HighWatermark, svc.CurrentWatermark)
506 fmt.Printf("%s %s\n", label("Watermarks:", 8, 20), watermarkStatus)
507 }
508
509 if len(vserver.Warnings) > 0 {
510 fmt.Println()
511 fmt.Printf(" Warnings:\n")
512 for _, warning := range vserver.Warnings {
513 fmt.Printf(" - %s\n", warning)
514 }
515 }
516}
517

Callers 1

showVserverFunction · 0.85

Calls 8

printHdrFunction · 0.85
printValFunction · 0.85
printFmtFunction · 0.85
labelFunction · 0.85
statusSummaryFunction · 0.85
IPv4PrintableMethod · 0.80
IPv6PrintableMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected