From c227c2353b5206d0f373e6554db59da27f019c54 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 15 Nov 2018 13:41:48 -0500 Subject: [PATCH] Provide better error on nodediscover assign Rather than the rather useless unexpected error, actually describe specific cases of wrong username or password. --- confluent_server/confluent/discovery/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 0d451077..9f37f424 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -394,8 +394,15 @@ def handle_api_request(configmanager, inputdata, operation, pathcomponents): 'Unable to {0} to {1}'.format(operation, '/'.join(pathcomponents))) handler = info['handler'].NodeHandler(info, configmanager) - eval_node(configmanager, handler, info, inputdata['node'], - manual=True) + try: + eval_node(configmanager, handler, info, inputdata['node'], + manual=True) + except Exception as e: + # or... incorrect passworod provided.. + if 'Incorrect password' in str(e) or 'Unauthorized name' in str(e): + return [msg.ConfluentTargetInvalidCredentials( + inputdata['node'])] + raise return [msg.AssignedResource(inputdata['node'])] elif operation == 'delete': mac = _get_mac_from_query(pathcomponents)