summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-04 11:27:30 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-04 11:29:53 +0100
commit2e1b9ab05d094f03f8dc2904bac02ab9904a4824 (patch)
treecf1b6f8fcd5ca836488f5a2843ca664e0b384876
parente54535129f23970619042a328ad9a139bba21c5d (diff)
Added "misc status" (short: "m sts") command
-rw-r--r--cmd-misc.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd-misc.go b/cmd-misc.go
index 8b77de0..450f4b5 100644
--- a/cmd-misc.go
+++ b/cmd-misc.go
@@ -43,6 +43,18 @@ func initCmdMisc(cmdDef *[]cli.Command) {
},
},
},
+ {
+ Name: "status",
+ Aliases: []string{"sts"},
+ Usage: "Get XDS configuration status (including XDS server connection)",
+ Action: xdsStatus,
+ Flags: []cli.Flag{
+ cli.BoolFlag{
+ Name: "verbose, v",
+ Usage: "display verbose output",
+ },
+ },
+ },
},
})
}
@@ -84,3 +96,23 @@ func xdsVersion(ctx *cli.Context) error {
return nil
}
+
+func xdsStatus(ctx *cli.Context) error {
+ cfg := xaapiv1.APIConfig{}
+ if err := XdsConfigGet(&cfg); err != nil {
+ return cli.NewExitError(err.Error(), 1)
+ }
+
+ writer := NewTableWriter()
+ fmt.Fprintln(writer, "XDS Server:")
+ for _, svr := range cfg.Servers {
+ fmt.Fprintln(writer, " ID:\t", svr.ID)
+ fmt.Fprintln(writer, " URL:\t", svr.URL)
+ fmt.Fprintln(writer, " Connected:\t", svr.Connected)
+ fmt.Fprintln(writer, " Connection retry:\t", svr.ConnRetry)
+ fmt.Fprintln(writer, " Disabled:\t", svr.Disabled)
+ }
+ writer.Flush()
+
+ return nil
+}