From c3576e4bd39f42e328de2c6cfe7e662881592535 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 2 Dec 2022 08:23:21 -0500 Subject: [PATCH] Enhance tab completion and extend some documentation and usage --- confluent_client/bin/nodediscover | 2 +- confluent_client/confluent_env.sh | 40 ++++++++++++++++++++-- confluent_client/doc/man/nodediscover.ronn | 10 ++++-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index be75197d..da8b0b21 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -353,7 +353,7 @@ def blocking_scan(session): def main(): parser = optparse.OptionParser( - usage='Usage: %prog [list|assign|rescan|clear] [options]') + usage='Usage: %prog [list|assign|rescan|clear|subscribe|unsubscribe|register] [options]') # -a for 'address' maybe? # order by # show state (discovered or.. diff --git a/confluent_client/confluent_env.sh b/confluent_client/confluent_env.sh index 4d6cba5f..81a70198 100644 --- a/confluent_client/confluent_env.sh +++ b/confluent_client/confluent_env.sh @@ -82,6 +82,17 @@ function _confluent_generic_completion() return; fi } +function _confluent_generic_ng_completion() +{ + _confluent_get_args + if [ $NUMARGS -ge 3 ] && [ ! -z "$GENNED" ]; then + COMPREPLY=($(compgen -W "$GENNED" -- ${COMP_WORDS[COMP_CWORD]})) + fi + if [ $NUMARGS -lt 3 ]; then + _confluent_ng_completion + return; + fi +} _confluent_nodeidentify_completion() { COMP_CANDIDATES=("on,off,blink -h") @@ -268,7 +279,20 @@ _confluent_nodeattrib_completion() _confluent_generic_completion } +_confluent_define_completion() +{ + COMP_CANDIDATES=$(nodegroupattrib 'everything' all | awk '{print $2}'|sed -e 's/://') + _confluent_get_args + if [ $NUMARGS -ge 3 ] && [ ! -z "$GENNED" ]; then + COMPREPLY=($(compgen -W "$GENNED" -- ${COMP_WORDS[COMP_CWORD]})) + fi +} +_confluent_nodegroupattrib_completion() +{ + COMP_CANDIDATES=$(nodegroupattrib 'everything' all | awk '{print $2}'|sed -e 's/://') + _confluent_generic_ng_completion +} _confluent_nn_completion() { _confluent_get_args @@ -323,18 +347,30 @@ _confluent_ng_completion() COMPREPLY=($(compgen -W "$(confetty show /nodegroups|sed -e 's/\///' -e s/^/$PREFIX/)" -- "${COMP_WORDS[COMP_CWORD]}")) } + +_confluent_nodediscover_completion() +{ + _confluent_get_args + if [ $NUMARGS == 2 ]; then + COMPREPLY=($(compgen -W "list assign rescan clear subscribe unsubscribe register" -- ${COMP_WORDS[COMP_CWORD]})) + return; + fi + +} +complete -F _confluent_nodediscover_completion nodediscover complete -F _confluent_nodeattrib_completion nodeattrib -complete -F _confluent_nodeattrib_completion nodegroupattrib complete -F _confluent_nr_completion nodebmcreset complete -F _confluent_nodesetboot_completion nodeboot complete -F _confluent_nr_completion nodeconfig complete -F _confluent_nn_completion nodeconsole +complete -F _confluent_define_completion nodedefine +complete -F _confluent_define_completion nodegroupdefine complete -F _confluent_nr_completion nodeeventlog complete -F _confluent_nodefirmware_completion nodefirmware complete -F _confluent_nodedeploy_completion nodedeploy complete -F _confluent_osimage_completion osdeploy complete -F _confluent_imgutil_completion imgutil -complete -F _confluent_ng_completion nodegroupattrib +complete -F _confluent_nodegroupattrib_completion nodegroupattrib complete -F _confluent_ng_completion nodegroupremove complete -F _confluent_nr_completion nodehealth complete -F _confluent_nodeidentify_completion nodeidentify diff --git a/confluent_client/doc/man/nodediscover.ronn b/confluent_client/doc/man/nodediscover.ronn index 2d79c676..e5ef5f04 100644 --- a/confluent_client/doc/man/nodediscover.ronn +++ b/confluent_client/doc/man/nodediscover.ronn @@ -8,8 +8,9 @@ nodediscover(8) -- List or manage confluent node discovery `nodediscover [options] assign` `nodediscover [options] rescan` `nodediscover [options] clear` -`nodediscover [options] subscribe` -`nodediscover [options] unsubscribe` +`nodediscover [options] subscribe [switch]` +`nodediscover [options] unsubscribe [switch]` +`nodediscover [options] register [Addresses, e.g. 192.168.1.2 or 192.168.1.0/24 or 192.168.1.1-192.168.1.28]` ## DESCRIPTION @@ -38,7 +39,10 @@ scan is the best approach to catch something that appears to be missing. detected device. It takes the same arguments as **nodediscover list**. **nodediscover subscribe** and **unsubscribe** instructs confluent to subscribe to or -unsubscribe from the designated (-n) node running affluent with system discovery support. +unsubscribe from the designated switch running affluent with system discovery support. + +**nodediscover register** instructs confluent to perform a remote probe of an address, subnet, +or range of IP addresses. ## CSV FORMAT