Allows a node uuid prefix to be passed in

This commit is contained in:
Drew Bailey 2019-11-21 14:51:48 -05:00
parent 1e9df94daa
commit 6d5156bbba
No known key found for this signature in database
GPG Key ID: FBA61B9FB7CCE1A7
1 changed files with 22 additions and 0 deletions

View File

@ -89,6 +89,28 @@ func (c *MonitorCommand) Run(args []string) int {
return 1
}
// Query the node info and lookup prefix
if len(nodeID) == 1 {
c.Ui.Error(fmt.Sprintf("Node identifier must contain at least two characters."))
return 1
}
if nodeID != "" {
nodeID = sanitizeUUIDPrefix(nodeID)
nodes, _, err := client.Nodes().PrefixList(nodeID)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error querying node: %v", err))
return 1
}
if len(nodes) > 1 {
out := formatNodeStubList(nodes, false)
c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", out))
return 1
}
nodeID = nodes[0].ID
}
params := map[string]string{
"log_level": logLevel,
"node_id": nodeID,