| 53 | } |
| 54 | |
| 55 | func (c *OperatorMembersCommand) Run(args []string) int { |
| 56 | f := c.Flags() |
| 57 | |
| 58 | if err := f.Parse(args); err != nil { |
| 59 | c.UI.Error(err.Error()) |
| 60 | return 1 |
| 61 | } |
| 62 | |
| 63 | client, err := c.Client() |
| 64 | if err != nil { |
| 65 | c.UI.Error(err.Error()) |
| 66 | return 2 |
| 67 | } |
| 68 | |
| 69 | resp, err := client.Sys().HAStatus() |
| 70 | if err != nil { |
| 71 | c.UI.Error(err.Error()) |
| 72 | return 2 |
| 73 | } |
| 74 | |
| 75 | switch Format(c.UI) { |
| 76 | case "table": |
| 77 | out := make([]string, 0) |
| 78 | cols := []string{"Host Name", "API Address", "Cluster Address", "Active Node", "Version", "Upgrade Version", "Redundancy Zone", "Last Echo"} |
| 79 | out = append(out, strings.Join(cols, " | ")) |
| 80 | for _, node := range resp.Nodes { |
| 81 | cols := []string{node.Hostname, node.APIAddress, node.ClusterAddress, fmt.Sprintf("%t", node.ActiveNode), node.Version, node.UpgradeVersion, node.RedundancyZone} |
| 82 | if node.LastEcho != nil { |
| 83 | cols = append(cols, node.LastEcho.Format(time.RFC3339)) |
| 84 | } else { |
| 85 | cols = append(cols, "") |
| 86 | } |
| 87 | out = append(out, strings.Join(cols, " | ")) |
| 88 | } |
| 89 | c.UI.Output(tableOutput(out, nil)) |
| 90 | return 0 |
| 91 | default: |
| 92 | return OutputData(c.UI, resp) |
| 93 | } |
| 94 | } |