2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Add register to nodediscover command

This connects the remote registration
api to the usual CLI usage
This commit is contained in:
Jarrod Johnson 2022-11-14 09:42:59 -05:00
parent 6a9024d87e
commit 03e632b630
2 changed files with 13 additions and 3 deletions

View File

@ -50,6 +50,14 @@ columnmapping = {
}
#TODO: add chassis uuid
def register_endpoint(options, session, addr):
for rsp in session.update('/discovery/register', {'addresses': addr}):
if 'created' in rsp:
print('Registered: {0}'.format(rsp['created']))
else:
sys.stderr.write(repr(rsp))
sys.stderr.write('\n')
def subscribe_discovery(options, session, subscribe):
keyn = 'subscribe' if subscribe else 'unsubscribe'
payload = {keyn: options.node}
@ -372,7 +380,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', 'subscribe', 'unsubscribe'):
if len(args) == 0 or args[0] not in ('list', 'assign', 'reassign', 'rescan', 'clear', 'subscribe', 'unsubscribe', 'register'):
parser.print_help()
sys.exit(1)
session = client.Command()
@ -384,6 +392,8 @@ def main():
assign_discovery(options, session)
if args[0] == 'reassign':
assign_discovery(options, session, False)
if args[0] == 'register':
register_endpoint(options, session, args[1])
if args[0] == 'subscribe':
subscribe_discovery(options, session, True)
if args[0] == 'unsubscribe':

View File

@ -475,10 +475,10 @@ def handle_api_request(configmanager, inputdata, operation, pathcomponents):
return (msg.KeyValueData({'status': 'unsubscribed'}),)
elif operation in ('update', 'create'):
if pathcomponents == ['discovery', 'register']:
if 'address' not in inputdata:
if 'addresses' not in inputdata:
raise exc.InvalidArgumentException('Missing address in input')
nd = {
'addresses': [(inputdata['address'], 443)]
'addresses': [(inputdata['addresses'], 443)]
}
sd = ssdp.check_fish(('/DeviceDescription.json', nd))
if not sd: