2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Implement subscribe/unsubscribe in nodediscover

This provides a self-evident entry point from
CLI to extending the discovery to
affluent switches that support it.

This function will work with newer affluent
and Lenovo XCC2 systems.
This commit is contained in:
Jarrod Johnson 2022-11-01 14:16:00 -04:00
parent eec20a6457
commit a6090877ff
2 changed files with 20 additions and 5 deletions

View File

@ -50,7 +50,13 @@ columnmapping = {
}
#TODO: add chassis uuid
def subscribe_discovery(options, session, subscribe):
keyn = 'subscribe' if subscribe else 'unsubscribe'
payload = {keyn: options.node}
for rsp in session.update('/discovery/subscription', payload):
if 'status' in rsp:
print(rsp['status'])
def print_disco(options, session, currmac, outhandler, columns):
procinfo = {}
for tmpinfo in session.read('/discovery/by-mac/{0}'.format(currmac)):
@ -361,7 +367,7 @@ def main():
parser.add_option('-o', '--order', dest='order',
help='Order output by given field', metavar='ORDER')
(options, args) = parser.parse_args()
if len(args) == 0 or args[0] not in ('list', 'assign', 'reassign', 'rescan', 'clear'):
if len(args) == 0 or args[0] not in ('list', 'assign', 'reassign', 'rescan', 'clear', 'subscribe', 'unsubscribe'):
parser.print_help()
sys.exit(1)
session = client.Command()
@ -373,6 +379,10 @@ def main():
assign_discovery(options, session)
if args[0] == 'reassign':
assign_discovery(options, session, False)
if args[0] == 'subscribe':
subscribe_discovery(options, session, True)
if args[0] == 'unsubscribe':
subscribe_discovery(options, session, False)
if args[0] == 'rescan':
blocking_scan(session)
print("Rescan complete")

View File

@ -5,9 +5,11 @@ nodediscover(8) -- List or manage confluent node discovery
`nodediscover rescan`
`nodediscover [options] list`
`nodediscover [options] assign`
`nodediscover [options] rescan`
`nodediscover [options] clear`
`nodediscover [options] assign`
`nodediscover [options] rescan`
`nodediscover [options] clear`
`nodediscover [options] subscribe`
`nodediscover [options] unsubscribe`
## DESCRIPTION
@ -35,6 +37,9 @@ scan is the best approach to catch something that appears to be missing.
**nodedsicover clear** requests the server forget about a selection of
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.
## CSV FORMAT
The CSV format used by nodediscover consists of one header describing the